From add6711670aa4c4e63b0d39ddb2d0fcadef53483 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Thu, 24 May 2012 11:59:02 +0200 Subject: [PATCH 1/2] 2columns align right --- html/admin/css/layout.css | 8 ++++++++ html/admin/js/master.js | 1 + 2 files changed, 9 insertions(+) diff --git a/html/admin/css/layout.css b/html/admin/css/layout.css index f46daec081..936865f4ad 100644 --- a/html/admin/css/layout.css +++ b/html/admin/css/layout.css @@ -1,3 +1,11 @@ +.DataTables_sort_wrapper { + text-align: center !important; +} + +.alignRight { + text-align: right; +} + .writeable { width: 100%; word-wrap: break-word; diff --git a/html/admin/js/master.js b/html/admin/js/master.js index a473deae50..b40e9e0380 100644 --- a/html/admin/js/master.js +++ b/html/admin/js/master.js @@ -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"} }); From 9d5e80b5b0270211922e6ee760d3671d40a35fd5 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Thu, 24 May 2012 12:24:23 +0200 Subject: [PATCH 2/2] double the throughput for simple AQL queries by returning the result set as V8 list instead of a cursor --- V8/v8-vocbase.cpp | 16 ++++++++----- js/actions/system/api-cursor.js | 3 ++- js/server/modules/actions.js | 40 ++++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index 8cb331d32c..833cdc6ed9 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -1021,7 +1021,8 @@ static v8::Handle 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 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 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(, , , )"))); + if (argc < 1 || argc > 5) { + return scope.Close(v8::ThrowException(v8::String::New("usage: AHUACATL_RUN(, , , , )"))); } TRI_vocbase_t* vocbase = GetContextVocBase(); @@ -1735,6 +1736,8 @@ static v8::Handle 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 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 JS_RunAhuacatl (v8::Arguments const& argv) { } v8::Handle result; - result = ExecuteQueryCursorAhuacatl(vocbase, context, parameters.ptr(), doCount, batchSize); + result = ExecuteQueryCursorAhuacatl(vocbase, context, parameters.ptr(), doCount, batchSize, allowDirectReturn); TRI_FreeContextAql(context); if (tryCatch.HasCaught()) { diff --git a/js/actions/system/api-cursor.js b/js/actions/system/api-cursor.js index 23b1fa5a7a..9ed28d4ed3 100644 --- a/js/actions/system/api-cursor.js +++ b/js/actions/system/api-cursor.js @@ -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); diff --git a/js/server/modules/actions.js b/js/server/modules/actions.js index 7baeba55a5..8a18dc6832 100644 --- a/js/server/modules/actions.js +++ b/js/server/modules/actions.js @@ -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 = {