Skip to content

Commit

Permalink
issue #1589
Browse files Browse the repository at this point in the history
  • Loading branch information
jsteemann committed Nov 25, 2015
1 parent 7538d71 commit 9b1ef91
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,6 +1,8 @@
v2.8.0 (XXXX-XX-XX)
-------------------

* fixed issue #1589

* return HTTP status code 410 (gone) instead of HTTP 408 (request timeout) for
server-side operations that are canceled / killed. Sending 410 instead of 408
prevents clients from re-starting the same (canceled) operation. Google Chrome
Expand Down
2 changes: 1 addition & 1 deletion arangod/Aql/AstNode.cpp
Expand Up @@ -377,7 +377,7 @@ int triagens::aql::CompareAstNodes (AstNode const* lhs,
// (this saves us from writing our own compare function
// for array AstNodes)
auto lJson = lhs->toJsonValue(TRI_UNKNOWN_MEM_ZONE);
auto rJson = lhs->toJsonValue(TRI_UNKNOWN_MEM_ZONE);
auto rJson = rhs->toJsonValue(TRI_UNKNOWN_MEM_ZONE);

int res = TRI_CompareValuesJson(lJson, rJson, compareUtf8);

Expand Down
2 changes: 1 addition & 1 deletion arangod/Aql/Expression.cpp
Expand Up @@ -325,7 +325,7 @@ bool Expression::findInArray (AqlValue const& left,

size_t const n = right.arraySize();

if (node->getMember(1)->isSorted()) {
if (n > 3 && node->getMember(1)->isSorted()) {
// node values are sorted. can use binary search
size_t l = 0;
size_t r = n - 1;
Expand Down
184 changes: 182 additions & 2 deletions js/server/tests/aql-queries-optimizer-in-noncluster.js
@@ -1,5 +1,5 @@
/*jshint globalstrict:false, strict:false, maxlen: 500 */
/*global assertEqual, assertTrue, AQL_EXPLAIN */
/*global assertEqual, assertTrue, AQL_EXPLAIN, AQL_EXECUTE */

////////////////////////////////////////////////////////////////////////////////
/// @brief tests for query language, in
Expand Down Expand Up @@ -1254,17 +1254,197 @@ function ahuacatlQueryOptimizerInTestSuite () {
ruleIsUsed(query);
}

};
}

////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////

function ahuacatlQueryOptimizerInWithLongArraysTestSuite () {
var c = null;
var cn = "UnitTestsAhuacatlOptimizerInWithLongArrays";

return {

////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////

setUp : function () {
internal.db._drop(cn);
c = internal.db._create(cn);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////

tearDown : function () {
internal.db._drop(cn);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with numbers
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithNumbersForward : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value: i });
comp.push(i);
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with numbers
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithNumbersBackward : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value: i });
comp.push(1000 - 1 - i);
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with strings
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithStringsForward : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value: "test" + i });
comp.push("test" + i);
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with strings
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithStringsBackward : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value: "test" + i });
comp.push("test" + (1000 - 1 - i));
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER doc.value NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with objects
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithObjectsForward1 : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value1: "test" + i, value2: i });
comp.push({ value1: "test" + i, value2: i });
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with objects
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithObjectsForward2 : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value1: "test" + i, value2: 1000 - 1 - i });
comp.push({ value1: "test" + i, value2: 1000 - 1 - i });
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with objects
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithObjectsBackward1 : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value1: "test" + (1000 - 1 - i), value2: 1000 - 1 - i });
comp.push({ value1: "test" + (1000 - 1 - i), value2: 1000 - 1 - i });
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief check long array with objects
////////////////////////////////////////////////////////////////////////////////

testInLongArrayWithObjectsBackward2 : function () {
var i, comp = [ ];
for (i = 0; i < 1000; ++i) {
c.insert({ value1: "test" + (1000 - 1 - i), value2: i });
comp.push({ value1: "test" + (1000 - 1 - i), value2: i });
}

var result;
result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(1000, result.length);

result = AQL_EXECUTE("FOR doc IN @@cn FILTER { value1: doc.value1, value2: doc.value2 } NOT IN @comp RETURN 1", { "@cn": cn, comp: comp }).json;
assertEqual(0, result.length);
}

};
}

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
/// @brief executes the test suites
////////////////////////////////////////////////////////////////////////////////

jsunity.run(ahuacatlQueryOptimizerInTestSuite);
jsunity.run(ahuacatlQueryOptimizerInWithLongArraysTestSuite);

return jsunity.done();

Expand Down

0 comments on commit 9b1ef91

Please sign in to comment.