-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support basic feature * dedup by pointer * return DataSet instead of List Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
- Loading branch information
1 parent
6317917
commit af1e1e8
Showing
13 changed files
with
688 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* Copyright (c) 2022 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#ifndef STORAGE_EXEC_GETDSTBYSRCNODE_H_ | ||
#define STORAGE_EXEC_GETDSTBYSRCNODE_H_ | ||
|
||
#include "common/base/Base.h" | ||
|
||
namespace nebula { | ||
namespace storage { | ||
|
||
class GetDstBySrcNode : public QueryNode<VertexID> { | ||
public: | ||
using RelNode::doExecute; | ||
|
||
GetDstBySrcNode(RuntimeContext* context, | ||
const std::vector<SingleEdgeNode*>& edgeNodes, | ||
EdgeContext* edgeContext, | ||
nebula::DataSet* result) | ||
: context_(context), edgeNodes_(edgeNodes), edgeContext_(edgeContext), result_(result) { | ||
name_ = "GetDstBySrcNode"; | ||
} | ||
|
||
// need to override doExecute because the return format of GetNeighborsNode and | ||
// GetDstBySrcNode are different | ||
nebula::cpp2::ErrorCode doExecute(PartitionID partId, const VertexID& vId) override { | ||
auto ret = RelNode::doExecute(partId, vId); | ||
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { | ||
return ret; | ||
} | ||
|
||
std::vector<SingleEdgeIterator*> iters; | ||
for (auto* edgeNode : edgeNodes_) { | ||
iters.emplace_back(edgeNode->iter()); | ||
} | ||
iter_.reset(new MultiEdgeIterator(std::move(iters))); | ||
if (iter_->valid()) { | ||
setCurrentEdgeInfo(iter_->edgeType()); | ||
} | ||
return iterateEdges(); | ||
} | ||
|
||
private: | ||
nebula::cpp2::ErrorCode iterateEdges() { | ||
for (; iter_->valid(); iter_->next()) { | ||
EdgeType type = iter_->edgeType(); | ||
if (type != context_->edgeType_) { | ||
// update info when edgeType changes while iterating over different edge types | ||
setCurrentEdgeInfo(type); | ||
} | ||
auto key = iter_->key(); | ||
auto reader = iter_->reader(); | ||
auto props = context_->props_; | ||
DCHECK_EQ(props->size(), 1); | ||
|
||
nebula::List list; | ||
// collect props need to return | ||
if (!QueryUtils::collectEdgeProps( | ||
key, context_->vIdLen(), context_->isIntId(), reader, props, list) | ||
.ok()) { | ||
return nebula::cpp2::ErrorCode::E_EDGE_PROP_NOT_FOUND; | ||
} | ||
result_->rows.emplace_back(std::move(list)); | ||
} | ||
return nebula::cpp2::ErrorCode::SUCCEEDED; | ||
} | ||
|
||
void setCurrentEdgeInfo(EdgeType type) { | ||
auto idxIter = edgeContext_->indexMap_.find(type); | ||
CHECK(idxIter != edgeContext_->indexMap_.end()); | ||
auto schemaIter = edgeContext_->schemas_.find(std::abs(type)); | ||
CHECK(schemaIter != edgeContext_->schemas_.end()); | ||
CHECK(!schemaIter->second.empty()); | ||
|
||
context_->edgeSchema_ = schemaIter->second.back().get(); | ||
auto idx = idxIter->second; | ||
context_->edgeType_ = type; | ||
context_->edgeName_ = edgeNodes_[iter_->getIdx()]->getEdgeName(); | ||
context_->props_ = &(edgeContext_->propContexts_[idx].second); | ||
} | ||
|
||
private: | ||
RuntimeContext* context_; | ||
std::vector<SingleEdgeNode*> edgeNodes_; | ||
EdgeContext* edgeContext_; | ||
nebula::DataSet* result_; | ||
std::unique_ptr<MultiEdgeIterator> iter_; | ||
}; | ||
|
||
} // namespace storage | ||
} // namespace nebula | ||
|
||
#endif // STORAGE_EXEC_GETDSTBYSRCNODE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.