@@ -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);
0 commit comments