mirror of https://gitee.com/bigwinds/arangodb
Added CXX implementation of SHIFT
This commit is contained in:
parent
fb0b5d8093
commit
1957ef668d
|
@ -180,7 +180,7 @@ std::unordered_map<std::string, Function const> const Executor::FunctionNames{
|
|||
{ "PUSH", Function("PUSH", "AQL_PUSH", "l,.|b", true, true, false, true, false, &Functions::Push) },
|
||||
{ "APPEND", Function("APPEND", "AQL_APPEND", "l,lz|b", true, true, false, true, true, &Functions::Append) },
|
||||
{ "POP", Function("POP", "AQL_POP", "l", true, true, false, true, true, &Functions::Pop) },
|
||||
{ "SHIFT", Function("SHIFT", "AQL_SHIFT", "l", true, true, false, true, true) },
|
||||
{ "SHIFT", Function("SHIFT", "AQL_SHIFT", "l", true, true, false, true, true, &Functions::Shift) },
|
||||
{ "UNSHIFT", Function("UNSHIFT", "AQL_UNSHIFT", "l,.|b", true, true, false, true, true, &Functions::Unshift) },
|
||||
{ "REMOVE_VALUE", Function("REMOVE_VALUE", "AQL_REMOVE_VALUE", "l,.|n", true, true, false, true, true) },
|
||||
{ "REMOVE_VALUES", Function("REMOVE_VALUES", "AQL_REMOVE_VALUES", "l,lz", true, true, false, true, true) },
|
||||
|
|
|
@ -3530,6 +3530,37 @@ AqlValue Functions::Unshift (triagens::aql::Query* query,
|
|||
return AqlValue(new Json(Json::Null));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief function SHIFT
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AqlValue Functions::Shift (triagens::aql::Query* query,
|
||||
triagens::arango::AqlTransaction* trx,
|
||||
FunctionParameters const& parameters) {
|
||||
size_t const n = parameters.size();
|
||||
|
||||
if (n != 1) {
|
||||
THROW_ARANGO_EXCEPTION_PARAMS(TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH, "SHIFT", (int) 1, (int) 1);
|
||||
}
|
||||
|
||||
Json list = ExtractFunctionParameter(trx, parameters, 0, false);
|
||||
if (list.isNull()) {
|
||||
return AqlValue(new Json(Json::Null));
|
||||
}
|
||||
if (list.isArray()) {
|
||||
if (list.size() == 0) {
|
||||
return AqlValue(new Json(Json::Array, 0));
|
||||
}
|
||||
if (!TRI_DeleteArrayJson(TRI_UNKNOWN_MEM_ZONE, list.json(), 0)) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
return AqlValue(new Json(TRI_UNKNOWN_MEM_ZONE, list.copy().steal()));
|
||||
}
|
||||
|
||||
RegisterInvalidArgumentWarning(query, "SHIFT");
|
||||
return AqlValue(new Json(Json::Null));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -135,6 +135,7 @@ namespace triagens {
|
|||
static AqlValue Pop (triagens::aql::Query*, triagens::arango::AqlTransaction*, FunctionParameters const&);
|
||||
static AqlValue Append (triagens::aql::Query*, triagens::arango::AqlTransaction*, FunctionParameters const&);
|
||||
static AqlValue Unshift (triagens::aql::Query*, triagens::arango::AqlTransaction*, FunctionParameters const&);
|
||||
static AqlValue Shift (triagens::aql::Query*, triagens::arango::AqlTransaction*, FunctionParameters const&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue