mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
01d632fda4
|
@ -1021,7 +1021,8 @@ static v8::Handle<v8::Value> ExecuteQueryCursorAhuacatl (TRI_vocbase_t* const vo
|
|||
TRI_aql_context_t* const context,
|
||||
const TRI_json_t* const parameters,
|
||||
const bool doCount,
|
||||
const uint32_t batchSize) {
|
||||
const uint32_t batchSize,
|
||||
const bool allowDirectReturn) {
|
||||
v8::HandleScope scope;
|
||||
v8::TryCatch tryCatch;
|
||||
|
||||
|
@ -1031,7 +1032,7 @@ static v8::Handle<v8::Value> ExecuteQueryCursorAhuacatl (TRI_vocbase_t* const vo
|
|||
return scope.Close(v8::ThrowException(tryCatch.Exception()));
|
||||
}
|
||||
|
||||
if (!result->IsArray()) {
|
||||
if (allowDirectReturn || !result->IsArray()) {
|
||||
// rethrow
|
||||
return scope.Close(result);
|
||||
}
|
||||
|
@ -1710,8 +1711,8 @@ static v8::Handle<v8::Value> JS_RunAhuacatl (v8::Arguments const& argv) {
|
|||
v8::TryCatch tryCatch;
|
||||
const uint32_t argc = argv.Length();
|
||||
|
||||
if (argc < 1 || argc > 4) {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("usage: AHUACATL_RUN(<querystring>, <bindvalues>, <doCount>, <max>)")));
|
||||
if (argc < 1 || argc > 5) {
|
||||
return scope.Close(v8::ThrowException(v8::String::New("usage: AHUACATL_RUN(<querystring>, <bindvalues>, <doCount>, <max>, <allowDirectReturn>)")));
|
||||
}
|
||||
|
||||
TRI_vocbase_t* vocbase = GetContextVocBase();
|
||||
|
@ -1735,6 +1736,8 @@ static v8::Handle<v8::Value> JS_RunAhuacatl (v8::Arguments const& argv) {
|
|||
bool doCount = false;
|
||||
// maximum number of results to return at once
|
||||
uint32_t batchSize = 1000;
|
||||
// directly return the results as a javascript array instrad of a cursor (performance optimisation)
|
||||
bool allowDirectReturn = false;
|
||||
if (argc > 2) {
|
||||
doCount = TRI_ObjectToBoolean(argv[2]);
|
||||
if (argc > 3) {
|
||||
|
@ -1742,6 +1745,9 @@ static v8::Handle<v8::Value> JS_RunAhuacatl (v8::Arguments const& argv) {
|
|||
if (maxValue >= 1.0) {
|
||||
batchSize = (uint32_t) maxValue;
|
||||
}
|
||||
if (argc > 4) {
|
||||
allowDirectReturn = TRI_ObjectToBoolean(argv[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1756,7 +1762,7 @@ static v8::Handle<v8::Value> JS_RunAhuacatl (v8::Arguments const& argv) {
|
|||
}
|
||||
|
||||
v8::Handle<v8::Value> result;
|
||||
result = ExecuteQueryCursorAhuacatl(vocbase, context, parameters.ptr(), doCount, batchSize);
|
||||
result = ExecuteQueryCursorAhuacatl(vocbase, context, parameters.ptr(), doCount, batchSize, allowDirectReturn);
|
||||
TRI_FreeContextAql(context);
|
||||
|
||||
if (tryCatch.HasCaught()) {
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
.DataTables_sort_wrapper {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.alignRight {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.writeable {
|
||||
width: 100%;
|
||||
word-wrap: break-word;
|
||||
|
|
|
@ -151,6 +151,7 @@ var collectionTable = $('#collectionsTableID').dataTable({
|
|||
"iDisplayLength": -1,
|
||||
"bJQueryUI": true,
|
||||
"aoColumns": [{"sWidth":"120px", "bSortable":false}, {"sWidth": "200px"}, {"sWidth": "200px"}, {"sWidth": "200px"}, {"sWidth": "200px"}, null ],
|
||||
"aoColumnDefs": [{ "sClass": "alignRight", "aTargets": [ 4, 5 ] }],
|
||||
"oLanguage": {"sEmptyTable": "No collections"}
|
||||
});
|
||||
|
||||
|
|
|
@ -140,7 +140,8 @@ function POST_api_cursor(req, res) {
|
|||
cursor = AHUACATL_RUN(json.query,
|
||||
json.bindVars,
|
||||
(json.count != undefined ? json.count : false),
|
||||
(json.batchSize != undefined ? json.batchSize : 1000));
|
||||
(json.batchSize != undefined ? json.batchSize : 1000),
|
||||
(json.batchSize == undefined));
|
||||
}
|
||||
else {
|
||||
actions.resultBad(req, res, actions.ERROR_QUERY_EMPTY);
|
||||
|
|
|
@ -389,20 +389,38 @@ function ResultUnsupported (req, res, headers) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function ResultCursor (req, res, cursor, code) {
|
||||
var hasCount = cursor.hasCount();
|
||||
var count = cursor.count();
|
||||
var rows = cursor.getRows();
|
||||
var rows;
|
||||
var count;
|
||||
var hasNext;
|
||||
var hasCount;
|
||||
var cursorId;
|
||||
|
||||
// must come after getRows()
|
||||
var hasNext = cursor.hasNext();
|
||||
var cursorId = null;
|
||||
|
||||
if (hasNext) {
|
||||
cursor.persist();
|
||||
cursorId = cursor.id();
|
||||
if (Array.isArray(cursor)) {
|
||||
// performance optimisation: if the value passed in is an error, we can
|
||||
// use it as it is
|
||||
hasCount = true;
|
||||
count = cursor.length;
|
||||
rows = cursor;
|
||||
hasNext = false;
|
||||
cursorId = null;
|
||||
}
|
||||
else {
|
||||
cursor.dispose();
|
||||
// cursor is assumed to be an ArangoCursor
|
||||
hasCount = cursor.hasCount();
|
||||
count = cursor.count();
|
||||
rows = cursor.getRows();
|
||||
|
||||
// must come after getRows()
|
||||
hasNext = cursor.hasNext();
|
||||
cursorId = null;
|
||||
|
||||
if (hasNext) {
|
||||
cursor.persist();
|
||||
cursorId = cursor.id();
|
||||
}
|
||||
else {
|
||||
cursor.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
var result = {
|
||||
|
|
Loading…
Reference in New Issue