Skip to content

Commit

Permalink
1. fix indexWithTTLTest
Browse files Browse the repository at this point in the history
2. fix LookupIndexTest
3. remove buildPlanWithFilter
  • Loading branch information
cangfengzhs committed Sep 8, 2021
1 parent f7e60d3 commit 694e7eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
19 changes: 6 additions & 13 deletions src/storage/index/LookupBaseProcessor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,12 @@ StatusOr<StoragePlan<IndexID>> LookupBaseProcessor<REQ, RESP>::buildPlan(
needData = needFilter = true;
}
}

if (!needData && !needFilter) {
out = buildPlanBasic(result, ctx, plan, hasNullableCol, fields);
} else if (needData && !needFilter) {
out = buildPlanWithData(result, ctx, plan);
} else if (!needData && needFilter) {
auto expr = Expression::decode(pool, ctx.get_filter());
auto exprCtx = std::make_unique<StorageExpressionContext>(
context_->vIdLen(), context_->isIntId(), hasNullableCol, fields);
filterItem->emplace(filterId, std::make_pair(std::move(exprCtx), expr));
out = buildPlanWithFilter(
result, ctx, plan, (*filterItem)[filterId].first.get(), (*filterItem)[filterId].second);
filterId++;
if (!needFilter) {
if (needData) {
out = buildPlanWithData(result, ctx, plan);
} else {
out = buildPlanBasic(result, ctx, plan, hasNullableCol, fields);
}
} else {
auto expr = Expression::decode(pool, ctx.get_filter());
// Need to get columns in data, expr ctx need to be aware of schema
Expand Down
12 changes: 7 additions & 5 deletions src/storage/test/IndexWithTTLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,9 @@ TEST(IndexWithTTLTest, LookupEdgeIndexWithTTL) {
}
req.set_parts(std::move(parts));
std::vector<std::string> returnCols;
returnCols.emplace_back(kVid);
returnCols.emplace_back(kTag);
returnCols.emplace_back(kSrc);
returnCols.emplace_back(kRank);
returnCols.emplace_back(kDst);
req.set_return_columns(std::move(returnCols));
auto expr = RelationalExpression::makeNE(pool,
TagPropertyExpression::make(pool, "2021001", "c1"),
Expand Down Expand Up @@ -783,7 +784,7 @@ TEST(IndexWithTTLTest, LookupTagIndexWithTTLExpired) {
}
req.set_parts(std::move(parts));
std::vector<std::string> returnCols;
returnCols.emplace_back(kVid);
returnCols.emplace_back(kSrc);
returnCols.emplace_back(kTag);
req.set_return_columns(std::move(returnCols));
auto expr = RelationalExpression::makeNE(pool,
Expand Down Expand Up @@ -828,8 +829,9 @@ TEST(IndexWithTTLTest, LookupEdgeIndexWithTTLExpired) {
}
req.set_parts(std::move(parts));
std::vector<std::string> returnCols;
returnCols.emplace_back(kVid);
returnCols.emplace_back(kTag);
returnCols.emplace_back(kSrc);
returnCols.emplace_back(kRank);
returnCols.emplace_back(kDst);
req.set_return_columns(std::move(returnCols));
auto expr = RelationalExpression::makeNE(pool,
TagPropertyExpression::make(pool, "2021001", "c1"),
Expand Down
16 changes: 7 additions & 9 deletions src/storage/test/LookupIndexTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,9 @@ TEST_P(LookupIndexTest, TagIndexFilterTest) {
columnHints.emplace_back(std::move(columnHint));
cpp2::IndexQueryContext context1;
context1.set_column_hints(std::move(columnHints));
const auto& expr =
*RelationalExpression::makeEQ(pool,
TagPropertyExpression::make(pool, "player", "age"),
ConstantExpression::make(pool, Value(34L)));
const auto& expr = *RelationalExpression::makeEQ(pool,
TagPropertyExpression::make(pool, "1", "age"),
ConstantExpression::make(pool, Value(34L)));
context1.set_filter(expr.encode());
context1.set_index_id(1);
decltype(indices.contexts) contexts;
Expand Down Expand Up @@ -701,10 +700,9 @@ TEST_P(LookupIndexTest, TagIndexFilterTest) {
columnHints.emplace_back(std::move(columnHint));
cpp2::IndexQueryContext context1;
context1.set_column_hints(std::move(columnHints));
const auto& expr =
*RelationalExpression::makeGT(pool,
TagPropertyExpression::make(pool, "player", "age"),
ConstantExpression::make(pool, Value(34L)));
const auto& expr = *RelationalExpression::makeGT(pool,
TagPropertyExpression::make(pool, "1", "age"),
ConstantExpression::make(pool, Value(34L)));
context1.set_filter(expr.encode());
context1.set_index_id(1);
decltype(indices.contexts) contexts;
Expand Down Expand Up @@ -881,7 +879,7 @@ TEST_P(LookupIndexTest, EdgeIndexFilterTest) {
context1.set_column_hints(std::move(columnHints));
const auto& expr =
*RelationalExpression::makeNE(pool,
EdgePropertyExpression::make(pool, "Teammate", "teamName"),
EdgePropertyExpression::make(pool, "102", "teamName"),
ConstantExpression::make(pool, Value("Spurs")));
context1.set_filter(expr.encode());
context1.set_index_id(102);
Expand Down

0 comments on commit 694e7eb

Please sign in to comment.