1
0
Fork 0

fixed array index behavior on hash collisions

This commit is contained in:
jsteemann 2016-11-24 13:45:38 +01:00
parent 7deaf8a800
commit 1d4e5e1c8a
2 changed files with 7 additions and 3 deletions

View File

@ -233,6 +233,7 @@ static bool IsEqualElementElementMulti(void* userData,
VPackSlice rightData = right->slice(context, i); VPackSlice rightData = right->slice(context, i);
int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false); int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false);
if (res != 0) { if (res != 0) {
return false; return false;
} }
@ -263,6 +264,7 @@ static bool IsEqualKeyElementMulti(void* userData,
VPackSlice const rightVPack = right->slice(context, i); VPackSlice const rightVPack = right->slice(context, i);
int res = arangodb::basics::VelocyPackHelper::compare(leftVPack, rightVPack, false); int res = arangodb::basics::VelocyPackHelper::compare(leftVPack, rightVPack, false);
if (res != 0) { if (res != 0) {
return false; return false;
} }
@ -480,7 +482,7 @@ HashIndex::HashIndex(TRI_idx_iid_t iid, LogicalCollection* collection,
} }
auto func = std::make_unique<HashElementFunc>(); auto func = std::make_unique<HashElementFunc>();
auto compare = std::make_unique<IsEqualElementElementByKey>(_paths.size()); auto compare = std::make_unique<IsEqualElementElementByKey>(_paths.size(), _useExpansion);
if (_unique) { if (_unique) {
auto array = std::make_unique<TRI_HashArray_t>( auto array = std::make_unique<TRI_HashArray_t>(

View File

@ -244,16 +244,17 @@ class HashIndex final : public PathBasedIndex {
/// @brief determines if a key corresponds to an element /// @brief determines if a key corresponds to an element
class IsEqualElementElementByKey { class IsEqualElementElementByKey {
size_t _numFields; size_t _numFields;
bool _allowExpansion;
public: public:
explicit IsEqualElementElementByKey(size_t n) : _numFields(n) {} IsEqualElementElementByKey(size_t n, bool allowExpansion) : _numFields(n), _allowExpansion(allowExpansion) {}
bool operator()(void* userData, HashIndexElement const* left, bool operator()(void* userData, HashIndexElement const* left,
HashIndexElement const* right) { HashIndexElement const* right) {
TRI_ASSERT(left->revisionId() != 0); TRI_ASSERT(left->revisionId() != 0);
TRI_ASSERT(right->revisionId() != 0); TRI_ASSERT(right->revisionId() != 0);
if (left->revisionId() == right->revisionId()) { if (!_allowExpansion && left->revisionId() == right->revisionId()) {
return true; return true;
} }
@ -264,6 +265,7 @@ class HashIndex final : public PathBasedIndex {
VPackSlice rightData = right->slice(context, i); VPackSlice rightData = right->slice(context, i);
int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false); int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false);
if (res != 0) { if (res != 0) {
return false; return false;
} }