From 781af3886cc6c96587b8d82a233c8159e56091a3 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 17 Sep 2018 12:52:49 +0200 Subject: [PATCH] Fix deduplication in IndexBlock (#6510) --- arangod/Aql/IndexBlock.cpp | 2 +- js/server/tests/aql/aql-queries-array.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arangod/Aql/IndexBlock.cpp b/arangod/Aql/IndexBlock.cpp index 2a37873626..6fd4f63328 100644 --- a/arangod/Aql/IndexBlock.cpp +++ b/arangod/Aql/IndexBlock.cpp @@ -101,7 +101,7 @@ IndexBlock::IndexBlock(ExecutionEngine* engine, IndexNode const* en) for (size_t i = 0; i < fields.size(); ++i) { if (idx->isAttributeExpanded(i)) { ++expansions; - if (expansions > 1) { + if (expansions > 1 || i > 0) { _hasMultipleExpansions = true; break; } diff --git a/js/server/tests/aql/aql-queries-array.js b/js/server/tests/aql/aql-queries-array.js index 1aa239a227..1e32da6d06 100644 --- a/js/server/tests/aql/aql-queries-array.js +++ b/js/server/tests/aql/aql-queries-array.js @@ -971,12 +971,12 @@ function arrayIndexNonArraySuite () { col.save({ a: [1, 2, 3, 3, 2, 1], b: 1 }); // b: 1 a: 1,2,3 c: null inserted += 3; - insertedB += 3; + insertedB += 1; checkElementsInIndex(inserted); col.save({ a: [1, 2, 3, 3, 2, 1], b: 1, c: 1 }); inserted += 3; - insertedB += 3; + insertedB += 1; checkElementsInIndex(inserted); // 1, 2, 3 :: 1 :: 1 col.save({_key: "null1", a: [null, "a", "b", "c", "b", "a", null] }); @@ -985,12 +985,12 @@ function arrayIndexNonArraySuite () { col.save({_key: "null2", a: [null, "a", "b", "c", "b", "a", null], b: 1 }); inserted += 4; - insertedB += 4; + insertedB += 1; checkElementsInIndex(inserted); col.save({_key: "null3", a: [null, "a", "b", "c", "b", "a", null], b: 1, c: 1}); inserted += 4; - insertedB += 4; + insertedB += 1; checkElementsInIndex(inserted); const query = `FOR x IN ${cName} FILTER @tag IN x.a[*] && 1 == x.b SORT x._key RETURN x._key`; @@ -1005,7 +1005,7 @@ function arrayIndexNonArraySuite () { assertEqual(actual.length, insertedB); const query3 = `FOR x IN ${cName} FILTER null == x.b RETURN x._key`; actual = AQL_EXECUTE(query3).json; - assertEqual(actual.length, inserted - insertedB); + assertEqual(actual.length, col.count() - insertedB); }, testSkiplistMultipleAttributeMiddleArraySub : function () { @@ -1077,12 +1077,12 @@ function arrayIndexNonArraySuite () { col.save({ a: [{d: 1}, {d: 2}, {d: 3}, {d: 3}, {d: 2}, {d: 1}], b: 1 }); inserted += 3; // We index b: 1 and 3 values for a[*].d - insertedB += 3; + insertedB += 1; checkElementsInIndex(inserted); col.save({ a: [{d: 1}, {d: 2}, {d: 3}, {d: 3}, {d: 2}, {d: 1}], b: 1, c: 1 }); inserted += 3; // We index b: 1, c: 1 and 3 values for a[*].d - insertedB += 3; + insertedB += 1; checkElementsInIndex(inserted); col.save({_key: "null3", a: [{d: null}, {d: "a"}, {d: "b"}, {d: "c"}, {d: "b"}, {d: "a"}, {d: null}] }); @@ -1091,12 +1091,12 @@ function arrayIndexNonArraySuite () { col.save({_key: "null4", a: [{d: null}, {d: "a"}, {d: "b"}, {d: "c"}, {d: "b"}, {d: "a"}, {d: null}], b: 1 }); inserted += 4; - insertedB += 4; + insertedB += 1; checkElementsInIndex(inserted); col.save({_key: "null5", a: [{d: null}, {d: "a"}, {d: "b"}, {d: "c"}, {d: "b"}, {d: "a"}, {d: null}], b: 1, c: 1 }); inserted += 4; - insertedB += 4; + insertedB += 1; checkElementsInIndex(inserted); const query = `FOR x IN ${cName} FILTER @tag IN x.a[*].d && 1 == x.b SORT x._key RETURN x._key`; @@ -1114,7 +1114,7 @@ function arrayIndexNonArraySuite () { assertEqual(actual.length, insertedB); const query3 = `FOR x IN ${cName} FILTER null == x.b RETURN x._key`; actual = AQL_EXECUTE(query3).json; - assertEqual(actual.length, inserted - insertedB); + assertEqual(actual.length, col.count() - insertedB); }, testSkiplistIndexSubAttributeArray : function () {