1
0
Fork 0

issue #1891: renamed to OUTERSECTION

This commit is contained in:
jsteemann 2016-06-24 14:07:41 +02:00
parent 04b29e9c34
commit 274801b7b6
7 changed files with 24 additions and 25 deletions

View File

@ -1,7 +1,7 @@
devel 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 input arguments

View File

@ -39,16 +39,15 @@ APPEND([ 1, 2, 3 ], [ 3, 4, 5, 2, 9 ], true)
This is an alias for [LENGTH()](#length). 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 Return the values that occur only once across all arrays specified.
occur just once across all arguments.
- **arrays** (array, *repeatable*): an arbitrary number of arrays as multiple arguments - **arrays** (array, *repeatable*): an arbitrary number of arrays as multiple arguments
(at least 2) (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. across all provided arrays. The element order is random.
!SUBSECTION FIRST() !SUBSECTION FIRST()

View File

@ -258,8 +258,8 @@ struct FunctionDefiner {
false, true, true, &Functions::UnionDistinct}); false, true, true, &Functions::UnionDistinct});
add({"MINUS", "AQL_MINUS", "l,l|+", true, true, false, true, add({"MINUS", "AQL_MINUS", "l,l|+", true, true, false, true,
true, &Functions::Minus}); true, &Functions::Minus});
add({"DIFFERENCE", "AQL_DIFFERENCE", "l,l|+", true, true, false, add({"OUTERSECTION", "AQL_OUTERSECTION", "l,l|+", true, true, false,
true, true, &Functions::Difference}); true, true, &Functions::Outersection});
add({"INTERSECTION", "AQL_INTERSECTION", "l,l|+", true, true, false, add({"INTERSECTION", "AQL_INTERSECTION", "l,l|+", true, true, false,
true, true, &Functions::Intersection}); true, true, &Functions::Intersection});
add({"FLATTEN", "AQL_FLATTEN", "l|n", true, true, false, add({"FLATTEN", "AQL_FLATTEN", "l|n", true, true, false,

View File

@ -2111,11 +2111,11 @@ AqlValue Functions::Intersection(arangodb::aql::Query* query,
return AqlValue(builder.get()); return AqlValue(builder.get());
} }
/// @brief function DIFFERENCE /// @brief function OUTERSECTION
AqlValue Functions::Difference(arangodb::aql::Query* query, AqlValue Functions::Outersection(arangodb::aql::Query* query,
arangodb::AqlTransaction* trx, arangodb::AqlTransaction* trx,
VPackFunctionParameters const& parameters) { VPackFunctionParameters const& parameters) {
ValidateParameters(parameters, "DIFFERENCE", 2); ValidateParameters(parameters, "OUTERSECTION", 2);
VPackOptions options; VPackOptions options;
options.customTypeHandler = options.customTypeHandler =
@ -2135,7 +2135,7 @@ AqlValue Functions::Difference(arangodb::aql::Query* query,
if (!value.isArray()) { if (!value.isArray()) {
// not an array // 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()); return AqlValue(arangodb::basics::VelocyPackHelper::NullValue());
} }

View File

@ -148,7 +148,7 @@ struct Functions {
static AqlValue Intersection(arangodb::aql::Query*, static AqlValue Intersection(arangodb::aql::Query*,
arangodb::AqlTransaction*, arangodb::AqlTransaction*,
VPackFunctionParameters const&); VPackFunctionParameters const&);
static AqlValue Difference(arangodb::aql::Query*, static AqlValue Outersection(arangodb::aql::Query*,
arangodb::AqlTransaction*, arangodb::AqlTransaction*,
VPackFunctionParameters const&); VPackFunctionParameters const&);
static AqlValue Near(arangodb::aql::Query*, arangodb::AqlTransaction*, static AqlValue Near(arangodb::aql::Query*, arangodb::AqlTransaction*,

View File

@ -3724,7 +3724,7 @@ function AQL_INTERSECTION () {
/// in the arrays /// in the arrays
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function AQL_DIFFERENCE () { function AQL_OUTERSECTION () {
'use strict'; 'use strict';
var i, keys = { }; var i, keys = { };
@ -3744,7 +3744,7 @@ function AQL_DIFFERENCE () {
var element = arguments[i]; var element = arguments[i];
if (TYPEWEIGHT(element) !== TYPEWEIGHT_ARRAY) { 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; return null;
} }
@ -5700,7 +5700,7 @@ exports.AQL_UNSHIFT = AQL_UNSHIFT;
exports.AQL_SLICE = AQL_SLICE; exports.AQL_SLICE = AQL_SLICE;
exports.AQL_MINUS = AQL_MINUS; exports.AQL_MINUS = AQL_MINUS;
exports.AQL_INTERSECTION = AQL_INTERSECTION; exports.AQL_INTERSECTION = AQL_INTERSECTION;
exports.AQL_DIFFERENCE = AQL_DIFFERENCE; exports.AQL_OUTERSECTION = AQL_OUTERSECTION;
exports.AQL_FLATTEN = AQL_FLATTEN; exports.AQL_FLATTEN = AQL_FLATTEN;
exports.AQL_MAX = AQL_MAX; exports.AQL_MAX = AQL_MAX;
exports.AQL_MIN = AQL_MIN; exports.AQL_MIN = AQL_MIN;

View File

@ -2572,10 +2572,10 @@ function ahuacatlFunctionsTestSuite () {
}, },
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief test difference function /// @brief test outersection function
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
testDifference : function () { testOutersection : function () {
var queries = [ var queries = [
[ [ [ ], [ ], [ ], [ ] ], [ ] ], [ [ [ ], [ ], [ ], [ ] ], [ ] ],
[ [ [ 1 ], [ ] ], [ 1 ] ], [ [ [ 1 ], [ ] ], [ 1 ] ],
@ -2597,13 +2597,13 @@ function ahuacatlFunctionsTestSuite () {
var sorter = require("@arangodb/aql").RELATIONAL_CMP; var sorter = require("@arangodb/aql").RELATIONAL_CMP;
queries.forEach(function(query) { 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)); 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)); 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)); assertEqual(query[1].sort(sorter), actual[0].sort(sorter));
}); });
}, },