mirror of https://gitee.com/bigwinds/arangodb
changed functions signature
This commit is contained in:
parent
33df831f41
commit
b04ec219d9
|
@ -35,8 +35,11 @@
|
|||
#include <velocypack/velocypack-aliases.h>
|
||||
|
||||
using namespace arangodb::aql;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief construct a document
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// construct from document
|
||||
AqlValue::AqlValue(TRI_doc_mptr_t const* mptr) {
|
||||
_data.pointer = mptr->vpack();
|
||||
setType(AqlValueType::VPACK_DOCUMENT);
|
||||
|
@ -79,6 +82,20 @@ bool AqlValue::isNull(bool emptyIsNull) const {
|
|||
return (s.isNull() || (emptyIsNull && s.isNone()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not the value contains a null value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool AqlValue::isBoolean() const {
|
||||
AqlValueType t = type();
|
||||
if (t == VPACK_DOCUMENT || t == DOCVEC || t == RANGE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VPackSlice s(slice());
|
||||
return s.isBoolean();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not the value is a number
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -198,6 +198,12 @@ struct AqlValue final {
|
|||
|
||||
bool isNull(bool emptyIsNull) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not the value contains a boolean value
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool isBoolean() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief whether or not the value is a number
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -40,7 +40,7 @@ CollectionScanner::~CollectionScanner() {}
|
|||
|
||||
VPackSlice CollectionScanner::scan(size_t batchSize) {
|
||||
if (!_cursor.hasMore()) {
|
||||
return arangodb::basics::VelocyPackHelper::ArrayValue();
|
||||
return arangodb::basics::VelocyPackHelper::EmptyArrayValue();
|
||||
}
|
||||
_cursor.getMore(batchSize, true);
|
||||
return _cursor.slice();
|
||||
|
|
|
@ -852,8 +852,7 @@ AqlValue Expression::executeSimpleExpressionFCall(
|
|||
|
||||
TRI_ASSERT(parameters.size() == destroyParameters.size());
|
||||
|
||||
AqlValue a = func->implementation(_ast->query(), trx, parameters);
|
||||
mustDestroy = true; // function result is dynamic
|
||||
AqlValue a = func->implementation(_ast->query(), trx, parameters, mustDestroy);
|
||||
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
if (destroyParameters[i]) {
|
||||
|
@ -1196,7 +1195,7 @@ AqlValue Expression::executeSimpleExpressionExpansion(
|
|||
|
||||
if (offset < 0 || count <= 0) {
|
||||
// no items to return... can already stop here
|
||||
return AqlValue(VelocyPackHelper::ArrayValue());
|
||||
return AqlValue(VelocyPackHelper::EmptyArrayValue());
|
||||
}
|
||||
|
||||
// FILTER
|
||||
|
@ -1210,7 +1209,7 @@ AqlValue Expression::executeSimpleExpressionExpansion(
|
|||
filterNode = nullptr;
|
||||
} else {
|
||||
// filter expression is always false
|
||||
return AqlValue(VelocyPackHelper::ArrayValue());
|
||||
return AqlValue(VelocyPackHelper::EmptyArrayValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1230,7 +1229,7 @@ AqlValue Expression::executeSimpleExpressionExpansion(
|
|||
|
||||
if (!a.isArray()) {
|
||||
TRI_ASSERT(!mustDestroy);
|
||||
return AqlValue(VelocyPackHelper::ArrayValue());
|
||||
return AqlValue(VelocyPackHelper::EmptyArrayValue());
|
||||
}
|
||||
|
||||
VPackBuilder builder;
|
||||
|
@ -1273,7 +1272,7 @@ AqlValue Expression::executeSimpleExpressionExpansion(
|
|||
|
||||
if (!a.isArray()) {
|
||||
TRI_ASSERT(!mustDestroy);
|
||||
return AqlValue(VelocyPackHelper::ArrayValue());
|
||||
return AqlValue(VelocyPackHelper::EmptyArrayValue());
|
||||
}
|
||||
|
||||
mustDestroy = localMustDestroy; // maybe we need to destroy...
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,7 +40,7 @@ typedef std::function<bool()> ExecutionCondition;
|
|||
typedef std::vector<AqlValue> VPackFunctionParameters;
|
||||
|
||||
typedef std::function<AqlValue(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&)>
|
||||
VPackFunctionParameters const&, bool&)>
|
||||
FunctionImplementation;
|
||||
|
||||
struct Functions {
|
||||
|
@ -59,170 +59,170 @@ struct Functions {
|
|||
static void DestroyThreadContext();
|
||||
|
||||
static AqlValue IsNull(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsBool(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsNumber(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsString(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsArray(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsObject(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue ToNumber(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue ToString(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue ToBool(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue ToArray(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Length(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue First(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Last(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Nth(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Concat(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Like(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Passthru(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Unset(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue UnsetRecursive(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Keep(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Merge(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue MergeRecursive(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Has(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Attributes(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Values(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Min(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Max(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Sum(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Average(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Md5(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Sha1(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Unique(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue SortedUnique(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Union(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue UnionDistinct(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Intersection(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Neighbors(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Near(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Within(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Flatten(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Zip(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue ParseIdentifier(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Minus(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Document(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Edges(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Round(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Abs(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Ceil(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Floor(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Sqrt(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Pow(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Rand(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue FirstDocument(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue FirstList(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Push(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Pop(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Append(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Unshift(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Shift(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue RemoveValue(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue RemoveValues(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue RemoveNth(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue NotNull(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue CurrentDatabase(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue CollectionCount(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue VarianceSample(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue VariancePopulation(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue StdDevSample(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue StdDevPopulation(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Median(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Percentile(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Range(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Position(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue Fulltext(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
static AqlValue IsSameCollection(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
VPackFunctionParameters const&, bool&);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ static VPackBuilder FalseBuilder;
|
|||
/// expressions but must never be freed
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static VPackBuilder ArrayBuilder;
|
||||
static VPackBuilder EmptyArrayBuilder;
|
||||
|
||||
|
||||
// attribute exclude handler for skipping over system attributes
|
||||
|
@ -129,8 +129,8 @@ void VelocyPackHelper::initialize() {
|
|||
// False value
|
||||
FalseBuilder.add(VPackValue(false));
|
||||
// Array value (empty)
|
||||
ArrayBuilder.openArray();
|
||||
ArrayBuilder.close();
|
||||
EmptyArrayBuilder.openArray();
|
||||
EmptyArrayBuilder.close();
|
||||
}
|
||||
|
||||
arangodb::velocypack::Slice VelocyPackHelper::NullValue() {
|
||||
|
@ -145,8 +145,15 @@ arangodb::velocypack::Slice VelocyPackHelper::FalseValue() {
|
|||
return FalseBuilder.slice();
|
||||
}
|
||||
|
||||
arangodb::velocypack::Slice VelocyPackHelper::ArrayValue() {
|
||||
return ArrayBuilder.slice();
|
||||
arangodb::velocypack::Slice VelocyPackHelper::BooleanValue(bool value) {
|
||||
if (value) {
|
||||
return TrueBuilder.slice();
|
||||
}
|
||||
return FalseBuilder.slice();
|
||||
}
|
||||
|
||||
arangodb::velocypack::Slice VelocyPackHelper::EmptyArrayValue() {
|
||||
return EmptyArrayBuilder.slice();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -213,7 +213,8 @@ class VelocyPackHelper {
|
|||
static arangodb::velocypack::Slice NullValue();
|
||||
static arangodb::velocypack::Slice TrueValue();
|
||||
static arangodb::velocypack::Slice FalseValue();
|
||||
static arangodb::velocypack::Slice ArrayValue();
|
||||
static arangodb::velocypack::Slice BooleanValue(bool);
|
||||
static arangodb::velocypack::Slice EmptyArrayValue();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue