Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
czpmango committed Dec 2, 2021
1 parent b66a873 commit b580610
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownEdgeIndexFullScanRule::transform
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const EdgeIndexFullScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownEdgeIndexPrefixScanRule::transfo
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const EdgeIndexPrefixScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownEdgeIndexRangeScanRule::transfor
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const EdgeIndexRangeScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
2 changes: 1 addition & 1 deletion src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownGetNeighborsRule::transform(
if (!graph::ExpressionUtils::isEvaluableExpr(limit->countExpr(), octx->qctx())) {
return TransformResult::noTransform();
}
int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (gn->limit(qctx) >= 0 && limitRows >= gn->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
2 changes: 1 addition & 1 deletion src/graph/optimizer/rule/PushLimitDownIndexScanRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownIndexScanRule::transform(
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const IndexScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownTagIndexFullScanRule::transform(
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const TagIndexFullScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownTagIndexPrefixScanRule::transfor
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const TagIndexPrefixScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ StatusOr<OptRule::TransformResult> PushLimitDownTagIndexRangeScanRule::transform
const auto limit = static_cast<const Limit *>(limitGroupNode->node());
const auto indexScan = static_cast<const TagIndexRangeScan *>(indexScanGroupNode->node());

int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
if (indexScan->limit(qctx) >= 0 && limitRows >= indexScan->limit(qctx)) {
return TransformResult::noTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ StatusOr<OptRule::TransformResult> PushStepLimitDownGetNeighborsRule::transform(
if (gn->limitExpr() != nullptr &&
graph::ExpressionUtils::isEvaluableExpr(gn->limitExpr(), qctx) &&
graph::ExpressionUtils::isEvaluableExpr(limit->countExpr(), qctx)) {
int64_t limitRows = limit->offset() + limit->count();
int64_t limitRows = limit->offset() + limit->count(qctx);
int64_t gnLimit = gn->limit(qctx);
if (gnLimit >= 0 && limitRows >= gnLimit) {
return TransformResult::noTransform();
Expand Down
2 changes: 1 addition & 1 deletion src/graph/optimizer/rule/TopNRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ StatusOr<OptRule::TransformResult> TopNRule::transform(OptContext *ctx,
}

auto qctx = ctx->qctx();
auto topn = TopN::make(qctx, nullptr, sort->factors(), limit->offset(), limit->count());
auto topn = TopN::make(qctx, nullptr, sort->factors(), limit->offset(), limit->count(qctx));
topn->setOutputVar(limit->outputVar());
topn->setInputVar(sort->inputVar());
topn->setColNames(sort->colNames());
Expand Down
7 changes: 3 additions & 4 deletions src/graph/planner/plan/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,12 @@ class Limit final : public SingleInputNode {
int64_t offset() const { return offset_; }

// Get constant count value
int64_t count() const {
int64_t count(QueryContext* qctx) const {
if (count_ == nullptr) {
return -1;
}
DCHECK(ExpressionUtils::isEvaluableExpr(count_));
QueryExpressionContext ctx;
auto s = count_->eval(ctx).getInt();
DCHECK(ExpressionUtils::isEvaluableExpr(count_, qctx));
auto s = count_->eval(QueryExpressionContext(qctx->ectx())()).getInt();
DCHECK_GE(s, 0);
return s;
}
Expand Down

0 comments on commit b580610

Please sign in to comment.