Skip to content

Commit 7458486

Browse files
authored
push step limit down storage (#5883)
push step limit down storage "
1 parent bdefcc8 commit 7458486

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

src/graph/executor/query/ExpandAllExecutor.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ folly::Future<Status> ExpandAllExecutor::getNeighbors() {
142142
std::vector<Value> vids(nextStepVids_.size());
143143
std::move(nextStepVids_.begin(), nextStepVids_.end(), vids.begin());
144144
QueryExpressionContext qec(qctx()->ectx());
145+
auto stepLimit =
146+
stepLimits_.empty() ? std::numeric_limits<int64_t>::max() : stepLimits_[currentStep_ - 2];
147+
auto limit = std::min(stepLimit, expand_->limit(qec));
145148
return storageClient
146149
->getNeighbors(param,
147150
{nebula::kVid},
@@ -153,9 +156,9 @@ folly::Future<Status> ExpandAllExecutor::getNeighbors() {
153156
expand_->edgeProps(),
154157
nullptr,
155158
false,
156-
false,
159+
sample_,
157160
std::vector<storage::cpp2::OrderBy>(),
158-
expand_->limit(qec),
161+
limit,
159162
expand_->filter(),
160163
nullptr)
161164
.via(runner())
@@ -402,6 +405,12 @@ folly::Future<Status> ExpandAllExecutor::handleResponse(RpcResponse&& resps) {
402405
buildResult(curVertexProps, edgeProps);
403406
}
404407

408+
if (!stepLimits_.empty()) {
409+
// if stepLimits_ is not empty, do not use cache
410+
nextStepVids_.emplace(dst);
411+
continue;
412+
}
413+
405414
if (adjList_.find(dst) == adjList_.end()) {
406415
nextStepVids_.emplace(dst);
407416
} else {
@@ -413,7 +422,9 @@ folly::Future<Status> ExpandAllExecutor::handleResponse(RpcResponse&& resps) {
413422
adjList_.emplace(curVid, std::move(adjEdgeProps));
414423
}
415424

416-
resetNextStepVids(visitedVids);
425+
if (stepLimits_.empty()) {
426+
resetNextStepVids(visitedVids);
427+
}
417428

418429
if (!preVisitedVids_.empty()) {
419430
getNeighborsFromCache(dst2VidsMap, visitedVids, samples);

src/graph/executor/query/ExpandExecutor.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ folly::Future<Status> ExpandExecutor::getNeighbors() {
141141
qctx_->plan()->isProfileEnabled());
142142
std::vector<Value> vids(nextStepVids_.size());
143143
std::move(nextStepVids_.begin(), nextStepVids_.end(), vids.begin());
144+
auto stepLimit =
145+
stepLimits_.empty() ? std::numeric_limits<int64_t>::max() : stepLimits_[currentStep_ - 1];
144146
return storageClient
145147
->getNeighbors(param,
146148
{nebula::kVid},
@@ -152,9 +154,9 @@ folly::Future<Status> ExpandExecutor::getNeighbors() {
152154
expand_->edgeProps(),
153155
nullptr,
154156
false,
155-
false,
157+
sample_,
156158
std::vector<storage::cpp2::OrderBy>(),
157-
-1,
159+
stepLimit,
158160
nullptr,
159161
nullptr)
160162
.via(runner())
@@ -323,6 +325,11 @@ folly::Future<Status> ExpandExecutor::handleResponse(RpcResponse&& resps) {
323325
if (currentStep_ >= maxSteps_) {
324326
continue;
325327
}
328+
if (!stepLimits_.empty()) {
329+
// do not use cache when stepLimits_ is not empty
330+
nextStepVids_.emplace(dst);
331+
continue;
332+
}
326333
if (adjDsts_.find(dst) == adjDsts_.end()) {
327334
nextStepVids_.emplace(dst);
328335
} else {

src/graph/planner/plan/Query.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class ExpandAll : public Expand {
422422
} else if (edgeColumns_) {
423423
colNames = edgeColumns_->names();
424424
}
425-
setLimit(-1);
425+
setLimit(std::numeric_limits<int64_t>::max());
426426
setColNames(colNames);
427427
}
428428

tests/tck/features/go/SampleLimit.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,3 @@ Feature: Sample and limit
7272
| like._dst |
7373
| /[\s\w+]/ |
7474
| /[\s\w+]/ |
75-
| /[\s\w+]/ |

tests/tck/features/go/SampleLimit.intVid.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,3 @@ Feature: Sample and limit
6262
| like._dst |
6363
| /[\d\-+]/ |
6464
| /[\d\-+]/ |
65-
| /[\d\-+]/ |

tests/tck/features/optimizer/PushSampleDownRule.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Feature: Push Limit down rule
2828
Then the result should be, in any order:
2929
| like._dst |
3030
| /[\w\s]+/ |
31-
| /[\w\s]+/ |
3231
And the execution plan should be:
3332
| id | name | dependencies | operator info |
3433
| 4 | Project | 3 | |
@@ -42,7 +41,6 @@ Feature: Push Limit down rule
4241
Then the result should be, in any order:
4342
| src | likeness | dst |
4443
| /[\w\s]+/ | /\d\d/ | /[\w\s]+/ |
45-
| /[\w\s]+/ | /\d\d/ | /[\w\s]+/ |
4644
And the execution plan should be:
4745
| id | name | dependencies | profiling data | operator info |
4846
| 8 | Project | 7 | | |

0 commit comments

Comments
 (0)