1
0
Fork 0

Using stream cursor in arangoexport and arangosh (#4807)

This commit is contained in:
Simon 2018-03-12 09:41:43 +01:00 committed by Jan
parent bb2d944e04
commit eb709e0dd8
4 changed files with 39 additions and 15 deletions

View File

@ -9,7 +9,8 @@ Contains the query.
@RESTDESCRIPTION
Returns all documents of a collections. The call expects a JSON object
Returns all documents of a collections. Equivalent to the AQL query
`FOR doc IN collection RETURN doc`. The call expects a JSON object
as body with the following attributes:
- *collection*: The name of the collection to query.
@ -17,7 +18,14 @@ as body with the following attributes:
- *skip*: The number of documents to skip in the query (optional).
- *limit*: The maximal amount of documents to return. The *skip*
is applied before the *limit* restriction. (optional)
is applied before the *limit* restriction (optional).
- *batchSize*: The number of documents to return in one go. (optional)
- *ttl*: The time-to-live for the cursor (in seconds, optional).
- *stream*: Create this cursor as a stream query (optional).
Returns a cursor containing the result, see [Http Cursor](../AqlQueryCursor/README.md) for details.

View File

@ -144,16 +144,20 @@ void RestSimpleQueryHandler::allDocuments() {
data.add("count", VPackValue(true));
// pass on standard options
{
VPackSlice ttl = body.get("ttl");
if (!ttl.isNone()) {
data.add("ttl", ttl);
}
VPackSlice batchSize = body.get("batchSize");
if (!batchSize.isNone()) {
data.add("batchSize", batchSize);
}
VPackSlice ttl = body.get("ttl");
if (!ttl.isNone()) {
data.add("ttl", ttl);
}
VPackSlice batchSize = body.get("batchSize");
if (!batchSize.isNone()) {
data.add("batchSize", batchSize);
}
VPackSlice stream = body.get("stream");
if (stream.isBool()) {
VPackObjectBuilder obj(&data, "options");
obj->add("stream", stream);
}
data.close();

View File

@ -75,8 +75,7 @@ ExportFeature::ExportFeature(application_features::ApplicationServer* server,
void ExportFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
options->addOption(
"--collection",
options->addOption("--collection",
"restrict to collection name (can be specified multiple times)",
new VectorParameter<StringParameter>(&_collections));
@ -326,6 +325,9 @@ void ExportFeature::collectionExport(SimpleHttpClient* httpClient) {
post.add("bindVars", VPackValue(VPackValueType::Object));
post.add("@collection", VPackValue(collection));
post.close();
post.add("options", VPackValue(VPackValueType::Object));
post.add("stream", VPackSlice::trueSlice());
post.close();
post.close();
std::shared_ptr<VPackBuilder> parsedBody =
@ -384,6 +386,9 @@ void ExportFeature::queryExport(SimpleHttpClient* httpClient) {
VPackBuilder post;
post.openObject();
post.add("query", VPackValue(_query));
post.add("options", VPackValue(VPackValueType::Object));
post.add("stream", VPackSlice::trueSlice());
post.close();
post.close();
std::shared_ptr<VPackBuilder> parsedBody =
@ -680,6 +685,9 @@ directed="1">
post.add("bindVars", VPackValue(VPackValueType::Object));
post.add("@collection", VPackValue(collection));
post.close();
post.add("options", VPackValue(VPackValueType::Object));
post.add("stream", VPackSlice::trueSlice());
post.close();
post.close();
std::shared_ptr<VPackBuilder> parsedBody =

View File

@ -71,12 +71,16 @@ SimpleQueryAll.prototype.execute = function (batchSize) {
data.batchSize = this._batchSize;
}
// for _api/simple/all stream becomes a top-level option
data.stream = true;
var requestResult = this._collection._database._connection.PUT(
'/_api/simple/all', JSON.stringify(data));
arangosh.checkRequestResult(requestResult);
this._execution = new ArangoQueryCursor(this._collection._database, requestResult);
this._execution = new ArangoQueryCursor(this._collection._database,
requestResult, true);
if (requestResult.hasOwnProperty('count')) {
this._countQuery = requestResult.count;