mirror of https://gitee.com/bigwinds/arangodb
fixed issue in `INTERSECTION` AQL function with duplicate elements in the source arrays
This commit is contained in:
parent
9f3b7a9080
commit
ddecc740e6
|
@ -36,6 +36,9 @@ devel
|
||||||
v3.0.4 (XXXX-XX-XX)
|
v3.0.4 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* fixed issue in `INTERSECTION` AQL function with duplicate elements
|
||||||
|
in the source arrays
|
||||||
|
|
||||||
* fixed issue #1970
|
* fixed issue #1970
|
||||||
|
|
||||||
* fixed issue #1967
|
* fixed issue #1967
|
||||||
|
|
|
@ -2079,8 +2079,11 @@ AqlValue Functions::Intersection(arangodb::aql::Query* query,
|
||||||
auto found = values.find(it);
|
auto found = values.find(it);
|
||||||
if (found != values.end()) {
|
if (found != values.end()) {
|
||||||
// already seen
|
// already seen
|
||||||
TRI_ASSERT((*found).second > 0);
|
if ((*found).second < i) {
|
||||||
++(found->second);
|
(*found).second = 0;
|
||||||
|
} else {
|
||||||
|
(*found).second = i + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2439,6 +2439,26 @@ function ahuacatlFunctionsTestSuite () {
|
||||||
assertEqual(expected, actual[0].sort());
|
assertEqual(expected, actual[0].sort());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test intersect function
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testIntersection11 : function () {
|
||||||
|
var expected = [ 1, 3 ];
|
||||||
|
var actual = getQueryResults("RETURN INTERSECTION([ 1, 1, 2, 2, 3, 3, 3 ], [ 1, 1, 3 ])");
|
||||||
|
assertEqual(expected, actual[0].sort());
|
||||||
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test intersect function
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testIntersection12 : function () {
|
||||||
|
var expected = [ 3 ];
|
||||||
|
var actual = getQueryResults("RETURN INTERSECTION([ 1, 1, 3 ], [ 2, 2, 3 ])");
|
||||||
|
assertEqual(expected, actual[0].sort());
|
||||||
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test intersection function
|
/// @brief test intersection function
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -2539,6 +2559,26 @@ function ahuacatlFunctionsTestSuite () {
|
||||||
assertEqual(expected, actual[0].sort());
|
assertEqual(expected, actual[0].sort());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test intersect function
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testIntersectionCxx11 : function () {
|
||||||
|
var expected = [ 1, 3 ];
|
||||||
|
var actual = getQueryResults("RETURN NOOPT(INTERSECTION([ 1, 1, 2, 2, 3, 3, 3 ], [ 1, 1, 3 ]))");
|
||||||
|
assertEqual(expected, actual[0].sort());
|
||||||
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test intersect function
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testIntersectionCxx12 : function () {
|
||||||
|
var expected = [ 3 ];
|
||||||
|
var actual = getQueryResults("RETURN NOOPT(INTERSECTION([ 1, 1, 3 ], [ 2, 2, 3 ]))");
|
||||||
|
assertEqual(expected, actual[0].sort());
|
||||||
|
},
|
||||||
|
|
||||||
testIntersectionAllDocuments : function () {
|
testIntersectionAllDocuments : function () {
|
||||||
// Insert 10 elements
|
// Insert 10 elements
|
||||||
for (var i = 0; i < 10; ++i) {
|
for (var i = 0; i < 10; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue