-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
lookup support push down topK #2992
lookup support push down topK #2992
Conversation
Add test cases. |
950dff9
to
afa18ac
Compare
src/storage/exec/TopKNode.h
Outdated
@@ -0,0 +1,125 @@ | |||
/* Copyright (c) 2020 vesoft inc. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/storage/exec/TopKNode.h
Outdated
void adjustDown(size_t parent) { | ||
size_t child = parent * 2 + 1; | ||
size_t size = v_.size(); | ||
while (child < size) { | ||
if (child + 1 < size && comparator_(v_[child], v_[child + 1])) { | ||
child += 1; | ||
} | ||
if (!comparator_(v_[parent], v_[child])) { | ||
return; | ||
} | ||
std::swap(v_[parent], v_[child]); | ||
parent = child; | ||
child = parent * 2 + 1; | ||
} | ||
} | ||
void adjustUp(size_t child) { | ||
size_t parent = (child - 1) >> 1; | ||
while (0 != child) { | ||
if (!comparator_(v_[parent], v_[child])) { | ||
return; | ||
} | ||
std::swap(v_[parent], v_[child]); | ||
child = parent; | ||
parent = (child - 1) >> 1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this function means?
Is it any different from std::sort & std:: erase ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it needs to sort all data by std::sort
, and this function gets topK better than std::sort
Good job. thanks for your contribution. |
And it is compatible with Order-by |
Firstly, I agree to that topK node also should be used for other queries, not just for lookup. And it can be implement by next pr. Secondly, I don't think it make sense to split topK up into OrderNode and TopNode. TopK Node is designed to solve |
src/storage/exec/TopKNode.h
Outdated
namespace storage { | ||
|
||
template <class T> | ||
class TopKHeap final { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could reuse the TokKHeap in graph layer, or merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, TopKHeap
has been reused in IndexScanExecutor
393e20e
to
a76065c
Compare
a test case has been added. |
Please check the failed case. |
Please check the conflicts. |
45c48d8
to
115434d
Compare
| 5 | DataCollect | 9 | | | ||
| 9 | Project | 10 | | | ||
| 10 | TopN | 11 | | | ||
| 11 | TagIndexFullScan | 0 | {"orderBy": {"pos": "0"}} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should check orderBy
and limit
fields of TagIndexFullScan`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check orderBy
and limit
together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 45, there is limit
check.
On line 27(here), there is orderBy
check.
So, You can try to merge them together, thus , you can check orderBy and limit together.
af549ec
to
27bdb7b
Compare
27bdb7b
to
5bee437
Compare
Codecov Report
@@ Coverage Diff @@
## master #2992 +/- ##
==========================================
+ Coverage 85.21% 85.31% +0.09%
==========================================
Files 1295 1294 -1
Lines 118198 118308 +110
==========================================
+ Hits 100728 100930 +202
+ Misses 17470 17378 -92
Continue to review full report at Codecov.
|
@@ -47,26 +47,6 @@ Feature: TopN rule | |||
| 4 | Start | | | | |||
|
|||
Scenario: [1] fail to apply topn rule | |||
When profiling query: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I known, this pr just push topn to IndexScan, but the go statement implemented by GetNeighbors executor.
@@ -1639,21 +1639,21 @@ Feature: IntegerVid Go Sentence | |||
When executing query: | |||
""" | |||
$a = GO FROM hash('Tony Parker') OVER like YIELD like._src as src, like._dst as dst; | |||
GO 2 STEPS FROM $a.src OVER like YIELD $a.src as src, $a.dst, like._src AS like_src, like._dst AS like_dst | |||
| ORDER BY $-.src,$-.like_src,$-.like_dst | OFFSET 1 LIMIT 2 | |||
GO 2 STEPS FROM $a.src OVER like YIELD $a.src as src, $a.dst as dst, like._src AS like_src, like._dst AS like_dst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why change tests of GO statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, this results in a change in the sorting results of two equal values.
eg:
The value list is 2、1、3、2'
and the previous sorting result may be 1、2、2'、3
, in other words, there's no change in the relative order of 2 and 2'. But now, it may be 1、2'、2、3
, although the result has no effect on the user, but test case will be failed. So I change this.
| 0 | Start | | | | ||
When profiling query: | ||
""" | ||
LOOKUP ON player | ORDER BY $-.VertexID | Limit 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the comments above, there is no need to test limit and orderBy check
separately
Hello @MMyheart : |
new PR #3499 |
No description provided.