Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor fix #4609

Merged
merged 4 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/storage/exec/GetPropNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ class GetTagPropNode : public QueryNode<VertexID> {
return ret;
}
}
if (filter_ == nullptr || (QueryUtils::vTrue(filter_->eval(*expCtx_)))) {
if (filter_ == nullptr) {
resultDataSet_->rows.emplace_back(std::move(row));
} else {
auto result = QueryUtils::vTrue(filter_->eval(*expCtx_));
if (result.ok() && result.value()) {
resultDataSet_->rows.emplace_back(std::move(row));
}
}
if (expCtx_ != nullptr) {
expCtx_->clear();
Expand Down Expand Up @@ -172,8 +177,13 @@ class GetEdgePropNode : public QueryNode<cpp2::EdgeKey> {
return ret;
}
}
if (filter_ == nullptr || (QueryUtils::vTrue(filter_->eval(*expCtx_)))) {
if (filter_ == nullptr) {
resultDataSet_->rows.emplace_back(std::move(row));
} else {
auto result = QueryUtils::vTrue(filter_->eval(*expCtx_));
if (result.ok() && result.value()) {
resultDataSet_->rows.emplace_back(std::move(row));
}
}
if (expCtx_ != nullptr) {
expCtx_->clear();
Expand Down
12 changes: 10 additions & 2 deletions src/storage/exec/QueryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ namespace storage {

class QueryUtils final {
public:
static inline bool vTrue(const Value& v) {
return v.isBool() && v.getBool();
// The behavior keep same with filter executor
static inline StatusOr<bool> vTrue(const Value& val) {
if (val.isBadNull() || (!val.empty() && !val.isBool() && !val.isNull())) {
return Status::Error("Wrong type result, the type should be NULL, EMPTY or BOOL");
}
if (val.empty() || val.isNull() || !val.getBool()) {
return false;
} else {
return true;
}
}

enum class ReturnColType : uint16_t {
Expand Down
24 changes: 18 additions & 6 deletions src/storage/exec/ScanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,15 @@ class ScanVertexPropNode : public QueryNode<Cursor> {
break;
}
}
if (ret == nebula::cpp2::ErrorCode::SUCCEEDED &&
(filter_ == nullptr || QueryUtils::vTrue(filter_->eval(*expCtx_)))) {
resultDataSet_->rows.emplace_back(std::move(row));
if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) {
if (filter_ == nullptr) {
resultDataSet_->rows.emplace_back(std::move(row));
} else {
auto result = QueryUtils::vTrue(filter_->eval(*expCtx_));
if (result.ok() && result.value()) {
resultDataSet_->rows.emplace_back(std::move(row));
}
}
}
expCtx_->clear();
for (auto& tagNode : tagNodes_) {
Expand Down Expand Up @@ -323,9 +329,15 @@ class ScanEdgePropNode : public QueryNode<Cursor> {
break;
}
}
if (ret == nebula::cpp2::ErrorCode::SUCCEEDED &&
(filter_ == nullptr || QueryUtils::vTrue(filter_->eval(*expCtx_)))) {
resultDataSet_->rows.emplace_back(std::move(row));
if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) {
if (filter_ == nullptr) {
resultDataSet_->rows.emplace_back(std::move(row));
} else {
auto result = QueryUtils::vTrue(filter_->eval(*expCtx_));
if (result.ok() && result.value()) {
resultDataSet_->rows.emplace_back(std::move(row));
}
}
}
expCtx_->clear();
for (auto& edgeNode : edgeNodes_) {
Expand Down
5 changes: 5 additions & 0 deletions src/storage/query/GetNeighborsProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ void GetNeighborsProcessor::runInMultipleThread(const cpp2::GetNeighborsRequest&
folly::collectAll(futures).via(executor_).thenTry([this](auto&& t) mutable {
CHECK(!t.hasException());
const auto& tries = t.value();
size_t sum = 0;
for (size_t j = 0; j < tries.size(); j++) {
CHECK(!tries[j].hasException());
sum += results_[j].size();
}
resultDataSet_.rows.reserve(sum);
for (size_t j = 0; j < tries.size(); j++) {
const auto& [code, partId] = tries[j].value();
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
handleErrorCode(code, spaceId_, partId);
Expand Down
5 changes: 5 additions & 0 deletions src/storage/query/GetPropProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ void GetPropProcessor::runInMultipleThread(const cpp2::GetPropRequest& req) {
folly::collectAll(futures).via(executor_).thenTry([this](auto&& t) mutable {
CHECK(!t.hasException());
const auto& tries = t.value();
size_t sum = 0;
for (size_t j = 0; j < tries.size(); j++) {
CHECK(!tries[j].hasException());
sum += results_[j].size();
}
resultDataSet_.rows.reserve(sum);
for (size_t j = 0; j < tries.size(); j++) {
const auto& [code, partId] = tries[j].value();
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
handleErrorCode(code, spaceId_, partId);
Expand Down
5 changes: 5 additions & 0 deletions src/storage/query/ScanEdgeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ void ScanEdgeProcessor::runInMultipleThread(const cpp2::ScanEdgeRequest& req) {
folly::collectAll(futures).via(executor_).thenTry([this](auto&& t) mutable {
CHECK(!t.hasException());
const auto& tries = t.value();
size_t sum = 0;
for (size_t j = 0; j < tries.size(); j++) {
CHECK(!tries[j].hasException());
sum += results_[j].size();
}
resultDataSet_.rows.reserve(sum);
for (size_t j = 0; j < tries.size(); j++) {
const auto& [code, partId] = tries[j].value();
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
handleErrorCode(code, spaceId_, partId);
Expand Down
5 changes: 5 additions & 0 deletions src/storage/query/ScanVertexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ void ScanVertexProcessor::runInMultipleThread(const cpp2::ScanVertexRequest& req
folly::collectAll(futures).via(executor_).thenTry([this](auto&& t) mutable {
CHECK(!t.hasException());
const auto& tries = t.value();
size_t sum = 0;
for (size_t j = 0; j < tries.size(); j++) {
CHECK(!tries[j].hasException());
sum += results_[j].size();
}
resultDataSet_.rows.reserve(sum);
for (size_t j = 0; j < tries.size(); j++) {
const auto& [code, partId] = tries[j].value();
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
handleErrorCode(code, spaceId_, partId);
Expand Down