1
0
Fork 0

removed enum value

This commit is contained in:
jsteemann 2017-06-07 13:23:26 +02:00
parent 3f0b3970cf
commit 21e96d6ff8
2 changed files with 33 additions and 35 deletions

View File

@ -45,7 +45,7 @@ uint64_t AqlValue::hash(transaction::Methods* trx, uint64_t seed) const {
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
// we must use the slow hash function here, because a value may have
// different representations in case it's an array/object/number
return slice().normalizedHash(seed);
@ -192,7 +192,7 @@ size_t AqlValue::length() const {
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
return static_cast<size_t>(slice().length());
}
case DOCVEC: {
@ -217,7 +217,7 @@ AqlValue AqlValue::at(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isArray()) {
int64_t const n = static_cast<int64_t>(s.length());
@ -293,7 +293,7 @@ AqlValue AqlValue::getKeyAttribute(transaction::Methods* trx,
doCopy = false;
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
VPackSlice found = transaction::helpers::extractKeyFromDocument(s);
@ -330,7 +330,7 @@ AqlValue AqlValue::getIdAttribute(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
VPackSlice found = transaction::helpers::extractIdFromDocument(s);
@ -372,7 +372,7 @@ AqlValue AqlValue::getFromAttribute(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
VPackSlice found = transaction::helpers::extractFromFromDocument(s);
@ -409,7 +409,7 @@ AqlValue AqlValue::getToAttribute(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
VPackSlice found = transaction::helpers::extractToFromDocument(s);
@ -447,7 +447,7 @@ AqlValue AqlValue::get(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
VPackSlice found(s.get(name));
@ -494,7 +494,7 @@ AqlValue AqlValue::get(transaction::Methods* trx,
// fall-through intentional
case VPACK_INLINE:
// fall-through intentional
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isObject()) {
if (s.isExternal()) {
@ -556,7 +556,7 @@ bool AqlValue::hasKey(transaction::Methods* trx,
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
return (s.isObject() && s.hasKey(name));
}
@ -581,7 +581,7 @@ double AqlValue::toDouble(transaction::Methods* trx, bool& failed) const {
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isNull()) {
return 0.0;
@ -647,7 +647,7 @@ int64_t AqlValue::toInt64(transaction::Methods* trx) const {
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isNumber()) {
return s.getNumber<int64_t>();
@ -698,7 +698,7 @@ bool AqlValue::toBoolean() const {
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(slice());
if (s.isBoolean()) {
return s.getBoolean();
@ -792,7 +792,7 @@ v8::Handle<v8::Value> AqlValue::toV8(
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackOptions* options = trx->transactionContext()->getVPackOptions();
return TRI_VPackToV8(isolate, slice(), options);
}
@ -851,7 +851,7 @@ void AqlValue::toVelocyPack(transaction::Methods* trx,
break;
} // fallthrough intentional
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
if (resolveExternals) {
bool const sanitizeExternals = true;
bool const sanitizeCustom = true;
@ -891,7 +891,7 @@ AqlValue AqlValue::materialize(transaction::Methods* trx, bool& hasCopied,
switch (type()) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
hasCopied = false;
return *this;
}
@ -928,7 +928,7 @@ AqlValue AqlValue::clone() const {
// copy internal data
return AqlValue(slice());
}
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
// copy buffer
VPackValueLength length = _data.buffer->size();
auto buffer = new VPackBuffer<uint8_t>(length);
@ -969,7 +969,7 @@ void AqlValue::destroy() {
// nothing to do
return;
}
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
delete _data.buffer;
break;
}
@ -1002,7 +1002,7 @@ VPackSlice AqlValue::slice() const {
}
return s;
}
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
VPackSlice s(_data.buffer->data());
if (s.isExternal()) {
s = s.resolveExternal();
@ -1082,8 +1082,6 @@ AqlValue AqlValue::CreateFromBlocks(
/// @brief 3-way comparison for AqlValue objects
int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
AqlValue const& right, bool compareUtf8) {
VPackOptions* options = trx->transactionContextPtr()->getVPackOptions();
AqlValue::AqlValueType const leftType = left.type();
AqlValue::AqlValueType const rightType = right.type();
@ -1098,7 +1096,7 @@ int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
right.toVelocyPack(trx, rightBuilder, false);
return arangodb::basics::VelocyPackHelper::compare(
leftBuilder.slice(), rightBuilder.slice(), compareUtf8, options);
leftBuilder.slice(), rightBuilder.slice(), compareUtf8, trx->transactionContextPtr()->getVPackOptions());
}
// fall-through to other types intentional
}
@ -1108,9 +1106,9 @@ int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
switch (leftType) {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
case VPACK_MANAGED: {
case VPACK_MANAGED_BUFFER: {
return arangodb::basics::VelocyPackHelper::compare(
left.slice(), right.slice(), compareUtf8, options);
left.slice(), right.slice(), compareUtf8, trx->transactionContextPtr()->getVPackOptions());
}
case DOCVEC: {
// use lexicographic ordering of AqlValues regardless of block,

View File

@ -94,7 +94,7 @@ struct AqlValue final {
enum AqlValueType : uint8_t {
VPACK_SLICE_POINTER, // contains a pointer to a vpack document, memory is not managed!
VPACK_INLINE, // contains vpack data, inline
VPACK_MANAGED, // contains vpack, via pointer to a managed buffer
VPACK_MANAGED_BUFFER, // contains vpack, via pointer to a managed buffer
DOCVEC, // a vector of blocks of results coming from a subquery, managed
RANGE // a pointer to a range remembering lower and upper bound, managed
};
@ -109,7 +109,7 @@ struct AqlValue final {
/// VPACK_INLINE: VPack values with a size less than 16 bytes can be stored
/// directly inside the data.internal structure. All data is stored inline,
/// so there is no need for memory management.
/// VPACK_MANAGED: all values of a larger size will be stored in
/// VPACK_MANAGED_BUFFER: all values of a larger size will be stored in
/// _data.external via a managed VPackBuffer object. The Buffer is managed
/// by the AqlValue.
/// DOCVEC: a managed vector of AqlItemBlocks, for storing subquery results.
@ -256,7 +256,7 @@ struct AqlValue final {
_data.buffer = new arangodb::velocypack::Buffer<uint8_t>(length + 1);
_data.buffer->push_back(static_cast<char>(0x40 + length));
_data.buffer->append(value, length);
setType(AqlValueType::VPACK_MANAGED);
setType(AqlValueType::VPACK_MANAGED_BUFFER);
} else {
// long string
// create a big enough Buffer object
@ -266,7 +266,7 @@ struct AqlValue final {
builder.add(VPackValuePair(value, length, VPackValueType::String));
// steal Buffer. now we have ownership
_data.buffer = buffer.release();
setType(AqlValueType::VPACK_MANAGED);
setType(AqlValueType::VPACK_MANAGED_BUFFER);
}
}
@ -292,7 +292,7 @@ struct AqlValue final {
// Use managed buffer, simply reuse the pointer and adjust the original
// Buffer's deleter
_data.buffer = buffer;
setType(AqlValueType::VPACK_MANAGED);
setType(AqlValueType::VPACK_MANAGED_BUFFER);
shouldDelete = false; // adjust deletion control variable
}
}
@ -301,7 +301,7 @@ struct AqlValue final {
explicit AqlValue(arangodb::velocypack::Buffer<uint8_t>* buffer) {
TRI_ASSERT(buffer != nullptr);
_data.buffer = buffer;
setType(AqlValueType::VPACK_MANAGED);
setType(AqlValueType::VPACK_MANAGED_BUFFER);
}
// construct from Builder, copying contents
@ -468,7 +468,7 @@ struct AqlValue final {
/// @brief return the slice for the value
/// this will throw if the value type is not VPACK_SLICE_POINTER, VPACK_INLINE or
/// VPACK_MANAGED
/// VPACK_MANAGED_BUFFER
arangodb::velocypack::Slice slice() const;
/// @brief clone a value
@ -490,7 +490,7 @@ struct AqlValue final {
case VPACK_SLICE_POINTER:
case VPACK_INLINE:
return 0;
case VPACK_MANAGED:
case VPACK_MANAGED_BUFFER:
return _data.buffer->size();
case DOCVEC:
// no need to count the memory usage for the item blocks in docvec.
@ -541,7 +541,7 @@ struct AqlValue final {
// Use managed buffer
_data.buffer = new arangodb::velocypack::Buffer<uint8_t>(length);
_data.buffer->append(reinterpret_cast<char const*>(slice.begin()), length);
setType(AqlValueType::VPACK_MANAGED);
setType(AqlValueType::VPACK_MANAGED_BUFFER);
}
}
@ -667,7 +667,7 @@ struct hash<arangodb::aql::AqlValue> {
case arangodb::aql::AqlValue::VPACK_INLINE: {
return res ^ static_cast<size_t>(arangodb::velocypack::Slice(&x._data.internal[0]).hash());
}
case arangodb::aql::AqlValue::VPACK_MANAGED: {
case arangodb::aql::AqlValue::VPACK_MANAGED_BUFFER: {
return res ^ ptrHash(x._data.buffer);
}
case arangodb::aql::AqlValue::DOCVEC: {
@ -698,7 +698,7 @@ struct equal_to<arangodb::aql::AqlValue> {
case arangodb::aql::AqlValue::VPACK_INLINE: {
return arangodb::velocypack::Slice(&a._data.internal[0]).equals(arangodb::velocypack::Slice(&b._data.internal[0]));
}
case arangodb::aql::AqlValue::VPACK_MANAGED: {
case arangodb::aql::AqlValue::VPACK_MANAGED_BUFFER: {
return a._data.buffer == b._data.buffer;
}
case arangodb::aql::AqlValue::DOCVEC: {