1
0
Fork 0

Added some test cases where filter optimization in Traverser could have yield wrong results.

This commit is contained in:
mchacki 2017-07-15 17:49:00 +02:00
parent df7051f2cb
commit dd13944264
1 changed files with 85 additions and 1 deletions

View File

@ -1629,6 +1629,57 @@ function complexInternaSuite () {
// test will segfault
},
testEdgeOptimizeAboveMinDepth: function () {
// The query should return depth 1
// Because edges[1] == null => null != edge.BC => ok
// And not depth 2/3 because edges[1]._id == edge.BC => not okay
let query = `
WITH ${vn}
FOR v, e, p IN 1..3 OUTBOUND '${vn}/A' ${en}
FILTER p.edges[1]._id != '${edge.BC}'
RETURN v._id`;
let res = db._query(query);
assertEqual(res.count(), 1);
assertEqual(res.toArray(), [vertex.B]);
},
testVertexOptimizeAboveMinDepth: function () {
// The query should return depth 1
// Because vertices[2] == null => null != vertex.C => ok
// And not depth 2/3 because vertices[3]._id == vertex.C => not okay
let query = `
WITH ${vn}
FOR v, e, p IN 1..3 OUTBOUND '${vn}/A' ${en}
FILTER p.vertices[2]._id != '${vertex.C}'
RETURN v._id`;
let res = db._query(query);
assertEqual(res.count(), 1);
assertEqual(res.toArray(), [vertex.B]);
},
testPathOptimizeAboveMinDepth: function () {
// The query should return depth 1
// Because vertices[2] == null => null != vertex.C => ok
// And not depth 2/3 because vertices[3]._id == vertex.C => not okay
let query = `
WITH ${vn}
FOR v, e, p IN 1..3 OUTBOUND '${vn}/A' ${en}
FILTER p.edges[1]._id != '${edge.BC}'
FILTER p.vertices[2]._id != '${vertex.C}'
RETURN v._id`;
let res = db._query(query);
assertEqual(res.count(), 1);
assertEqual(res.toArray(), [vertex.B]);
},
};
}
@ -3631,6 +3682,36 @@ function optimizeNonVertexCentricIndexesSuite () {
};
};
function exampleGraphsSuite () {
let ex = require('@arangodb/graph-examples/example-graph');
return {
setUpAll: () => {
ex.dropGraph('traversalGraph');
ex.loadGraph('traversalGraph');
},
tearDownAll: () => {
ex.dropGraph('traversalGraph');
},
testMinDepthFilter: () => {
let q = `FOR v,e,p IN 1..3 OUTBOUND 'circles/A' GRAPH 'traversalGraph'
FILTER p.vertices[1]._key != 'G'
FILTER p.edges[1].label != 'left_blub'
RETURN v._key`;
let res = db._query(q);
assertEqual(res.count(), 3);
let resArr = res.toArray().sort();
assertEqual(resArr, ['B', 'C', 'D'].sort());
}
};
};
/*
jsunity.run(limitSuite);
jsunity.run(nestedSuite);
jsunity.run(namedGraphSuite);
@ -3645,8 +3726,11 @@ jsunity.run(multiEdgeDirectionSuite);
jsunity.run(subQuerySuite);
jsunity.run(optionsSuite);
jsunity.run(optimizeQuantifierSuite);
*/
jsunity.run(exampleGraphsSuite);
/*
if (!isCluster) {
jsunity.run(optimizeNonVertexCentricIndexesSuite);
}
*/
return jsunity.done();