Skip to content

Commit

Permalink
Fixed filter error for index scan (vesoft-inc#2376)
Browse files Browse the repository at this point in the history
* fixed filter error for index scan

* addressed critical27's comment
  • Loading branch information
bright-starry-sky authored Oct 24, 2020
1 parent 81c5182 commit 5593705
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
36 changes: 36 additions & 0 deletions src/graph/test/LookupTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,5 +1123,41 @@ TEST_F(LookupTest, StringFieldTest) {
ASSERT_TRUE(verifyResult(resp, expected));
}
}

TEST_F(LookupTest, ConditionTest) {
{
cpp2::ExecutionResponse resp;
auto stmt = "create tag identity (BIRTHDAY int, NATION string, BIRTHPLACE_CITY string)";
auto code = client_->execute(stmt, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
{
cpp2::ExecutionResponse resp;
auto stmt = "CREATE TAG INDEX idx_identity_cname_birth_gender_nation_city "
"ON identity(BIRTHDAY, NATION, BIRTHPLACE_CITY)";
auto code = client_->execute(stmt, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
sleep(FLAGS_heartbeat_interval_secs + 1);
{
cpp2::ExecutionResponse resp;
auto stmt = "INSERT VERTEX identity "
"(BIRTHDAY, NATION, BIRTHPLACE_CITY)"
"VALUES 1 : (19860413, \"汉族\", \"aaa\")";
auto code = client_->execute(stmt, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
{
cpp2::ExecutionResponse resp;
auto query = "lookup on identity where "
"identity.NATION == \"汉族\" && "
"identity.BIRTHDAY > 19620101 && "
"identity.BIRTHDAY < 20021231 && "
"identity.BIRTHPLACE_CITY == \"bbb\"";
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
ASSERT_TRUE(!resp.__isset.rows || resp.get_rows()->size() == 0);
}
}
} // namespace graph
} // namespace nebula
8 changes: 6 additions & 2 deletions src/storage/index/IndexPolicyMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ bool IndexPolicyMaker::buildPolicy() {
* Field c2 is missing from the operatorList_,
* So we just need using c1 to range scan and filter c3.
*/
auto exist = scanItems_.find(col.get_name());
if (exist == scanItems_.end()) {
auto it = scanItems_.find(col.get_name());
if (it == scanItems_.end()) {
break;
} else if (it->second.beginBound_.rel_ != RelationType::kEQRel){
// Stop build policy when last operator is range scan,
// And other fields will use expression filtering.
break;
}
}
Expand Down

0 comments on commit 5593705

Please sign in to comment.