Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

eliminate one copy overhead in ExtractList of UnwindExecutor #1276

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 4 additions & 7 deletions src/executor/query/UnwindExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ folly::Future<Status> UnwindExecutor::execute() {
DataSet ds;
ds.colNames = unwind->colNames();
for (; iter->valid(); iter->next()) {
Value list = unwindExpr->eval(ctx(iter.get()));
const Value& list = unwindExpr->eval(ctx(iter.get()));
std::vector<Value> vals = extractList(list);
for (auto &v : vals) {
Row row;
Expand All @@ -41,17 +41,14 @@ folly::Future<Status> UnwindExecutor::execute() {
return finish(ResultBuilder().value(Value(std::move(ds))).finish());
}

std::vector<Value> UnwindExecutor::extractList(Value &val) {
std::vector<Value> UnwindExecutor::extractList(const Value &val) {
std::vector<Value> ret;
if (val.isList()) {
auto &list = val.getList();
ret.reserve(list.size());
for (size_t i = 0; i < list.size(); ++i) {
ret.emplace_back(std::move(list[i]));
}
ret = list.values;
} else {
if (!(val.isNull() || val.empty())) {
ret.emplace_back(std::move(val));
jievince marked this conversation as resolved.
Show resolved Hide resolved
ret.push_back(val);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/executor/query/UnwindExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UnwindExecutor final : public Executor {
folly::Future<Status> execute() override;

private:
std::vector<Value> extractList(Value &val);
std::vector<Value> extractList(const Value &val);
};

} // namespace graph
Expand Down