8000 APM-786 heap sort with stored values by Dronplane · Pull Request #19551 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

APM-786 heap sort with stored values #19551

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 33 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
07b591f
wip
Dronplane Apr 25, 2023
899331c
wip
Dronplane Apr 26, 2023
a03e71e
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Jul 18, 2023
a1ea685
wip
Dronplane Jul 18, 2023
b1ba920
wip
Dronplane Aug 1, 2023
8e392ce
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 1, 2023
4584827
wip
Dronplane Aug 1, 2023
13d90f3
wip
Dronplane Aug 1, 2023
f62a7d5
wip
Dronplane Aug 3, 2023
dc44497
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 3, 2023
48442bc
wip
Dronplane Aug 7, 2023
c2a0b23
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 7, 2023
6995111
wip
Dronplane Aug 8, 2023
3227d21
wip
Dronplane Aug 8, 2023
de064a2
wip
Dronplane Aug 9, 2023
022d9da
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 9, 2023
9599662
wip
Dronplane Aug 9, 2023
8f8acff
fixex for postfix case
Dronplane Aug 9, 2023
e53f502
cleanup
Dronplane Aug 9, 2023
e7589a9
fix build
Dronplane Aug 10, 2023
7227454
fix
Dronplane Aug 10, 2023
0b91f37
fix typename
Dronplane Aug 10, 2023
0cdf93b
clang-format
Dronplane Aug 10, 2023
a47eb93
add explicit inits
Dronplane Aug 10, 2023
b56a4ec
fix
Dronplane Aug 10, 2023
e4fc95a
review comments
Dronplane Aug 10, 2023
34b8946
get rid of values mapping
Dronplane Aug 11, 2023
3504ef2
remove redundant inits
Dronplane Aug 11, 2023
9b8f84f
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 11, 2023
9db2616
fix empty field case
Dronplane Aug 11, 2023
ec8b7b1
fix tests
Dronplane Aug 11, 2023
40dbd9e
Merge remote-tracking branch 'origin/devel' into feature/APM-786-heap…
Dronplane Aug 11, 2023
b1c9e09
fix asan build + fix slice iteration
Dronplane Aug 11, 2023
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
Dronplane committed Aug 8, 2023
commit 3227d21d9a2ab543c0bcee6d281c194ca0b2443a
12 changes: 7 additions & 5 deletions arangod/Aql/IResearchViewExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ class IndexReadBuffer {
auto res =
maxSize * sizeof(typename decltype(_keyBuffer)::value_type) +
scores * maxSize * sizeof(typename decltype(_scoreBuffer)::value_type) +
maxSize * sizeof(typename decltype(_searchDocs)::value_type) +
stored * maxSize *
sizeof(typename decltype(_storedValuesBuffer)::value_type);
maxSize * sizeof(typename decltype(_searchDocs)::value_type);
if (!_heapSort.empty()) {
res += stored * maxSize *
sizeof(typename decltype(_storedValuesBuffer)::value_type);
res += maxSize * sizeof(typename decltype(_rows)::value_type);
res += _heapOnlyColumnsCount * maxSize *
sizeof(typename decltype(_heapOnlyStoredValuesBuffer)::value_type);
Expand All @@ -372,11 +372,13 @@ class IndexReadBuffer {
_keyBuffer.reserve(atMost);
_searchDocs.reserve(atMost);
_scoreBuffer.reserve(atMost * scores);
_storedValuesBuffer.resize(atMost * stored);
if (!_heapSort.empty()) {
_rows.reserve(atMost);
_heapOnlyStoredValuesBuffer.resize(_heapOnlyColumnsCount * atMost);
_currentDocumentBuffer.reserve(_heapOnlyColumnsCount);
// resize is important here as we want
// indexed access for setting values
_storedValuesBuffer.resize(atMost * stored);
_heapOnlyStoredValuesBuffer.resize(_heapOnlyColumnsCount * atMost);
}
}
_maxSize = atMost;
Expand Down
4 changes: 4 additions & 0 deletions arangod/Aql/IResearchViewNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct HeapSortElement {
return fieldNumber == std::numeric_limits<size_t>::max();
}

#ifdef ARANGODB_USE_GOOGLE_TESTS
auto operator<=>(HeapSortElement const&) const noexcept = default;
#endif

std::string postfix;
ptrdiff_t source{0};
size_t fieldNumber{std::numeric_limits<size_t>::max()};
Expand Down
9 changes: 3 additions & 6 deletions tests/IResearch/IResearchViewCountApproximateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ static char const* collectionName1 = "collection_1";
static char const* collectionName2 = "collection_2";
static char const* viewName = "view";

static std::vector<arangodb::iresearch::SearchFunc> emptyScorers;
static std::vector<arangodb::iresearch::HeapSortElement> emptyScorersSort;

static constexpr frozen::map<std::string_view,
arangodb::iresearch::CountApproximate, 2>
countApproximationTypeMap = {
Expand Down Expand Up @@ -547,8 +550,6 @@ TEST_F(IResearchViewCountApproximateTest, directSkipAllForMergeExecutorExact) {
arangodb::iresearch::ViewSnapshotPtr{}, snapshot};
arangodb::iresearch::IResearchViewSort sort;
sort.emplace_back({{std::string_view("value"), false}}, true);
std::vector<arangodb::iresearch::SearchFunc> emptyScorers;
std::vector<std::pair<size_t, bool>> emptyScorersSort;
arangodb::aql::IResearchViewExecutorInfos executorInfos(
reader, arangodb::aql::RegisterId::makeInvalid(),
arangodb::aql::RegisterId::makeInvalid(), {}, *query,
Expand Down Expand Up @@ -630,8 +631,6 @@ TEST_F(IResearchViewCountApproximateTest,
arangodb::iresearch::ViewSnapshotPtr{}, snapshot};
arangodb::iresearch::IResearchViewSort sort;
sort.emplace_back({{std::string_view("value"), false}}, true);
std::vector<arangodb::iresearch::SearchFunc> emptyScorers;
std::vector<std::pair<size_t, bool>> emptyScorersSort;
arangodb::aql::IResearchViewExecutorInfos executorInfos(
reader, arangodb::aql::RegisterId::makeInvalid(),
arangodb::aql::RegisterId::makeInvalid(), {}, *query,
Expand Down Expand Up @@ -715,8 +714,6 @@ TEST_F(IResearchViewCountApproximateTest, directSkipAllForMergeExecutorCost) {
arangodb::iresearch::ViewSnapshotPtr{}, snapshot};
arangodb::iresearch::IResearchViewSort sort;
sort.emplace_back({{std::string_view("value"), false}}, true);
std::vector<arangodb::iresearch::SearchFunc> emptyScorers;
std::vector<std::pair<size_t, bool>> emptyScorersSort;
arangodb::aql::IResearchViewExecutorInfos executorInfos(
reader, arangodb::aql::RegisterId::makeInvalid(),
arangodb::aql::RegisterId::makeInvalid(), {}, *query,
Expand Down
20 changes: 12 additions & 8 deletions tests/IResearch/IResearchViewNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,14 @@ TEST_F(IResearchViewNodeTest, construct) {
EXPECT_EQ(0, node.getScorersSortLimit());
EXPECT_TRUE(node.getScorersSort().empty());

std::vector<std::pair<size_t, bool>> scorersSort{
{1, true}, {2, false}, {4, true}};
std::vector<arangodb::iresearch::HeapSortElement> scorersSort{
{"", 1, std::numeric_limits<size_t>::max(), true},
{"foo", 2, 1, false},
{"", -1, 0, true}};
auto expectedScorersSort = scorersSort;
< 8000 span class='blob-code-inner blob-code-marker ' data-code-marker=" "> node.setScorersSort(std::move(scorersSort), 42);
EXPECT_EQ(42, node.getScorersSortLimit());
auto actualScorersSort = node.getScorersSort();
EXPECT_EQ(expectedScorersSort.size(), actualScorersSort.size());
EXPECT_TRUE(std::equal(expectedScorersSort.begin(),
expectedScorersSort.end(), actualScorersSort.begin(),
actualScorersSort.end()));
Expand Down Expand Up @@ -1282,10 +1283,12 @@ TEST_F(IResearchViewNodeTest, constructFromVPackSingleServer) {
EXPECT_EQ(42, node.getScorersSortLimit());
auto actualScorersSort = node.getScorersSort();
EXPECT_EQ(2, actualScorersSort.size());
EXPECT_EQ(0, actualScorersSort[0].first);
EXPECT_TRUE(actualScorersSort[0].second);
EXPECT_EQ(1, actualScorersSort[1].first);
EXPECT_FALSE(actualScorersSort[1].second);
EXPECT_EQ(0, actualScorersSort[0].source);
EXPECT_TRUE(actualScorersSort[0].ascending);
EXPECT_TRUE(actualScorersSort[0].isScore());
EXPECT_EQ(1, actualScorersSort[1].source);
EXPECT_FALSE(actualScorersSort[1].ascending);
EXPECT_TRUE(actualScorersSort[1].isScore());
}

// no options with invalid index scorersSort
Expand Down Expand Up @@ -2441,7 +2444,8 @@ TEST_F(IResearchViewNodeTest, clone) {
resourceMonitor);
arangodb::aql::Variable const outNmDocId("variable101", 101, false,
resourceMonitor);
std::vector<std::pair<size_t, bool>> scorersSort{{0, true}};
std::vector<arangodb::iresearch::HeapSortElement> scorersSort{
{"", 0, 0, true}};
node.setScorersSort(std::move(scorersSort), 42);
auto varsSetOriginal = node.getVariablesSetHere();
// clone without properties into the same plan
Expand Down
0