40
40
#include < velocypack/StringRef.h>
41
41
#include < velocypack/velocypack-aliases.h>
42
42
43
- #include < array>
44
-
45
43
using namespace arangodb ;
46
44
using namespace arangodb ::aql;
47
45
@@ -933,7 +931,7 @@ v8::Handle<v8::Value> AqlValue::toV8(v8::Isolate* isolate, transaction::Methods*
933
931
}
934
932
935
933
// / @brief materializes a value into the builder
936
- void AqlValue::toVelocyPack (transaction::Methods* trx , arangodb::velocypack::Builder& builder,
934
+ void AqlValue::toVelocyPack (VPackOptions const * options , arangodb::velocypack::Builder& builder,
937
935
bool resolveExternals) const {
938
936
switch (type ()) {
939
937
case VPACK_SLICE_POINTER:
@@ -949,7 +947,7 @@ void AqlValue::toVelocyPack(transaction::Methods* trx, arangodb::velocypack::Bui
949
947
bool const sanitizeCustom = true ;
950
948
arangodb::basics::VelocyPackHelper::sanitizeNonClientTypes (
951
949
slice (), VPackSlice::noneSlice (), builder,
952
- trx-> transactionContextPtr ()-> getVPackOptions () , sanitizeExternals,
950
+ options , sanitizeExternals,
953
951
sanitizeCustom);
954
952
} else {
955
953
builder.add (slice ());
@@ -961,7 +959,7 @@ void AqlValue::toVelocyPack(transaction::Methods* trx, arangodb::velocypack::Bui
961
959
for (auto const & it : *_data.docvec ) {
962
960
size_t const n = it->size ();
963
961
for (size_t i = 0 ; i < n; ++i) {
964
- it->getValueReference (i, 0 ).toVelocyPack (trx , builder, resolveExternals);
962
+ it->getValueReference (i, 0 ).toVelocyPack (options , builder, resolveExternals);
965
963
}
966
964
}
967
965
builder.close ();
@@ -980,8 +978,13 @@ void AqlValue::toVelocyPack(transaction::Methods* trx, arangodb::velocypack::Bui
980
978
}
981
979
}
982
980
981
+ void AqlValue::toVelocyPack (transaction::Methods* trx, arangodb::velocypack::Builder& builder,
982
+ bool resolveExternals) const {
983
+ toVelocyPack (trx->transactionContextPtr ()->getVPackOptions (), builder, resolveExternals);
984
+ }
985
+
983
986
// / @brief materializes a value into the builder
984
- AqlValue AqlValue::materialize (transaction::Methods* trx , bool & hasCopied,
987
+ AqlValue AqlValue::materialize (VPackOptions const * options , bool & hasCopied,
985
988
bool resolveExternals) const {
986
989
switch (type ()) {
987
990
case VPACK_INLINE:
@@ -997,7 +1000,7 @@ AqlValue AqlValue::materialize(transaction::Methods* trx, bool& hasCopied,
997
1000
ConditionalDeleter<VPackBuffer<uint8_t >> deleter (shouldDelete);
998
1001
std::shared_ptr<VPackBuffer<uint8_t >> buffer (new VPackBuffer<uint8_t >, deleter);
999
1002
VPackBuilder builder (buffer);
1000
- toVelocyPack (trx , builder, resolveExternals);
1003
+ toVelocyPack (options , builder, resolveExternals);
1001
1004
hasCopied = true ;
1002
1005
return AqlValue (buffer.get (), shouldDelete);
1003
1006
}
@@ -1008,6 +1011,11 @@ AqlValue AqlValue::materialize(transaction::Methods* trx, bool& hasCopied,
1008
1011
return AqlValue ();
1009
1012
}
1010
1013
1014
+ AqlValue AqlValue::materialize (transaction::Methods* trx, bool & hasCopied,
1015
+ bool resolveExternals) const {
1016
+ return materialize (trx->transactionContextPtr ()->getVPackOptions (), hasCopied, resolveExternals);
1017
+ }
1018
+
1011
1019
// / @brief clone a value
1012
1020
AqlValue AqlValue::clone () const {
1013
1021
switch (type ()) {
@@ -1173,23 +1181,24 @@ AqlValue AqlValue::CreateFromBlocks(transaction::Methods* trx,
1173
1181
}
1174
1182
1175
1183
// / @brief comparison for AqlValue objects
1176
- int AqlValue::Compare (transaction::Methods* trx , AqlValue const & left,
1184
+ int AqlValue::Compare (velocypack::Options const * options , AqlValue const & left,
1177
1185
AqlValue const & right, bool compareUtf8) {
1178
1186
AqlValue::AqlValueType const leftType = left.type ();
1179
1187
AqlValue::AqlValueType const rightType = right.type ();
1180
1188
1181
1189
if (leftType != rightType) {
1190
+ // TODO implement this case more efficiently
1182
1191
if (leftType == RANGE || rightType == RANGE || leftType == DOCVEC || rightType == DOCVEC) {
1183
1192
// range|docvec against x
1184
- transaction::BuilderLeaser leftBuilder (trx) ;
1185
- left.toVelocyPack (trx, * leftBuilder. get () , false );
1193
+ VPackBuilder leftBuilder;
1194
+ left.toVelocyPack (options, leftBuilder, false );
1186
1195
1187
- transaction::BuilderLeaser rightBuilder (trx) ;
1188
- right.toVelocyPack (trx, * rightBuilder. get () , false );
1196
+ VPackBuilder rightBuilder;
1197
+ right.toVelocyPack (options, rightBuilder, false );
1189
1198
1190
- return arangodb::basics::VelocyPackHelper::compare (
1191
- leftBuilder-> slice (), rightBuilder-> slice (), compareUtf8 ,
1192
- trx-> transactionContextPtr ()-> getVPackOptions () );
1199
+ return arangodb::basics::VelocyPackHelper::compare (leftBuilder. slice (),
1200
+ rightBuilder. slice (),
1201
+ compareUtf8, options );
1193
1202
}
1194
1203
// fall-through to other types intentional
1195
1204
}
@@ -1201,9 +1210,8 @@ int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
1201
1210
case VPACK_SLICE_POINTER:
1202
1211
case VPACK_MANAGED_SLICE:
1203
1212
case VPACK_MANAGED_BUFFER: {
1204
- return arangodb::basics::VelocyPackHelper::compare (
1205
- left.slice (), right.slice (), compareUtf8,
1206
- trx->transactionContextPtr ()->getVPackOptions ());
1213
+ return arangodb::basics::VelocyPackHelper::compare (left.slice (), right.slice (),
1214
+ compareUtf8, options);
1207
1215
}
1208
1216
case DOCVEC: {
1209
1217
// use lexicographic ordering of AqlValues regardless of block,
@@ -1232,7 +1240,7 @@ int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
1232
1240
AqlValue const & rval =
1233
1241
right._data .docvec ->at (rblock)->getValueReference (ritem, 0 );
1234
1242
1235
- int cmp = Compare (trx , lval, rval, compareUtf8);
1243
+ int cmp = Compare (options , lval, rval, compareUtf8);
1236
1244
1237
1245
if (cmp != 0 ) {
1238
1246
return cmp;
@@ -1280,6 +1288,11 @@ int AqlValue::Compare(transaction::Methods* trx, AqlValue const& left,
1280
1288
return 0 ;
1281
1289
}
1282
1290
1291
+ int AqlValue::Compare (transaction::Methods* trx, AqlValue const & left,
1292
+ AqlValue const & right, bool compareUtf8) {
1293
+ return Compare (trx->transactionContextPtr ()->getVPackOptions (), left, right, compareUtf8);
1294
+ }
1295
+
1283
1296
AqlValue::AqlValue (std::vector<arangodb::aql::SharedAqlItemBlockPtr>* docvec) noexcept {
1284
1297
TRI_ASSERT (docvec != nullptr );
1285
1298
_data.docvec = docvec;
@@ -1610,68 +1623,8 @@ AqlValueGuard::~AqlValueGuard() {
1610
1623
}
1611
1624
1612
1625
void AqlValueGuard::steal () { _destroy = false ; }
1613
- AqlValue& AqlValueGuard::value () { return _value; }
1614
- AqlValueMaterializer::AqlValueMaterializer (transaction::Methods* trx)
1615
- : trx(trx), materialized(), hasCopied(false ) {}
1616
- AqlValueMaterializer::AqlValueMaterializer (AqlValueMaterializer const & other)
1617
- : trx(other.trx), materialized(other.materialized), hasCopied(other.hasCopied) {
1618
- if (other.hasCopied ) {
1619
- // copy other's slice
1620
- materialized = other.materialized .clone ();
1621
- }
1622
- }
1623
1626
1624
- AqlValueMaterializer& AqlValueMaterializer::operator =(AqlValueMaterializer const & other) {
1625
- if (this != &other) {
1626
- TRI_ASSERT (trx == other.trx ); // must be from same transaction
1627
- trx = other.trx ; // to shut up cppcheck
1628
- if (hasCopied) {
1629
- // destroy our own slice
1630
- materialized.destroy ();
1631
- hasCopied = false ;
1632
- }
1633
- // copy other's slice
1634
- materialized = other.materialized .clone ();
1635
- hasCopied = other.hasCopied ;
1636
- }
1637
- return *this ;
1638
- }
1639
-
1640
- AqlValueMaterializer::AqlValueMaterializer (AqlValueMaterializer&& other) noexcept
1641
- : trx(other.trx), materialized(other.materializ
10000
ed), hasCopied(other.hasCopied) {
1642
- // reset other
1643
- other.hasCopied = false ;
1644
- // cppcheck-suppress *
1645
- other.materialized = AqlValue ();
1646
- }
1647
-
1648
- AqlValueMaterializer& AqlValueMaterializer::operator =(AqlValueMaterializer&& other) noexcept {
1649
- if (this != &other) {
1650
- TRI_ASSERT (trx == other.trx ); // must be from same transaction
1651
- trx = other.trx ; // to shut up cppcheck
1652
- if (hasCopied) {
1653
- // destroy our own slice
1654
- materialized.destroy ();
1655
- }
1656
- // reset other
1657
- materialized = other.materialized ;
1658
- hasCopied = other.hasCopied ;
1659
- other.materialized = AqlValue ();
1660
- }
1661
- return *this ;
1662
- }
1663
-
1664
- AqlValueMaterializer::~AqlValueMaterializer () {
1665
- if (hasCopied) {
1666
- materialized.destroy ();
1667
- }
1668
- }
1669
-
1670
- arangodb::velocypack::Slice AqlValueMaterializer::slice (AqlValue const & value,
1671
- bool resolveExternals) {
1672
- materialized = value.materialize (trx, hasCopied, resolveExternals);
1673
- return materialized.slice ();
1674
- }
1627
+ AqlValue& AqlValueGuard::value () { return _value; }
1675
1628
1676
1629
size_t std::hash<arangodb::aql::AqlValue>::operator ()(arangodb::aql::AqlValue const & x) const
1677
1630
noexcept {
0 commit comments