mirror of https://gitee.com/bigwinds/arangodb
fixed array index behavior on hash collisions
This commit is contained in:
parent
7deaf8a800
commit
1d4e5e1c8a
|
@ -233,6 +233,7 @@ static bool IsEqualElementElementMulti(void* userData,
|
|||
VPackSlice rightData = right->slice(context, i);
|
||||
|
||||
int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false);
|
||||
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -263,6 +264,7 @@ static bool IsEqualKeyElementMulti(void* userData,
|
|||
VPackSlice const rightVPack = right->slice(context, i);
|
||||
|
||||
int res = arangodb::basics::VelocyPackHelper::compare(leftVPack, rightVPack, false);
|
||||
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -480,7 +482,7 @@ HashIndex::HashIndex(TRI_idx_iid_t iid, LogicalCollection* collection,
|
|||
}
|
||||
|
||||
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) {
|
||||
auto array = std::make_unique<TRI_HashArray_t>(
|
||||
|
|
|
@ -244,16 +244,17 @@ class HashIndex final : public PathBasedIndex {
|
|||
/// @brief determines if a key corresponds to an element
|
||||
class IsEqualElementElementByKey {
|
||||
size_t _numFields;
|
||||
bool _allowExpansion;
|
||||
|
||||
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,
|
||||
HashIndexElement const* right) {
|
||||
TRI_ASSERT(left->revisionId() != 0);
|
||||
TRI_ASSERT(right->revisionId() != 0);
|
||||
|
||||
if (left->revisionId() == right->revisionId()) {
|
||||
if (!_allowExpansion && left->revisionId() == right->revisionId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -264,6 +265,7 @@ class HashIndex final : public PathBasedIndex {
|
|||
VPackSlice rightData = right->slice(context, i);
|
||||
|
||||
int res = arangodb::basics::VelocyPackHelper::compare(leftData, rightData, false);
|
||||
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue