Commit 3157fad 1 parent 7b9fc17 commit 3157fad Copy full SHA for 3157fad
File tree 7 files changed +60
-10
lines changed
7 files changed +60
-10
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,13 @@ class GetTagPropNode : public QueryNode<VertexID> {
94
94
return ret;
95
95
}
96
96
}
97
- if (filter_ == nullptr || ( QueryUtils::vTrue (filter_-> eval (*expCtx_))) ) {
97
+ if (filter_ == nullptr ) {
98
98
resultDataSet_->rows .emplace_back (std::move (row));
99
+ } else {
100
+ auto result = QueryUtils::vTrue (filter_->eval (*expCtx_));
101
+ if (result.ok () && result.value ()) {
102
+ resultDataSet_->rows .emplace_back (std::move (row));
103
+ }
99
104
}
100
105
if (expCtx_ != nullptr ) {
101
106
expCtx_->clear ();
@@ -172,8 +177,13 @@ class GetEdgePropNode : public QueryNode<cpp2::EdgeKey> {
172
177
return ret;
173
178
}
174
179
}
175
- if (filter_ == nullptr || ( QueryUtils::vTrue (filter_-> eval (*expCtx_))) ) {
180
+ if (filter_ == nullptr ) {
176
181
resultDataSet_->rows .emplace_back (std::move (row));
182
+ } else {
183
+ auto result = QueryUtils::vTrue (filter_->eval (*expCtx_));
184
+ if (result.ok () && result.value ()) {
185
+ resultDataSet_->rows .emplace_back (std::move (row));
186
+ }
177
187
}
178
188
if (expCtx_ != nullptr ) {
179
189
expCtx_->clear ();
Original file line number Diff line number Diff line change @@ -18,8 +18,16 @@ namespace storage {
18
18
19
19
class QueryUtils final {
20
20
public:
21
- static inline bool vTrue (const Value& v) {
22
- return v.isBool () && v.getBool ();
21
+ // The behavior keep same with filter executor
22
+ static inline StatusOr<bool > vTrue (const Value& val) {
23
+ if (val.isBadNull () || (!val.empty () && !val.isBool () && !val.isNull ())) {
24
+ return Status::Error (" Wrong type result, the type should be NULL, EMPTY or BOOL" );
25
+ }
26
+ if (val.empty () || val.isNull () || !val.getBool ()) {
27
+ return false ;
28
+ } else {
29
+ return true ;
30
+ }
23
31
}
24
32
25
33
enum class ReturnColType : uint16_t {
Original file line number Diff line number Diff line change @@ -171,9 +171,15 @@ class ScanVertexPropNode : public QueryNode<Cursor> {
171
171
break ;
172
172
}
173
173
}
174
- if (ret == nebula::cpp2::ErrorCode::SUCCEEDED &&
175
- (filter_ == nullptr || QueryUtils::vTrue (filter_->eval (*expCtx_)))) {
176
- resultDataSet_->rows .emplace_back (std::move (row));
174
+ if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) {
175
+ if (filter_ == nullptr ) {
176
+ resultDataSet_->rows .emplace_back (std::move (row));
177
+ } else {
178
+ auto result = QueryUtils::vTrue (filter_->eval (*expCtx_));
179
+ if (result.ok () && result.value ()) {
180
+ resultDataSet_->rows .emplace_back (std::move (row));
181
+ }
182
+ }
177
183
}
178
184
expCtx_->clear ();
179
185
for (auto & tagNode : tagNodes_) {
@@ -323,9 +329,15 @@ class ScanEdgePropNode : public QueryNode<Cursor> {
323
329
break ;
324
330
}
325
331
}
326
- if (ret == nebula::cpp2::ErrorCode::SUCCEEDED &&
327
- (filter_ == nullptr || QueryUtils::vTrue (filter_->eval (*expCtx_)))) {
328
- resultDataSet_->rows .emplace_back (std::move (row));
332
+ if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) {
333
+ if (filter_ == nullptr ) {
334
+ resultDataSet_->rows .emplace_back (std::move (row));
335
+ } else {
336
+ auto result = QueryUtils::vTrue (filter_->eval (*expCtx_));
337
+ if (result.ok () && result.value ()) {
338
+ resultDataSet_->rows .emplace_back (std::move (row));
339
+ }
340
+ }
329
341
}
330
342
expCtx_->clear ();
331
343
for (auto & edgeNode : edgeNodes_) {
Original file line number Diff line number Diff line change @@ -130,8 +130,13 @@ void GetNeighborsProcessor::runInMultipleThread(const cpp2::GetNeighborsRequest&
130
130
folly::collectAll (futures).via (executor_).thenTry ([this ](auto && t) mutable {
131
131
CHECK (!t.hasException ());
132
132
const auto & tries = t.value ();
133
+ size_t sum = 0 ;
133
134
for (size_t j = 0 ; j < tries.size (); j++) {
134
135
CHECK (!tries[j].hasException ());
136
+ sum += results_[j].size ();
137
+ }
138
+ resultDataSet_.rows .reserve (sum);
139
+ for (size_t j = 0 ; j < tries.size (); j++) {
135
140
const auto & [code, partId] = tries[j].value ();
136
141
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
137
142
handleErrorCode (code, spaceId_, partId);
Original file line number Diff line number Diff line change @@ -129,8 +129,13 @@ void GetPropProcessor::runInMultipleThread(const cpp2::GetPropRequest& req) {
129
129
folly::collectAll (futures).via (executor_).thenTry ([this ](auto && t) mutable {
130
130
CHECK (!t.hasException ());
131
131
const auto & tries = t.value ();
132
+ size_t sum = 0 ;
132
133
for (size_t j = 0 ; j < tries.size (); j++) {
133
134
CHECK (!tries[j].hasException ());
135
+ sum += results_[j].size ();
136
+ }
137
+ resultDataSet_.rows .reserve (sum);
138
+ for (size_t j = 0 ; j < tries.size (); j++) {
134
139
const auto & [code, partId] = tries[j].value ();
135
140
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
136
141
handleErrorCode (code, spaceId_, partId);
Original file line number Diff line number Diff line change @@ -179,8 +179,13 @@ void ScanEdgeProcessor::runInMultipleThread(const cpp2::ScanEdgeRequest& req) {
179
179
folly::collectAll (futures).via (executor_).thenTry ([this ](auto && t) mutable {
180
180
CHECK (!t.hasException ());
181
181
const auto & tries = t.value ();
182
+ size_t sum = 0 ;
182
183
for (size_t j = 0 ; j < tries.size (); j++) {
183
184
CHECK (!tries[j].hasException ());
185
+ sum += results_[j].size ();
186
+ }
187
+ resultDataSet_.rows .reserve (sum);
188
+ for (size_t j = 0 ; j < tries.size (); j++) {
184
189
const auto & [code, partId] = tries[j].value ();
185
190
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
186
191
handleErrorCode (code, spaceId_, partId);
Original file line number Diff line number Diff line change @@ -184,8 +184,13 @@ void ScanVertexProcessor::runInMultipleThread(const cpp2::ScanVertexRequest& req
184
184
folly::collectAll (futures).via (executor_).thenTry ([this ](auto && t) mutable {
185
185
CHECK (!t.hasException ());
186
186
const auto & tries = t.value ();
187
+ size_t sum = 0 ;
187
188
for (size_t j = 0 ; j < tries.size (); j++) {
188
189
CHECK (!tries[j].hasException ());
190
+ sum += results_[j].size ();
191
+ }
192
+ resultDataSet_.rows .reserve (sum);
193
+ for (size_t j = 0 ; j < tries.size (); j++) {
189
194
const auto & [code, partId] = tries[j].value ();
190
195
if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
191
196
handleErrorCode (code, spaceId_, partId);
You can’t perform that action at this time.
0 commit comments