Skip to content

Commit

Permalink
Some minor fix (#4609)
Browse files Browse the repository at this point in the history
* reserve enough space when merge storage executor's result

* make filter logic same as ent version

* address @SuperYoko's comments

Co-authored-by: Sophie <[email protected]>
  • Loading branch information
critical27 and Sophie-Xie authored Sep 2, 2022
1 parent 7b9fc17 commit 3157fad
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
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 @@ -130,8 +130,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

0 comments on commit 3157fad

Please sign in to comment.