Migrate unique_ptr from InitEdges to optional

Reviewers: buda, florijan, teon.banek

Reviewed By: florijan

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D674
This commit is contained in:
Mislav Bradac 2017-08-17 16:02:33 +02:00
parent 0f12426ae3
commit 3a365a2808
2 changed files with 15 additions and 15 deletions

View File

@ -453,10 +453,10 @@ bool Expand::ExpandCursor::Pull(Frame &frame, const SymbolTable &symbol_table) {
void Expand::ExpandCursor::Reset() {
input_cursor_->Reset();
in_edges_.release();
in_edges_it_.release();
out_edges_.release();
out_edges_it_.release();
in_edges_ = std::experimental::nullopt;
in_edges_it_ = std::experimental::nullopt;
out_edges_ = std::experimental::nullopt;
out_edges_it_ = std::experimental::nullopt;
}
namespace {
@ -494,14 +494,14 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame,
auto direction = self_.direction_;
if (direction == EdgeAtom::Direction::IN ||
direction == EdgeAtom::Direction::BOTH) {
in_edges_ = std::make_unique<InEdgeT>(vertex.in());
in_edges_it_ = std::make_unique<InEdgeIteratorT>(in_edges_->begin());
in_edges_.emplace(vertex.in());
in_edges_it_.emplace(in_edges_->begin());
}
if (direction == EdgeAtom::Direction::OUT ||
direction == EdgeAtom::Direction::BOTH) {
out_edges_ = std::make_unique<InEdgeT>(vertex.out());
out_edges_it_ = std::make_unique<InEdgeIteratorT>(out_edges_->begin());
out_edges_.emplace(vertex.out());
out_edges_it_.emplace(out_edges_->begin());
}
// TODO add support for Front and Back expansion (when QueryPlanner

View File

@ -551,13 +551,13 @@ class Expand : public LogicalOperator, ExpandCommon {
const std::unique_ptr<Cursor> input_cursor_;
GraphDbAccessor &db_;
// the iterable over edges and the current edge iterator are referenced via
// unique pointers because they can not be initialized in the constructor of
// this class. They are initialized once for each pull from the input
std::unique_ptr<InEdgeT> in_edges_;
std::unique_ptr<InEdgeIteratorT> in_edges_it_;
std::unique_ptr<OutEdgeT> out_edges_;
std::unique_ptr<OutEdgeIteratorT> out_edges_it_;
// The iterable over edges and the current edge iterator are referenced via
// optional because they can not be initialized in the constructor of
// this class. They are initialized once for each pull from the input.
std::experimental::optional<InEdgeT> in_edges_;
std::experimental::optional<InEdgeIteratorT> in_edges_it_;
std::experimental::optional<OutEdgeT> out_edges_;
std::experimental::optional<OutEdgeIteratorT> out_edges_it_;
bool InitEdges(Frame &frame, const SymbolTable &symbol_table);