1
0
Fork 0

update velocypack library to latest version (#5605)

This commit is contained in:
Jan 2018-06-18 11:58:57 +02:00 committed by GitHub
parent d4ad460fb7
commit af7299691d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 294 additions and 19 deletions

View File

@ -297,7 +297,7 @@ class Builder {
} }
// Return a Slice of the result: // Return a Slice of the result:
inline Slice slice() const noexcept { inline Slice slice() const {
if (isEmpty()) { if (isEmpty()) {
return Slice(); return Slice();
} }

View File

@ -67,12 +67,12 @@ namespace velocypack {
class SliceScope; class SliceScope;
class SliceStaticData { struct SliceStaticData {
friend class Slice;
static uint8_t const FixedTypeLengths[256]; static uint8_t const FixedTypeLengths[256];
static ValueType const TypeMap[256]; static ValueType const TypeMap[256];
static unsigned int const WidthMap[32]; static unsigned int const WidthMap[32];
static unsigned int const FirstSubMap[32]; static unsigned int const FirstSubMap[32];
static uint64_t const PrecalculatedHashesForDefaultSeed[256];
}; };
class Slice { class Slice {
@ -87,6 +87,7 @@ class Slice {
uint8_t const* _start; uint8_t const* _start;
public: public:
static constexpr uint64_t defaultSeed = 0xdeadbeef;
// constructor for an empty Value of type None // constructor for an empty Value of type None
constexpr Slice() noexcept : Slice("\x00") {} constexpr Slice() noexcept : Slice("\x00") {}
@ -171,18 +172,24 @@ class Slice {
inline uint8_t head() const noexcept { return *_start; } inline uint8_t head() const noexcept { return *_start; }
// hashes the binary representation of a value // hashes the binary representation of a value
inline uint64_t hash(uint64_t seed = 0xdeadbeef) const { inline uint64_t hash(uint64_t seed = defaultSeed) const {
return VELOCYPACK_HASH(start(), checkOverflow(byteSize()), seed); size_t const size = checkOverflow(byteSize());
if (seed == defaultSeed && size == 1) {
uint64_t h = SliceStaticData::PrecalculatedHashesForDefaultSeed[head()];
VELOCYPACK_ASSERT(h != 0);
return h;
}
return VELOCYPACK_HASH(start(), size, seed);
} }
// hashes the value, normalizing different representations of // hashes the value, normalizing different representations of
// arrays, objects and numbers. this function may produce different // arrays, objects and numbers. this function may produce different
// hash values than the binary hash() function // hash values than the binary hash() function
uint64_t normalizedHash(uint64_t seed = 0xdeadbeef) const; uint64_t normalizedHash(uint64_t seed = defaultSeed) const;
// hashes the binary representation of a String slice. No check // hashes the binary representation of a String slice. No check
// is done if the Slice value is actually of type String // is done if the Slice value is actually of type String
inline uint64_t hashString(uint64_t seed = 0xdeadbeef) const noexcept { inline uint64_t hashString(uint64_t seed = defaultSeed) const noexcept {
return VELOCYPACK_HASH(start(), static_cast<size_t>(stringSliceLength()), seed); return VELOCYPACK_HASH(start(), static_cast<size_t>(stringSliceLength()), seed);
} }

View File

@ -97,7 +97,7 @@ bool assemblerFunctionsDisabled();
std::size_t checkOverflow(ValueLength); std::size_t checkOverflow(ValueLength);
#else #else
// on a 64 bit platform, the following function is probably a no-op // on a 64 bit platform, the following function is probably a no-op
static inline constexpr std::size_t checkOverflow(ValueLength length) { static inline constexpr std::size_t checkOverflow(ValueLength length) noexcept {
return static_cast<std::size_t>(length); return static_cast<std::size_t>(length);
} }
#endif #endif
@ -114,7 +114,7 @@ static inline ValueLength getVariableValueLength(ValueLength value) noexcept {
// read a variable length integer in unsigned LEB128 format // read a variable length integer in unsigned LEB128 format
template <bool reverse> template <bool reverse>
static inline ValueLength readVariableValueLength(uint8_t const* source) { static inline ValueLength readVariableValueLength(uint8_t const* source) noexcept {
ValueLength len = 0; ValueLength len = 0;
uint8_t v; uint8_t v;
ValueLength p = 0; ValueLength p = 0;
@ -133,7 +133,7 @@ static inline ValueLength readVariableValueLength(uint8_t const* source) {
// store a variable length integer in unsigned LEB128 format // store a variable length integer in unsigned LEB128 format
template <bool reverse> template <bool reverse>
static inline void storeVariableValueLength(uint8_t* dst, ValueLength value) { static inline void storeVariableValueLength(uint8_t* dst, ValueLength value) noexcept {
VELOCYPACK_ASSERT(value > 0); VELOCYPACK_ASSERT(value > 0);
if (reverse) { if (reverse) {

View File

@ -3,10 +3,10 @@
#ifndef VELOCYPACK_VERSION_NUMBER_H #ifndef VELOCYPACK_VERSION_NUMBER_H
#define VELOCYPACK_VERSION_NUMBER_H 1 #define VELOCYPACK_VERSION_NUMBER_H 1
#define VELOCYPACK_VERSION "0.1.30" #define VELOCYPACK_VERSION "0.1.31"
#define VELOCYPACK_VERSION_MAJOR 0 #define VELOCYPACK_VERSION_MAJOR 0
#define VELOCYPACK_VERSION_MINOR 1 #define VELOCYPACK_VERSION_MINOR 1
#define VELOCYPACK_VERSION_PATCH 30 #define VELOCYPACK_VERSION_PATCH 31
#endif #endif

View File

@ -345,6 +345,269 @@ unsigned int const SliceStaticData::FirstSubMap[32] = {
0, // 0x14, compact object, no index table - note: the offset is dynamic! 0, // 0x14, compact object, no index table - note: the offset is dynamic!
0}; 0};
uint64_t const SliceStaticData::PrecalculatedHashesForDefaultSeed[256] = {
#ifdef VELOCYPACK_XXHASH
/* 0x00 */ 0xe2b56fa571b3a544, /* 0x01 */ 0xda3cfd1dc58389d8,
/* 0x02 */ 0x0000000000000000, /* 0x03 */ 0x0000000000000000,
/* 0x04 */ 0x0000000000000000, /* 0x05 */ 0x0000000000000000,
/* 0x06 */ 0x0000000000000000, /* 0x07 */ 0x0000000000000000,
/* 0x08 */ 0x0000000000000000, /* 0x09 */ 0x0000000000000000,
/* 0x0a */ 0xd296bf393ef8d5f5, /* 0x0b */ 0x0000000000000000,
/* 0x0c */ 0x0000000000000000, /* 0x0d */ 0x0000000000000000,
/* 0x0e */ 0x0000000000000000, /* 0x0f */ 0x0000000000000000,
/* 0x10 */ 0x0000000000000000, /* 0x11 */ 0x0000000000000000,
/* 0x12 */ 0x0000000000000000, /* 0x13 */ 0x0000000000000000,
/* 0x14 */ 0x0000000000000000, /* 0x15 */ 0x0000000000000000,
/* 0x16 */ 0x0000000000000000, /* 0x17 */ 0x24db76da0ebbd8bb,
/* 0x18 */ 0x1a6a668fb2aa030a, /* 0x19 */ 0xed545328fb397fed,
/* 0x1a */ 0xfd783491fceeb46b, /* 0x1b */ 0x0000000000000000,
/* 0x1c */ 0x0000000000000000, /* 0x1d */ 0x0000000000000000,
/* 0x1e */ 0x505ec293ddfeec5e, /* 0x1f */ 0x9fab26ba108e2fbf,
/* 0x20 */ 0x0000000000000000, /* 0x21 */ 0x0000000000000000,
/* 0x22 */ 0x0000000000000000, /* 0x23 */ 0x0000000000000000,
/* 0x24 */ 0x0000000000000000, /* 0x25 */ 0x0000000000000000,
/* 0x26 */ 0x0000000000000000, /* 0x27 */ 0x0000000000000000,
/* 0x28 */ 0x0000000000000000, /* 0x29 */ 0x0000000000000000,
/* 0x2a */ 0x0000000000000000, /* 0x2b */ 0x0000000000000000,
/* 0x2c */ 0x0000000000000000, /* 0x2d */ 0x0000000000000000,
/* 0x2e */ 0x0000000000000000, /* 0x2f */ 0x0000000000000000,
/* 0x30 */ 0xcdf3868203041650, /* 0x31 */ 0x7c9133bfa6f828a6,
/* 0x32 */ 0x62e05b34c4ed7ce4, /* 0x33 */ 0xb79b6530d263533d,
/* 0x34 */ 0xf05f611558114f31, /* 0x35 */ 0xc941f9afc86cdcd5,
/* 0x36 */ 0x79873ccd694a9f90, /* 0x37 */ 0xd360268d66bf8c1f,
/* 0x38 */ 0x19e870f3e36185fe, /* 0x39 */ 0xd154aeb6ba9114e5,
/* 0x3a */ 0xa4d6434557b5b885, /* 0x3b */ 0x91584221ca9eda5b,
/* 0x3c */ 0xb39b55e7252de481, /* 0x3d */ 0xe6bf494f0a40618e,
/* 0x3e */ 0xd2ce603b7dceb6ea, /* 0x3f */ 0xec71f69fe56368f1,
/* 0x40 */ 0x142191d3f9a23bce, /* 0x41 */ 0x0000000000000000,
/* 0x42 */ 0x0000000000000000, /* 0x43 */ 0x0000000000000000,
/* 0x44 */ 0x0000000000000000, /* 0x45 */ 0x0000000000000000,
/* 0x46 */ 0x0000000000000000, /* 0x47 */ 0x0000000000000000,
/* 0x48 */ 0x0000000000000000, /* 0x49 */ 0x0000000000000000,
/* 0x4a */ 0x0000000000000000, /* 0x4b */ 0x0000000000000000,
/* 0x4c */ 0x0000000000000000, /* 0x4d */ 0x0000000000000000,
/* 0x4e */ 0x0000000000000000, /* 0x4f */ 0x0000000000000000,
/* 0x50 */ 0x0000000000000000, /* 0x51 */ 0x0000000000000000,
/* 0x52 */ 0x0000000000000000, /* 0x53 */ 0x0000000000000000,
/* 0x54 */ 0x0000000000000000, /* 0x55 */ 0x0000000000000000,
/* 0x56 */ 0x0000000000000000, /* 0x57 */ 0x0000000000000000,
/* 0x58 */ 0x0000000000000000, /* 0x59 */ 0x0000000000000000,
/* 0x5a */ 0x0000000000000000, /* 0x5b */ 0x0000000000000000,
/* 0x5c */ 0x0000000000000000, /* 0x5d */ 0x0000000000000000,
/* 0x5e */ 0x0000000000000000, /* 0x5f */ 0x0000000000000000,
/* 0x60 */ 0x0000000000000000, /* 0x61 */ 0x0000000000000000,
/* 0x62 */ 0x0000000000000000, /* 0x63 */ 0x0000000000000000,
/* 0x64 */ 0x0000000000000000, /* 0x65 */ 0x0000000000000000,
/* 0x66 */ 0x0000000000000000, /* 0x67 */ 0x0000000000000000,
/* 0x68 */ 0x0000000000000000, /* 0x69 */ 0x0000000000000000,
/* 0x6a */ 0x0000000000000000, /* 0x6b */ 0x0000000000000000,
/* 0x6c */ 0x0000000000000000, /* 0x6d */ 0x0000000000000000,
/* 0x6e */ 0x0000000000000000, /* 0x6f */ 0x0000000000000000,
/* 0x70 */ 0x0000000000000000, /* 0x71 */ 0x0000000000000000,
/* 0x72 */ 0x0000000000000000, /* 0x73 */ 0x0000000000000000,
/* 0x74 */ 0x0000000000000000, /* 0x75 */ 0x0000000000000000,
/* 0x76 */ 0x0000000000000000, /* 0x77 */ 0x0000000000000000,
/* 0x78 */ 0x0000000000000000, /* 0x79 */ 0x0000000000000000,
/* 0x7a */ 0x0000000000000000, /* 0x7b */ 0x0000000000000000,
/* 0x7c */ 0x0000000000000000, /* 0x7d */ 0x0000000000000000,
/* 0x7e */ 0x0000000000000000, /* 0x7f */ 0x0000000000000000,
/* 0x80 */ 0x0000000000000000, /* 0x81 */ 0x0000000000000000,
/* 0x82 */ 0x0000000000000000, /* 0x83 */ 0x0000000000000000,
/* 0x84 */ 0x0000000000000000, /* 0x85 */ 0x0000000000000000,
/* 0x86 */ 0x0000000000000000, /* 0x87 */ 0x0000000000000000,
/* 0x88 */ 0x0000000000000000, /* 0x89 */ 0x0000000000000000,
/* 0x8a */ 0x0000000000000000, /* 0x8b */ 0x0000000000000000,
/* 0x8c */ 0x0000000000000000, /* 0x8d */ 0x0000000000000000,
/* 0x8e */ 0x0000000000000000, /* 0x8f */ 0x0000000000000000,
/* 0x90 */ 0x0000000000000000, /* 0x91 */ 0x0000000000000000,
/* 0x92 */ 0x0000000000000000, /* 0x93 */ 0x0000000000000000,
/* 0x94 */ 0x0000000000000000, /* 0x95 */ 0x0000000000000000,
/* 0x96 */ 0x0000000000000000, /* 0x97 */ 0x0000000000000000,
/* 0x98 */ 0x0000000000000000, /* 0x99 */ 0x0000000000000000,
/* 0x9a */ 0x0000000000000000, /* 0x9b */ 0x0000000000000000,
/* 0x9c */ 0x0000000000000000, /* 0x9d */ 0x0000000000000000,
/* 0x9e */ 0x0000000000000000, /* 0x9f */ 0x0000000000000000,
/* 0xa0 */ 0x0000000000000000, /* 0xa1 */ 0x0000000000000000,
/* 0xa2 */ 0x0000000000000000, /* 0xa3 */ 0x0000000000000000,
/* 0xa4 */ 0x0000000000000000, /* 0xa5 */ 0x0000000000000000,
/* 0xa6 */ 0x0000000000000000, /* 0xa7 */ 0x0000000000000000,
/* 0xa8 */ 0x0000000000000000, /* 0xa9 */ 0x0000000000000000,
/* 0xaa */ 0x0000000000000000, /* 0xab */ 0x0000000000000000,
/* 0xac */ 0x0000000000000000, /* 0xad */ 0x0000000000000000,
/* 0xae */ 0x0000000000000000, /* 0xaf */ 0x0000000000000000,
/* 0xb0 */ 0x0000000000000000, /* 0xb1 */ 0x0000000000000000,
/* 0xb2 */ 0x0000000000000000, /* 0xb3 */ 0x0000000000000000,
/* 0xb4 */ 0x0000000000000000, /* 0xb5 */ 0x0000000000000000,
/* 0xb6 */ 0x0000000000000000, /* 0xb7 */ 0x0000000000000000,
/* 0xb8 */ 0x0000000000000000, /* 0xb9 */ 0x0000000000000000,
/* 0xba */ 0x0000000000000000, /* 0xbb */ 0x0000000000000000,
/* 0xbc */ 0x0000000000000000, /* 0xbd */ 0x0000000000000000,
/* 0xbe */ 0x0000000000000000, /* 0xbf */ 0x0000000000000000,
/* 0xc0 */ 0x0000000000000000, /* 0xc1 */ 0x0000000000000000,
/* 0xc2 */ 0x0000000000000000, /* 0xc3 */ 0x0000000000000000,
/* 0xc4 */ 0x0000000000000000, /* 0xc5 */ 0x0000000000000000,
/* 0xc6 */ 0x0000000000000000, /* 0xc7 */ 0x0000000000000000,
/* 0xc8 */ 0x0000000000000000, /* 0xc9 */ 0x0000000000000000,
/* 0xca */ 0x0000000000000000, /* 0xcb */ 0x0000000000000000,
/* 0xcc */ 0x0000000000000000, /* 0xcd */ 0x0000000000000000,
/* 0xce */ 0x0000000000000000, /* 0xcf */ 0x0000000000000000,
/* 0xd0 */ 0x0000000000000000, /* 0xd1 */ 0x0000000000000000,
/* 0xd2 */ 0x0000000000000000, /* 0xd3 */ 0x0000000000000000,
/* 0xd4 */ 0x0000000000000000, /* 0xd5 */ 0x0000000000000000,
/* 0xd6 */ 0x0000000000000000, /* 0xd7 */ 0x0000000000000000,
/* 0xd8 */ 0x0000000000000000, /* 0xd9 */ 0x0000000000000000,
/* 0xda */ 0x0000000000000000, /* 0xdb */ 0x0000000000000000,
/* 0xdc */ 0x0000000000000000, /* 0xdd */ 0x0000000000000000,
/* 0xde */ 0x0000000000000000, /* 0xdf */ 0x0000000000000000,
/* 0xe0 */ 0x0000000000000000, /* 0xe1 */ 0x0000000000000000,
/* 0xe2 */ 0x0000000000000000, /* 0xe3 */ 0x0000000000000000,
/* 0xe4 */ 0x0000000000000000, /* 0xe5 */ 0x0000000000000000,
/* 0xe6 */ 0x0000000000000000, /* 0xe7 */ 0x0000000000000000,
/* 0xe8 */ 0x0000000000000000, /* 0xe9 */ 0x0000000000000000,
/* 0xea */ 0x0000000000000000, /* 0xeb */ 0x0000000000000000,
/* 0xec */ 0x0000000000000000, /* 0xed */ 0x0000000000000000,
/* 0xee */ 0x0000000000000000, /* 0xef */ 0x0000000000000000,
/* 0xf0 */ 0x0000000000000000, /* 0xf1 */ 0x0000000000000000,
/* 0xf2 */ 0x0000000000000000, /* 0xf3 */ 0x0000000000000000,
/* 0xf4 */ 0x0000000000000000, /* 0xf5 */ 0x0000000000000000,
/* 0xf6 */ 0x0000000000000000, /* 0xf7 */ 0x0000000000000000,
/* 0xf8 */ 0x0000000000000000, /* 0xf9 */ 0x0000000000000000,
/* 0xfa */ 0x0000000000000000, /* 0xfb */ 0x0000000000000000,
/* 0xfc */ 0x0000000000000000, /* 0xfd */ 0x0000000000000000,
/* 0xfe */ 0x0000000000000000, /* 0xff */ 0x0000000000000000
#endif
#ifdef VELOCYPACK_FASTHASH
/* 0x00 */ 0xf747d9afd5fc13cd, /* 0x01 */ 0x9dd59a0795d72dae,
/* 0x02 */ 0x0000000000000000, /* 0x03 */ 0x0000000000000000,
/* 0x04 */ 0x0000000000000000, /* 0x05 */ 0x0000000000000000,
/* 0x06 */ 0x0000000000000000, /* 0x07 */ 0x0000000000000000,
/* 0x08 */ 0x0000000000000000, /* 0x09 */ 0x0000000000000000,
/* 0x0a */ 0x651f231e0822a1f2, /* 0x0b */ 0x0000000000000000,
/* 0x0c */ 0x0000000000000000, /* 0x0d */ 0x0000000000000000,
/* 0x0e */ 0x0000000000000000, /* 0x0f */ 0x0000000000000000,
/* 0x10 */ 0x0000000000000000, /* 0x11 */ 0x0000000000000000,
/* 0x12 */ 0x0000000000000000, /* 0x13 */ 0x0000000000000000,
/* 0x14 */ 0x0000000000000000, /* 0x15 */ 0x0000000000000000,
/* 0x16 */ 0x0000000000000000, /* 0x17 */ 0x423211fec79af09b,
/* 0x18 */ 0xd43a065f33b14e52, /* 0x19 */ 0xf1adc756c139e443,
/* 0x1a */ 0x6bf229fb02c686b , /* 0x1b */ 0x0000000000000000,
/* 0x1c */ 0x0000000000000000, /* 0x1d */ 0x0000000000000000,
/* 0x1e */ 0xc36f498e29ef2aba, /* 0x1f */ 0x1ad28762083cdc7d,
/* 0x20 */ 0x0000000000000000, /* 0x21 */ 0x0000000000000000,
/* 0x22 */ 0x0000000000000000, /* 0x23 */ 0x0000000000000000,
/* 0x24 */ 0x0000000000000000, /* 0x25 */ 0x0000000000000000,
/* 0x26 */ 0x0000000000000000, /* 0x27 */ 0x0000000000000000,
/* 0x28 */ 0x0000000000000000, /* 0x29 */ 0x0000000000000000,
/* 0x2a */ 0x0000000000000000, /* 0x2b */ 0x0000000000000000,
/* 0x2c */ 0x0000000000000000, /* 0x2d */ 0x0000000000000000,
/* 0x2e */ 0x0000000000000000, /* 0x2f */ 0x0000000000000000,
/* 0x30 */ 0xbb1c99a88abf76d2, /* 0x31 */ 0x8d3e0efdb932c4b8,
/* 0x32 */ 0xcd41672e3cd8f76e, /* 0x33 */ 0x3f831eadbd6628f8,
/* 0x34 */ 0x9e4ea5d4abe810ae, /* 0x35 */ 0x836489847293c2d6,
/* 0x36 */ 0x270883ef450bf1c8, /* 0x37 */ 0x4abf5dea3bb7fb98,
/* 0x38 */ 0x5a6892806deadcb2, /* 0x39 */ 0xdeaa9c7264ffdad0,
/* 0x3a */ 0xabd49df61b8b4756, /* 0x3b */ 0xc068ab004a6dc8de,
/* 0x3c */ 0xc2a9f41025e2711b, /* 0x3d */ 0x47cb9c887443ad40,
/* 0x3e */ 0xa57497643e705316, /* 0x3f */ 0xea4688cdf868a142,
/* 0x40 */ 0x49e51044202c2999, /* 0x41 */ 0x0000000000000000,
/* 0x42 */ 0x0000000000000000, /* 0x43 */ 0x0000000000000000,
/* 0x44 */ 0x0000000000000000, /* 0x45 */ 0x0000000000000000,
/* 0x46 */ 0x0000000000000000, /* 0x47 */ 0x0000000000000000,
/* 0x48 */ 0x0000000000000000, /* 0x49 */ 0x0000000000000000,
/* 0x4a */ 0x0000000000000000, /* 0x4b */ 0x0000000000000000,
/* 0x4c */ 0x0000000000000000, /* 0x4d */ 0x0000000000000000,
/* 0x4e */ 0x0000000000000000, /* 0x4f */ 0x0000000000000000,
/* 0x50 */ 0x0000000000000000, /* 0x51 */ 0x0000000000000000,
/* 0x52 */ 0x0000000000000000, /* 0x53 */ 0x0000000000000000,
/* 0x54 */ 0x0000000000000000, /* 0x55 */ 0x0000000000000000,
/* 0x56 */ 0x0000000000000000, /* 0x57 */ 0x0000000000000000,
/* 0x58 */ 0x0000000000000000, /* 0x59 */ 0x0000000000000000,
/* 0x5a */ 0x0000000000000000, /* 0x5b */ 0x0000000000000000,
/* 0x5c */ 0x0000000000000000, /* 0x5d */ 0x0000000000000000,
/* 0x5e */ 0x0000000000000000, /* 0x5f */ 0x0000000000000000,
/* 0x60 */ 0x0000000000000000, /* 0x61 */ 0x0000000000000000,
/* 0x62 */ 0x0000000000000000, /* 0x63 */ 0x0000000000000000,
/* 0x64 */ 0x0000000000000000, /* 0x65 */ 0x0000000000000000,
/* 0x66 */ 0x0000000000000000, /* 0x67 */ 0x0000000000000000,
/* 0x68 */ 0x0000000000000000, /* 0x69 */ 0x0000000000000000,
/* 0x6a */ 0x0000000000000000, /* 0x6b */ 0x0000000000000000,
/* 0x6c */ 0x0000000000000000, /* 0x6d */ 0x0000000000000000,
/* 0x6e */ 0x0000000000000000, /* 0x6f */ 0x0000000000000000,
/* 0x70 */ 0x0000000000000000, /* 0x71 */ 0x0000000000000000,
/* 0x72 */ 0x0000000000000000, /* 0x73 */ 0x0000000000000000,
/* 0x74 */ 0x0000000000000000, /* 0x75 */ 0x0000000000000000,
/* 0x76 */ 0x0000000000000000, /* 0x77 */ 0x0000000000000000,
/* 0x78 */ 0x0000000000000000, /* 0x79 */ 0x0000000000000000,
/* 0x7a */ 0x0000000000000000, /* 0x7b */ 0x0000000000000000,
/* 0x7c */ 0x0000000000000000, /* 0x7d */ 0x0000000000000000,
/* 0x7e */ 0x0000000000000000, /* 0x7f */ 0x0000000000000000,
/* 0x80 */ 0x0000000000000000, /* 0x81 */ 0x0000000000000000,
/* 0x82 */ 0x0000000000000000, /* 0x83 */ 0x0000000000000000,
/* 0x84 */ 0x0000000000000000, /* 0x85 */ 0x0000000000000000,
/* 0x86 */ 0x0000000000000000, /* 0x87 */ 0x0000000000000000,
/* 0x88 */ 0x0000000000000000, /* 0x89 */ 0x0000000000000000,
/* 0x8a */ 0x0000000000000000, /* 0x8b */ 0x0000000000000000,
/* 0x8c */ 0x0000000000000000, /* 0x8d */ 0x0000000000000000,
/* 0x8e */ 0x0000000000000000, /* 0x8f */ 0x0000000000000000,
/* 0x90 */ 0x0000000000000000, /* 0x91 */ 0x0000000000000000,
/* 0x92 */ 0x0000000000000000, /* 0x93 */ 0x0000000000000000,
/* 0x94 */ 0x0000000000000000, /* 0x95 */ 0x0000000000000000,
/* 0x96 */ 0x0000000000000000, /* 0x97 */ 0x0000000000000000,
/* 0x98 */ 0x0000000000000000, /* 0x99 */ 0x0000000000000000,
/* 0x9a */ 0x0000000000000000, /* 0x9b */ 0x0000000000000000,
/* 0x9c */ 0x0000000000000000, /* 0x9d */ 0x0000000000000000,
/* 0x9e */ 0x0000000000000000, /* 0x9f */ 0x0000000000000000,
/* 0xa0 */ 0x0000000000000000, /* 0xa1 */ 0x0000000000000000,
/* 0xa2 */ 0x0000000000000000, /* 0xa3 */ 0x0000000000000000,
/* 0xa4 */ 0x0000000000000000, /* 0xa5 */ 0x0000000000000000,
/* 0xa6 */ 0x0000000000000000, /* 0xa7 */ 0x0000000000000000,
/* 0xa8 */ 0x0000000000000000, /* 0xa9 */ 0x0000000000000000,
/* 0xaa */ 0x0000000000000000, /* 0xab */ 0x0000000000000000,
/* 0xac */ 0x0000000000000000, /* 0xad */ 0x0000000000000000,
/* 0xae */ 0x0000000000000000, /* 0xaf */ 0x0000000000000000,
/* 0xb0 */ 0x0000000000000000, /* 0xb1 */ 0x0000000000000000,
/* 0xb2 */ 0x0000000000000000, /* 0xb3 */ 0x0000000000000000,
/* 0xb4 */ 0x0000000000000000, /* 0xb5 */ 0x0000000000000000,
/* 0xb6 */ 0x0000000000000000, /* 0xb7 */ 0x0000000000000000,
/* 0xb8 */ 0x0000000000000000, /* 0xb9 */ 0x0000000000000000,
/* 0xba */ 0x0000000000000000, /* 0xbb */ 0x0000000000000000,
/* 0xbc */ 0x0000000000000000, /* 0xbd */ 0x0000000000000000,
/* 0xbe */ 0x0000000000000000, /* 0xbf */ 0x0000000000000000,
/* 0xc0 */ 0x0000000000000000, /* 0xc1 */ 0x0000000000000000,
/* 0xc2 */ 0x0000000000000000, /* 0xc3 */ 0x0000000000000000,
/* 0xc4 */ 0x0000000000000000, /* 0xc5 */ 0x0000000000000000,
/* 0xc6 */ 0x0000000000000000, /* 0xc7 */ 0x0000000000000000,
/* 0xc8 */ 0x0000000000000000, /* 0xc9 */ 0x0000000000000000,
/* 0xca */ 0x0000000000000000, /* 0xcb */ 0x0000000000000000,
/* 0xcc */ 0x0000000000000000, /* 0xcd */ 0x0000000000000000,
/* 0xce */ 0x0000000000000000, /* 0xcf */ 0x0000000000000000,
/* 0xd0 */ 0x0000000000000000, /* 0xd1 */ 0x0000000000000000,
/* 0xd2 */ 0x0000000000000000, /* 0xd3 */ 0x0000000000000000,
/* 0xd4 */ 0x0000000000000000, /* 0xd5 */ 0x0000000000000000,
/* 0xd6 */ 0x0000000000000000, /* 0xd7 */ 0x0000000000000000,
/* 0xd8 */ 0x0000000000000000, /* 0xd9 */ 0x0000000000000000,
/* 0xda */ 0x0000000000000000, /* 0xdb */ 0x0000000000000000,
/* 0xdc */ 0x0000000000000000, /* 0xdd */ 0x0000000000000000,
/* 0xde */ 0x0000000000000000, /* 0xdf */ 0x0000000000000000,
/* 0xe0 */ 0x0000000000000000, /* 0xe1 */ 0x0000000000000000,
/* 0xe2 */ 0x0000000000000000, /* 0xe3 */ 0x0000000000000000,
/* 0xe4 */ 0x0000000000000000, /* 0xe5 */ 0x0000000000000000,
/* 0xe6 */ 0x0000000000000000, /* 0xe7 */ 0x0000000000000000,
/* 0xe8 */ 0x0000000000000000, /* 0xe9 */ 0x0000000000000000,
/* 0xea */ 0x0000000000000000, /* 0xeb */ 0x0000000000000000,
/* 0xec */ 0x0000000000000000, /* 0xed */ 0x0000000000000000,
/* 0xee */ 0x0000000000000000, /* 0xef */ 0x0000000000000000,
/* 0xf0 */ 0x0000000000000000, /* 0xf1 */ 0x0000000000000000,
/* 0xf2 */ 0x0000000000000000, /* 0xf3 */ 0x0000000000000000,
/* 0xf4 */ 0x0000000000000000, /* 0xf5 */ 0x0000000000000000,
/* 0xf6 */ 0x0000000000000000, /* 0xf7 */ 0x0000000000000000,
/* 0xf8 */ 0x0000000000000000, /* 0xf9 */ 0x0000000000000000,
/* 0xfa */ 0x0000000000000000, /* 0xfb */ 0x0000000000000000,
/* 0xfc */ 0x0000000000000000, /* 0xfd */ 0x0000000000000000,
/* 0xfe */ 0x0000000000000000, /* 0xff */ 0x0000000000000000
#endif
};
// creates a Slice from Json and adds it to a scope // creates a Slice from Json and adds it to a scope
Slice Slice::fromJson(SliceScope& scope, std::string const& json, Slice Slice::fromJson(SliceScope& scope, std::string const& json,
Options const* options) { Options const* options) {
@ -452,21 +715,26 @@ uint64_t Slice::normalizedHash(uint64_t seed) const {
} else if (isArray()) { } else if (isArray()) {
// normalize arrays by hashing array length and iterating // normalize arrays by hashing array length and iterating
// over all array members // over all array members
uint64_t const n = length() ^ 0xba5bedf00d; ArrayIterator it(*this);
uint64_t const n = it.size() ^ 0xba5bedf00d;
value = VELOCYPACK_HASH(&n, sizeof(n), seed); value = VELOCYPACK_HASH(&n, sizeof(n), seed);
for (auto const& it : ArrayIterator(*this)) { while (it.valid()) {
value ^= it.normalizedHash(value); value ^= it.value().normalizedHash(value);
it.next();
} }
} else if (isObject()) { } else if (isObject()) {
// normalize objects by hashing object length and iterating // normalize objects by hashing object length and iterating
// over all object members // over all object members
uint64_t const n = length() ^ 0xf00ba44ba5; ObjectIterator it(*this, true);
uint64_t const n = it.size() ^ 0xf00ba44ba5;
uint64_t seed2 = VELOCYPACK_HASH(&n, sizeof(n), seed); uint64_t seed2 = VELOCYPACK_HASH(&n, sizeof(n), seed);
value = seed2; value = seed2;
for (auto const& it : ObjectIterator(*this, true)) { while (it.valid()) {
uint64_t seed3 = it.key.makeKey().normalizedHash(seed2); auto current = (*it);
uint64_t seed3 = current.key.normalizedHash(seed2);
value ^= seed3; value ^= seed3;
value ^= it.value.normalizedHash(seed3); value ^= current.value.normalizedHash(seed3);
it.next();
} }
} else { } else {
// fall back to regular hash function // fall back to regular hash function