memgraph/src/storage/edge_accessor.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

#include "storage/edge_accessor.hpp"
2016-09-09 23:14:20 +08:00
#include <cassert>
2016-12-20 01:32:44 +08:00
#include "utils/assert.hpp"
#include "storage/vertex_record.hpp"
#include "storage/edge_type/edge_type.hpp"
2016-08-30 15:53:02 +08:00
void EdgeAccessor::remove() const
{
2016-08-30 15:53:02 +08:00
RecordAccessor::remove();
auto from_va = from();
2016-12-20 01:32:44 +08:00
auto from_va_is_full = from_va.fill();
runtime_assert(from_va_is_full, "From Vertex Accessor is empty");
2016-08-30 15:53:02 +08:00
auto to_va = to();
2016-12-20 01:32:44 +08:00
auto to_va_is_full = to_va.fill();
permanent_assert(to_va_is_full, "To Vertex Accessor is empty");
2016-08-30 15:53:02 +08:00
from_va.update().record->data.out.remove(vlist);
to_va.update().record->data.in.remove(vlist);
}
2016-08-28 22:47:13 +08:00
void EdgeAccessor::edge_type(const EdgeType &edge_type)
{
2016-08-28 22:47:13 +08:00
this->record->data.edge_type = &edge_type;
}
2016-08-28 22:47:13 +08:00
const EdgeType &EdgeAccessor::edge_type() const
{
2016-09-09 23:14:20 +08:00
assert(this->record->data.edge_type != nullptr);
runtime_assert(this->record->data.edge_type != nullptr, "EdgeType is null");
2016-08-28 22:47:13 +08:00
return *this->record->data.edge_type;
}
2016-08-29 21:51:31 +08:00
VertexAccessor EdgeAccessor::from() const
{
return VertexAccessor(this->vlist->from(), this->db);
}
VertexAccessor EdgeAccessor::to() const
{
return VertexAccessor(this->vlist->to(), this->db);
}