8000 fix failing query by jsteemann · Pull Request #11317 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

fix failing query #11317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix failing query
  • Loading branch information
jsteemann committed Mar 20, 2020
8000 commit 7d702009bcffebb5458f75f7ef0a2f3a572c752a
4 changes: 3 additions & 1 deletion arangod/Aql/MultiAqlItemBlockInputRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ auto MultiAqlItemBlockInputRange::skipAllRemainingDataRows() -> size_t {
// Subtract up to count rows from the local _skipped state
auto MultiAqlItemBlockInputRange::skipForDependency(size_t const dependency,
size_t count) -> size_t {
TRI_ASSERT(dependency < _inputs.size());
return _inputs.at(dependency).skip(count);
}

// Skipp all that is available
// Skip all that is available
auto MultiAqlItemBlockInputRange::skipAllForDependency(size_t const dependency) -> size_t {
TRI_ASSERT(dependency < _inputs.size());
return _inputs.at(dependency).skipAll();
}

Expand Down
8000 19 changes: 11 additions & 8 deletions arangod/Aql/UnsortedGatherExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ auto UnsortedGatherExecutor::skipRowsRange(typename Fetcher::DataRange& input, A
-> std::tuple<ExecutorState, Stats, size_t, AqlCallSet> {
auto skipped = size_t{0};

if (done()) {
return {ExecutorState::DONE, Stats{}, skipped, AqlCallSet{}};
}

if (call.getOffset() > 0) {
skipped = input.skipForDependency(currentDependency(), call.getOffset());
} else {
Expand All @@ -108,15 +112,14 @@ auto UnsortedGatherExecutor::skipRowsRange(typename Fetcher::DataRange& input, A
// Here we are either done, or currentDependency() still could produce more
if (done()) {
return {ExecutorState::DONE, Stats{}, skipped, AqlCallSet{}};
} else {
// If we're not done skipping, we can just request the current clientcall
// from upstream
auto callSet = AqlCallSet{};
if (call.needSkipMore()) {
callSet.calls.emplace_back(AqlCallSet::DepCallPair{currentDependency(), call});
}
return {ExecutorState::HASMORE, Stats{}, skipped, callSet};
}
// If we're not done skipping, we can just request the current clientcall
// from upstream
auto callSet = AqlCallSet{};
if (call.needSkipMore()) {
callSet.calls.emplace_back(AqlCallSet::DepCallPair{currentDependency(), call});
}
return {ExecutorState::HASMORE, Stats{}, skipped, callSet};
}

auto UnsortedGatherExecutor::numDependencies() const
Expand Down
43 changes: 33 additions & 10 deletions tests/js/server/aql/aql-fullcount.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var jsunity = require("jsunity");
var db = require("@arangodb").db;

////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////
const jsunity = require("jsunity");
const db = require("@arangodb").db;

function optimizerFullcountTestSuite () {
var c;
let c;

return {
setUpAll : function () {
Expand Down Expand Up @@ -254,11 +250,38 @@ function optimizerFullcountTestSuite () {
};
}

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////
function optimizerFullcountQueryTestSuite () {
let c;

return {
setUp : function () {
db._drop("UnitTestsCollection");
c = db._create("UnitTestsCollection");
c.ensureIndex({ type: "geo", fields: ["location"] });
c.insert([
{ location: [2, 0] },
{ location: [3, 0] },
{ location: [4, 0] },
{ location: [6, 0] }
]);
},

tearDown : function () {
db._drop("UnitTestsCollection");
},

testQueryRegression : function () {
let result = db._query({ query: "FOR e IN " + c.name() + " SORT DISTANCE(e.location[0], e.location[1], 0, 0) LIMIT 2, 2 RETURN e", options: { fullCount: true }}).toArray();
assertEqual(2, result.length);
assertEqual([4, 0], result[0].location);
assertEqual([6, 0], result[1].location);
},

};
}

jsunity.run(optimizerFullcountTestSuite);
jsunity.run(optimizerFullcountQueryTestSuite);

return jsunity.done();

0