diff --git a/arangod/Aql/RangeInfo.h b/arangod/Aql/RangeInfo.h index 4f314be8a0..0797128474 100644 --- a/arangod/Aql/RangeInfo.h +++ b/arangod/Aql/RangeInfo.h @@ -51,86 +51,131 @@ namespace triagens { struct RangeInfoBound { - RangeInfoBound (AstNode const* bound, bool include) - : _include(include), _undefined(false){ - _bound = Json(TRI_UNKNOWN_MEM_ZONE, bound->toJson(TRI_UNKNOWN_MEM_ZONE, true)); - } - - RangeInfoBound (basics::Json const& json) - : _bound(Json(TRI_UNKNOWN_MEM_ZONE, - basics::JsonHelper::checkAndGetArrayValue(json.json(), "bound"), - basics::Json::NOFREE).copy()), - _include(basics::JsonHelper::checkAndGetBooleanValue(json.json(), "include")), - _undefined(false) {} - - RangeInfoBound () : _include(false), _undefined(true) {} +//////////////////////////////////////////////////////////////////////////////// +/// @brief constructors +//////////////////////////////////////////////////////////////////////////////// - ~RangeInfoBound(){} - - RangeInfoBound ( RangeInfoBound const& copy ) - : _bound(copy._bound.copy()), _include(copy._include), - _undefined(copy._undefined) {} - - RangeInfoBound& operator= ( RangeInfoBound const& copy ) = delete; - - void assign ( basics::Json const& json ) { - _bound = Json(TRI_UNKNOWN_MEM_ZONE, - basics::JsonHelper::checkAndGetArrayValue(json.json(), "bound"), - basics::Json::NOFREE).copy(); - _include = basics::JsonHelper::checkAndGetBooleanValue(json.json(), "include"); - _undefined = false; - } - - void assign (AstNode const* bound, bool include) { - _include = include; - _bound = Json(TRI_UNKNOWN_MEM_ZONE, bound->toJson(TRI_UNKNOWN_MEM_ZONE, true)); - _undefined = false; - } - - void assign (RangeInfoBound copy) { - _include = copy._include; - _bound = copy._bound; - _undefined = false; - } - - Json toJson () const { - Json item(basics::Json::Array); - item("bound", Json(TRI_UNKNOWN_MEM_ZONE, - TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, _bound.json()))) - ("include", Json(_include)); - return item; - } - - // doesn't work with unbounded above and below RangeInfos - TRI_index_operator_t* toIndexOperator (bool high, Json parameters, - TRI_shaper_t* shaper) const { - TRI_index_operator_type_e op; - - if (high) { - if (_include) { - op = TRI_LE_INDEX_OPERATOR; - } - else { - op = TRI_LT_INDEX_OPERATOR; - } - } - else { - if (_include) { - op = TRI_GE_INDEX_OPERATOR; - } - else { - op = TRI_GT_INDEX_OPERATOR; - } + RangeInfoBound (AstNode const* bound, bool include) + : _include(include), _undefined(false){ + _bound = Json(TRI_UNKNOWN_MEM_ZONE, + bound->toJson(TRI_UNKNOWN_MEM_ZONE, true)); + } + + RangeInfoBound (basics::Json const& json) + : _bound(Json(TRI_UNKNOWN_MEM_ZONE, + basics::JsonHelper::checkAndGetArrayValue(json.json(), "bound"), + basics::Json::NOFREE).copy()), + _include(basics::JsonHelper::checkAndGetBooleanValue(json.json(), + "include")), + _undefined(false) { + } + + RangeInfoBound () : _include(false), _undefined(true) { } - parameters.add(_bound.get("value").copy()); - size_t nr = parameters.size(); - return TRI_CreateIndexOperator(op, NULL, NULL, parameters.steal(), - shaper, NULL, nr, NULL); - } - Json _bound; - bool _include; - bool _undefined; + RangeInfoBound ( RangeInfoBound const& copy ) + : _bound(copy._bound.copy()), _include(copy._include), + _undefined(copy._undefined) { + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief destructor +//////////////////////////////////////////////////////////////////////////////// + + ~RangeInfoBound(){} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief delete assignment +//////////////////////////////////////////////////////////////////////////////// + + RangeInfoBound& operator= ( RangeInfoBound const& copy ) = delete; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief explicit assign +//////////////////////////////////////////////////////////////////////////////// + + void assign ( basics::Json const& json ) { + _bound = Json(TRI_UNKNOWN_MEM_ZONE, + basics::JsonHelper::checkAndGetArrayValue(json.json(), "bound"), + basics::Json::NOFREE).copy(); + _include = basics::JsonHelper::checkAndGetBooleanValue(json.json(), + "include"); + _undefined = false; + } + + void assign (AstNode const* bound, bool include) { + _include = include; + _bound = Json(TRI_UNKNOWN_MEM_ZONE, + bound->toJson(TRI_UNKNOWN_MEM_ZONE, true)); + _undefined = false; + } + + void assign (RangeInfoBound copy) { + _include = copy._include; + _bound = copy._bound; + _undefined = false; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief toJson +//////////////////////////////////////////////////////////////////////////////// + + Json toJson () const { + Json item(basics::Json::Array); + item("bound", Json(TRI_UNKNOWN_MEM_ZONE, + TRI_CopyJson(TRI_UNKNOWN_MEM_ZONE, _bound.json()))) + ("include", Json(_include)); + return item; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief toIndexOperator, doesn't work with unbounded above and below +/// RangeInfos +//////////////////////////////////////////////////////////////////////////////// + + TRI_index_operator_t* toIndexOperator (bool high, Json parameters, + TRI_shaper_t* shaper) const { + TRI_index_operator_type_e op; + + if (high) { + if (_include) { + op = TRI_LE_INDEX_OPERATOR; + } + else { + op = TRI_LT_INDEX_OPERATOR; + } + } + else { + if (_include) { + op = TRI_GE_INDEX_OPERATOR; + } + else { + op = TRI_GT_INDEX_OPERATOR; + } + } + parameters.add(_bound.get("value").copy()); + size_t nr = parameters.size(); + return TRI_CreateIndexOperator(op, NULL, NULL, parameters.steal(), + shaper, NULL, nr, NULL); + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief _bound as Json +//////////////////////////////////////////////////////////////////////////////// + + Json _bound; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief _include, flag indicating whether or not bound is included +//////////////////////////////////////////////////////////////////////////////// + + bool _include; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief _undefined, if this is true the bound is undefined +//////////////////////////////////////////////////////////////////////////////// + + bool _undefined; }; diff --git a/js/server/tests/aql-functions.js b/js/server/tests/aql-functions.js index 9073f0c509..6b8869405c 100644 --- a/js/server/tests/aql-functions.js +++ b/js/server/tests/aql-functions.js @@ -4034,7 +4034,7 @@ function ahuacatlFunctionsTestSuite () { // allow some tolerance for the time diff // TODO: we're currently sleeping twice because we're testing // old AQL against new AQL. when we're done comparing, remove the 2 * - assertTrue(diff >= 1.8 && diff <= 2.5); + assertTrue(diff >= 1.8 && diff <= 2.5, "SLEEP(2) did not take between 1.8 and 2.5 seconds"); }, ////////////////////////////////////////////////////////////////////////////////