mirror of https://gitee.com/bigwinds/arangodb
issue #1891: renamed to OUTERSECTION
This commit is contained in:
parent
04b29e9c34
commit
274801b7b6
|
@ -1,7 +1,7 @@
|
|||
devel
|
||||
-----
|
||||
|
||||
* added AQL function `DIFFERENCE` to return the symmetric difference of its
|
||||
* added AQL function `OUTERSECTION` to return the symmetric difference of its
|
||||
input arguments
|
||||
|
||||
|
||||
|
|
|
@ -39,16 +39,15 @@ APPEND([ 1, 2, 3 ], [ 3, 4, 5, 2, 9 ], true)
|
|||
|
||||
This is an alias for [LENGTH()](#length).
|
||||
|
||||
!SUBSECTION DIFFERENCE()
|
||||
!SUBSECTION OUTERSECTION()
|
||||
|
||||
`DIFFERENCE(array1, array2, ... arrayN) → newArray`
|
||||
`OUTERSECTION(array1, array2, ... arrayN) → newArray`
|
||||
|
||||
Return the symmetric difference of all arrays specified. The result is an array of values that
|
||||
occur just once across all arguments.
|
||||
Return the values that occur only once across all arrays specified.
|
||||
|
||||
- **arrays** (array, *repeatable*): an arbitrary number of arrays as multiple arguments
|
||||
(at least 2)
|
||||
- returns **newArray** (array): a single array with only the elements, which exist only once
|
||||
- returns **newArray** (array): a single array with only the elements that exist only once
|
||||
across all provided arrays. The element order is random.
|
||||
|
||||
!SUBSECTION FIRST()
|
||||
|
|
|
@ -258,8 +258,8 @@ struct FunctionDefiner {
|
|||
false, true, true, &Functions::UnionDistinct});
|
||||
add({"MINUS", "AQL_MINUS", "l,l|+", true, true, false, true,
|
||||
true, &Functions::Minus});
|
||||
add({"DIFFERENCE", "AQL_DIFFERENCE", "l,l|+", true, true, false,
|
||||
true, true, &Functions::Difference});
|
||||
add({"OUTERSECTION", "AQL_OUTERSECTION", "l,l|+", true, true, false,
|
||||
true, true, &Functions::Outersection});
|
||||
add({"INTERSECTION", "AQL_INTERSECTION", "l,l|+", true, true, false,
|
||||
true, true, &Functions::Intersection});
|
||||
add({"FLATTEN", "AQL_FLATTEN", "l|n", true, true, false,
|
||||
|
|
|
@ -2111,11 +2111,11 @@ AqlValue Functions::Intersection(arangodb::aql::Query* query,
|
|||
return AqlValue(builder.get());
|
||||
}
|
||||
|
||||
/// @brief function DIFFERENCE
|
||||
AqlValue Functions::Difference(arangodb::aql::Query* query,
|
||||
arangodb::AqlTransaction* trx,
|
||||
VPackFunctionParameters const& parameters) {
|
||||
ValidateParameters(parameters, "DIFFERENCE", 2);
|
||||
/// @brief function OUTERSECTION
|
||||
AqlValue Functions::Outersection(arangodb::aql::Query* query,
|
||||
arangodb::AqlTransaction* trx,
|
||||
VPackFunctionParameters const& parameters) {
|
||||
ValidateParameters(parameters, "OUTERSECTION", 2);
|
||||
|
||||
VPackOptions options;
|
||||
options.customTypeHandler =
|
||||
|
@ -2135,7 +2135,7 @@ AqlValue Functions::Difference(arangodb::aql::Query* query,
|
|||
|
||||
if (!value.isArray()) {
|
||||
// not an array
|
||||
RegisterWarning(query, "DIFFERENCE", TRI_ERROR_QUERY_ARRAY_EXPECTED);
|
||||
RegisterWarning(query, "OUTERSECTION", TRI_ERROR_QUERY_ARRAY_EXPECTED);
|
||||
return AqlValue(arangodb::basics::VelocyPackHelper::NullValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -148,9 +148,9 @@ struct Functions {
|
|||
static AqlValue Intersection(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
static AqlValue Difference(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
static AqlValue Outersection(arangodb::aql::Query*,
|
||||
arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
static AqlValue Near(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
VPackFunctionParameters const&);
|
||||
static AqlValue Within(arangodb::aql::Query*, arangodb::AqlTransaction*,
|
||||
|
|
|
@ -3724,7 +3724,7 @@ function AQL_INTERSECTION () {
|
|||
/// in the arrays
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AQL_DIFFERENCE () {
|
||||
function AQL_OUTERSECTION () {
|
||||
'use strict';
|
||||
|
||||
var i, keys = { };
|
||||
|
@ -3744,7 +3744,7 @@ function AQL_DIFFERENCE () {
|
|||
var element = arguments[i];
|
||||
|
||||
if (TYPEWEIGHT(element) !== TYPEWEIGHT_ARRAY) {
|
||||
WARN("DIFFERENCE", INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH);
|
||||
WARN("OUTERSECTION", INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -5700,7 +5700,7 @@ exports.AQL_UNSHIFT = AQL_UNSHIFT;
|
|||
exports.AQL_SLICE = AQL_SLICE;
|
||||
exports.AQL_MINUS = AQL_MINUS;
|
||||
exports.AQL_INTERSECTION = AQL_INTERSECTION;
|
||||
exports.AQL_DIFFERENCE = AQL_DIFFERENCE;
|
||||
exports.AQL_OUTERSECTION = AQL_OUTERSECTION;
|
||||
exports.AQL_FLATTEN = AQL_FLATTEN;
|
||||
exports.AQL_MAX = AQL_MAX;
|
||||
exports.AQL_MIN = AQL_MIN;
|
||||
|
|
|
@ -2572,10 +2572,10 @@ function ahuacatlFunctionsTestSuite () {
|
|||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test difference function
|
||||
/// @brief test outersection function
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testDifference : function () {
|
||||
testOutersection : function () {
|
||||
var queries = [
|
||||
[ [ [ ], [ ], [ ], [ ] ], [ ] ],
|
||||
[ [ [ 1 ], [ ] ], [ 1 ] ],
|
||||
|
@ -2597,13 +2597,13 @@ function ahuacatlFunctionsTestSuite () {
|
|||
var sorter = require("@arangodb/aql").RELATIONAL_CMP;
|
||||
|
||||
queries.forEach(function(query) {
|
||||
var actual = getQueryResults("RETURN DIFFERENCE(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + ")");
|
||||
var actual = getQueryResults("RETURN OUTERSECTION(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + ")");
|
||||
assertEqual(query[1].sort(sorter), actual[0].sort(sorter));
|
||||
|
||||
actual = getQueryResults("RETURN V8(DIFFERENCE(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + "))");
|
||||
actual = getQueryResults("RETURN V8(OUTERSECTION(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + "))");
|
||||
assertEqual(query[1].sort(sorter), actual[0].sort(sorter));
|
||||
|
||||
actual = getQueryResults("RETURN NOOPT(DIFFERENCE(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + "))");
|
||||
actual = getQueryResults("RETURN NOOPT(OUTERSECTION(" + JSON.stringify(query[0]).replace(/^\[(.*)\]$/, "$1") + "))");
|
||||
assertEqual(query[1].sort(sorter), actual[0].sort(sorter));
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue