Skip to content

Commit 70cbb17

Browse files
authored
treat "zkd" and "mdi" indexes as equal when comparing 'em (arangodb#20426)
1 parent 362c0a4 commit 70cbb17

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

arangod/ClusterEngine/ClusterIndexFactory.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ void ClusterIndexFactory::linkIndexFactories(ArangodServer& server,
212212
factory.emplace(mdiIndexFactory._type, mdiIndexFactory);
213213
factory.emplace(mdiPrefixedIndexFactory._type, mdiPrefixedIndexFactory);
214214
factory.emplace(invertedIndexFactory._type, invertedIndexFactory);
215+
factory.emplace("zkd", mdiIndexFactory);
215216
}
216217

217218
ClusterIndexFactory::ClusterIndexFactory(ArangodServer& server)

arangod/Indexes/Index.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,17 +481,25 @@ bool Index::CompareIdentifiers(velocypack::Slice const& lhs,
481481
/// contents are the same
482482
bool Index::Compare(StorageEngine& engine, VPackSlice const& lhs,
483483
VPackSlice const& rhs, std::string const& dbname) {
484-
auto lhsType = lhs.get(arangodb::StaticStrings::IndexType);
485-
TRI_ASSERT(lhsType.isString());
484+
auto normalizeType = [](VPackSlice s) -> std::string_view {
485+
TRI_ASSERT(s.isString());
486+
// "zkd" is the old naming for "mdi", so we have to treat these
487+
// two type names as identical.
488+
if (s.stringView() == "zkd") {
489+
return "mdi";
490+
}
491+
return s.stringView();
492+
};
493+
494+
auto lhsType = normalizeType(lhs.get(arangodb::StaticStrings::IndexType));
495+
auto rhsType = normalizeType(rhs.get(arangodb::StaticStrings::IndexType));
486496

487-
// type must be identical
488-
if (!arangodb::basics::VelocyPackHelper::equal(
489-
lhsType, rhs.get(arangodb::StaticStrings::IndexType), false)) {
497+
if (lhsType != rhsType) {
490498
return false;
491499
}
492500

493501
return engine.indexFactory()
494-
.factory(lhsType.copyString())
502+
.factory(std::string{lhsType})
495503
.equal(lhs, rhs, dbname);
496504
}
497505

arangod/Indexes/IndexFactory.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,25 @@ bool IndexTypeFactory::equal(Index::IndexType type, velocypack::Slice lhs,
118118
velocypack::Slice rhs,
119119
bool attributeOrderMatters) const {
120120
// unique must be identical if present
121-
auto value = lhs.get(StaticStrings::IndexUnique);
122-
123-
if (value.isBoolean() &&
124-
!basics::VelocyPackHelper::equal(
125-
value, rhs.get(StaticStrings::IndexUnique), false)) {
121+
bool lhsUnique = basics::VelocyPackHelper::getBooleanValue(
122+
lhs, StaticStrings::IndexUnique, false);
123+
bool rhsUnique = basics::VelocyPackHelper::getBooleanValue(
124+
rhs, StaticStrings::IndexUnique, false);
125+
if (lhsUnique != rhsUnique) {
126126
return false;
127127
}
128128

129129
// sparse must be identical if present
130-
value = lhs.get(StaticStrings::IndexSparse);
131-
132-
if (value.isBoolean() &&
133-
!basics::VelocyPackHelper::equal(
134-
value, rhs.get(StaticStrings::IndexSparse), false)) {
130+
bool lhsSparse = basics::VelocyPackHelper::getBooleanValue(
131+
lhs, StaticStrings::IndexSparse, false);
132+
bool rhsSparse = basics::VelocyPackHelper::getBooleanValue(
133+
rhs, StaticStrings::IndexSparse, false);
134+
if (lhsSparse != rhsSparse) {
135135
return false;
136136
}
137137

138+
VPackSlice value;
139+
138140
if (Index::IndexType::TRI_IDX_TYPE_GEO1_INDEX == type ||
139141
Index::IndexType::TRI_IDX_TYPE_GEO_INDEX == type) {
140142
// geoJson must be identical if present

0 commit comments

Comments
 (0)