Migrate db::types to storage::
Reviewers: teon.banek, dgleich Reviewed By: teon.banek, dgleich Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1110
This commit is contained in:
parent
98cbd2b500
commit
813d37e939
@ -14,6 +14,8 @@
|
||||
#include "transactions/engine_worker.hpp"
|
||||
#include "utils/flag_validation.hpp"
|
||||
|
||||
using namespace storage;
|
||||
|
||||
namespace database {
|
||||
namespace impl {
|
||||
|
||||
@ -28,9 +30,9 @@ class Base {
|
||||
virtual StorageGc &storage_gc() = 0;
|
||||
virtual durability::WriteAheadLog &wal() = 0;
|
||||
virtual tx::Engine &tx_engine() = 0;
|
||||
virtual storage::ConcurrentIdMapper<Label> &label_mapper() = 0;
|
||||
virtual storage::ConcurrentIdMapper<EdgeType> &edge_type_mapper() = 0;
|
||||
virtual storage::ConcurrentIdMapper<Property> &property_mapper() = 0;
|
||||
virtual ConcurrentIdMapper<Label> &label_mapper() = 0;
|
||||
virtual ConcurrentIdMapper<EdgeType> &edge_type_mapper() = 0;
|
||||
virtual ConcurrentIdMapper<Property> &property_mapper() = 0;
|
||||
virtual database::Counters &counters() = 0;
|
||||
|
||||
Base(const Base &) = delete;
|
||||
@ -50,20 +52,20 @@ struct TypemapPack {
|
||||
TMapper<Property> property;
|
||||
};
|
||||
|
||||
#define IMPL_GETTERS \
|
||||
Storage &storage() override { return storage_; } \
|
||||
StorageGc &storage_gc() override { return storage_gc_; } \
|
||||
durability::WriteAheadLog &wal() override { return wal_; } \
|
||||
tx::Engine &tx_engine() override { return tx_engine_; } \
|
||||
storage::ConcurrentIdMapper<Label> &label_mapper() override { \
|
||||
return typemap_pack_.label; \
|
||||
} \
|
||||
storage::ConcurrentIdMapper<EdgeType> &edge_type_mapper() override { \
|
||||
return typemap_pack_.edge_type; \
|
||||
} \
|
||||
storage::ConcurrentIdMapper<Property> &property_mapper() override { \
|
||||
return typemap_pack_.property; \
|
||||
} \
|
||||
#define IMPL_GETTERS \
|
||||
Storage &storage() override { return storage_; } \
|
||||
StorageGc &storage_gc() override { return storage_gc_; } \
|
||||
durability::WriteAheadLog &wal() override { return wal_; } \
|
||||
tx::Engine &tx_engine() override { return tx_engine_; } \
|
||||
ConcurrentIdMapper<Label> &label_mapper() override { \
|
||||
return typemap_pack_.label; \
|
||||
} \
|
||||
ConcurrentIdMapper<EdgeType> &edge_type_mapper() override { \
|
||||
return typemap_pack_.edge_type; \
|
||||
} \
|
||||
ConcurrentIdMapper<Property> &property_mapper() override { \
|
||||
return typemap_pack_.property; \
|
||||
} \
|
||||
database::Counters &counters() override { return counters_; }
|
||||
|
||||
class SingleNode : public Base {
|
||||
@ -77,7 +79,7 @@ class SingleNode : public Base {
|
||||
config_.durability_enabled};
|
||||
tx::SingleNodeEngine tx_engine_{&wal_};
|
||||
StorageGc storage_gc_{storage_, tx_engine_, config_.gc_cycle_sec};
|
||||
TypemapPack<storage::SingleNodeConcurrentIdMapper> typemap_pack_;
|
||||
TypemapPack<SingleNodeConcurrentIdMapper> typemap_pack_;
|
||||
database::SingleNodeCounters counters_;
|
||||
};
|
||||
|
||||
@ -94,7 +96,7 @@ class Master : public Base {
|
||||
tx::MasterEngine tx_engine_{system_, &wal_};
|
||||
StorageGc storage_gc_{storage_, tx_engine_, config_.gc_cycle_sec};
|
||||
distributed::MasterCoordination coordination{system_};
|
||||
TypemapPack<storage::MasterConcurrentIdMapper> typemap_pack_{system_};
|
||||
TypemapPack<MasterConcurrentIdMapper> typemap_pack_{system_};
|
||||
database::MasterCounters counters_{system_};
|
||||
};
|
||||
|
||||
@ -113,8 +115,8 @@ class Worker : public Base {
|
||||
StorageGc storage_gc_{storage_, tx_engine_, config_.gc_cycle_sec};
|
||||
durability::WriteAheadLog wal_{config_.durability_directory,
|
||||
config_.durability_enabled};
|
||||
TypemapPack<storage::WorkerConcurrentIdMapper> typemap_pack_{
|
||||
system_, config_.master_endpoint};
|
||||
TypemapPack<WorkerConcurrentIdMapper> typemap_pack_{system_,
|
||||
config_.master_endpoint};
|
||||
database::WorkerCounters counters_{system_, config_.master_endpoint};
|
||||
};
|
||||
|
||||
@ -148,15 +150,15 @@ durability::WriteAheadLog &GraphDb::wal() { return impl_->wal(); }
|
||||
|
||||
tx::Engine &GraphDb::tx_engine() { return impl_->tx_engine(); }
|
||||
|
||||
storage::ConcurrentIdMapper<Label> &GraphDb::label_mapper() {
|
||||
ConcurrentIdMapper<Label> &GraphDb::label_mapper() {
|
||||
return impl_->label_mapper();
|
||||
}
|
||||
|
||||
storage::ConcurrentIdMapper<EdgeType> &GraphDb::edge_type_mapper() {
|
||||
ConcurrentIdMapper<EdgeType> &GraphDb::edge_type_mapper() {
|
||||
return impl_->edge_type_mapper();
|
||||
}
|
||||
|
||||
storage::ConcurrentIdMapper<Property> &GraphDb::property_mapper() {
|
||||
ConcurrentIdMapper<Property> &GraphDb::property_mapper() {
|
||||
return impl_->property_mapper();
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include "database/counters.hpp"
|
||||
#include "database/storage.hpp"
|
||||
#include "database/storage_gc.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "durability/wal.hpp"
|
||||
#include "io/network/endpoint.hpp"
|
||||
#include "storage/concurrent_id_mapper.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "transactions/engine.hpp"
|
||||
#include "utils/scheduler.hpp"
|
||||
|
||||
@ -71,9 +71,9 @@ class GraphDb {
|
||||
Storage &storage();
|
||||
durability::WriteAheadLog &wal();
|
||||
tx::Engine &tx_engine();
|
||||
storage::ConcurrentIdMapper<Label> &label_mapper();
|
||||
storage::ConcurrentIdMapper<EdgeType> &edge_type_mapper();
|
||||
storage::ConcurrentIdMapper<Property> &property_mapper();
|
||||
storage::ConcurrentIdMapper<storage::Label> &label_mapper();
|
||||
storage::ConcurrentIdMapper<storage::EdgeType> &edge_type_mapper();
|
||||
storage::ConcurrentIdMapper<storage::Property> &property_mapper();
|
||||
database::Counters &counters();
|
||||
void CollectGarbage();
|
||||
|
||||
|
@ -86,8 +86,8 @@ std::experimental::optional<EdgeAccessor> GraphDbAccessor::FindEdge(
|
||||
return record_accessor;
|
||||
}
|
||||
|
||||
void GraphDbAccessor::BuildIndex(const class Label &label,
|
||||
const class Property &property) {
|
||||
void GraphDbAccessor::BuildIndex(storage::Label label,
|
||||
storage::Property property) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
|
||||
db_.storage().index_build_tx_in_progress_.access().insert(transaction_.id_);
|
||||
@ -163,7 +163,7 @@ void GraphDbAccessor::BuildIndex(const class Label &label,
|
||||
db_.storage().label_property_index_.IndexFinishedBuilding(key);
|
||||
}
|
||||
|
||||
void GraphDbAccessor::UpdateLabelIndices(const class Label &label,
|
||||
void GraphDbAccessor::UpdateLabelIndices(storage::Label label,
|
||||
const VertexAccessor &vertex_accessor,
|
||||
const Vertex *const vertex) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
@ -174,8 +174,8 @@ void GraphDbAccessor::UpdateLabelIndices(const class Label &label,
|
||||
}
|
||||
|
||||
void GraphDbAccessor::UpdatePropertyIndex(
|
||||
const class Property &property,
|
||||
const RecordAccessor<Vertex> &vertex_accessor, const Vertex *const vertex) {
|
||||
storage::Property property, const RecordAccessor<Vertex> &vertex_accessor,
|
||||
const Vertex *const vertex) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
DCHECK(vertex_accessor.is_local()) << "Only local vertices belong in indexes";
|
||||
db_.storage().label_property_index_.UpdateOnProperty(
|
||||
@ -187,13 +187,13 @@ int64_t GraphDbAccessor::VerticesCount() const {
|
||||
return db_.storage().vertices_.access().size();
|
||||
}
|
||||
|
||||
int64_t GraphDbAccessor::VerticesCount(const class Label &label) const {
|
||||
int64_t GraphDbAccessor::VerticesCount(storage::Label label) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.storage().labels_index_.Count(label);
|
||||
}
|
||||
|
||||
int64_t GraphDbAccessor::VerticesCount(const class Label &label,
|
||||
const class Property &property) const {
|
||||
int64_t GraphDbAccessor::VerticesCount(storage::Label label,
|
||||
storage::Property property) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
const LabelPropertyIndex::Key key(label, property);
|
||||
DCHECK(db_.storage().label_property_index_.IndexExists(key))
|
||||
@ -201,8 +201,8 @@ int64_t GraphDbAccessor::VerticesCount(const class Label &label,
|
||||
return db_.storage().label_property_index_.Count(key);
|
||||
}
|
||||
|
||||
int64_t GraphDbAccessor::VerticesCount(const class Label &label,
|
||||
const class Property &property,
|
||||
int64_t GraphDbAccessor::VerticesCount(storage::Label label,
|
||||
storage::Property property,
|
||||
const PropertyValue &value) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
const LabelPropertyIndex::Key key(label, property);
|
||||
@ -214,7 +214,7 @@ int64_t GraphDbAccessor::VerticesCount(const class Label &label,
|
||||
}
|
||||
|
||||
int64_t GraphDbAccessor::VerticesCount(
|
||||
const class Label &label, const class Property &property,
|
||||
storage::Label label, storage::Property property,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
|
||||
const {
|
||||
@ -306,7 +306,7 @@ void GraphDbAccessor::DetachRemoveVertex(VertexAccessor &vertex_accessor) {
|
||||
}
|
||||
|
||||
EdgeAccessor GraphDbAccessor::InsertEdge(
|
||||
VertexAccessor &from, VertexAccessor &to, class EdgeType edge_type,
|
||||
VertexAccessor &from, VertexAccessor &to, storage::EdgeType edge_type,
|
||||
std::experimental::optional<gid::Gid> requested_gid) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
// An edge is created on the worker of it's "from" vertex.
|
||||
@ -378,34 +378,34 @@ void GraphDbAccessor::RemoveEdge(EdgeAccessor &edge_accessor,
|
||||
database::StateDelta::RemoveEdge(transaction_.id_, edge_accessor.gid()));
|
||||
}
|
||||
|
||||
Label GraphDbAccessor::Label(const std::string &label_name) {
|
||||
storage::Label GraphDbAccessor::Label(const std::string &label_name) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.label_mapper().value_to_id(label_name);
|
||||
}
|
||||
|
||||
const std::string &GraphDbAccessor::LabelName(const class Label label) const {
|
||||
const std::string &GraphDbAccessor::LabelName(storage::Label label) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.label_mapper().id_to_value(label);
|
||||
}
|
||||
|
||||
EdgeType GraphDbAccessor::EdgeType(const std::string &edge_type_name) {
|
||||
storage::EdgeType GraphDbAccessor::EdgeType(const std::string &edge_type_name) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.edge_type_mapper().value_to_id(edge_type_name);
|
||||
}
|
||||
|
||||
const std::string &GraphDbAccessor::EdgeTypeName(
|
||||
const class EdgeType edge_type) const {
|
||||
storage::EdgeType edge_type) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.edge_type_mapper().id_to_value(edge_type);
|
||||
}
|
||||
|
||||
Property GraphDbAccessor::Property(const std::string &property_name) {
|
||||
storage::Property GraphDbAccessor::Property(const std::string &property_name) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.property_mapper().value_to_id(property_name);
|
||||
}
|
||||
|
||||
const std::string &GraphDbAccessor::PropertyName(
|
||||
const class Property property) const {
|
||||
storage::Property property) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.property_mapper().id_to_value(property);
|
||||
}
|
||||
@ -420,7 +420,7 @@ void GraphDbAccessor::CounterSet(const std::string &name, int64_t value) {
|
||||
|
||||
std::vector<std::string> GraphDbAccessor::IndexInfo() const {
|
||||
std::vector<std::string> info;
|
||||
for (class Label label : db_.storage().labels_index_.Keys()) {
|
||||
for (storage::Label label : db_.storage().labels_index_.Keys()) {
|
||||
info.emplace_back(":" + LabelName(label));
|
||||
}
|
||||
for (LabelPropertyIndex::Key key :
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/edge_accessor.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex_accessor.hpp"
|
||||
#include "transactions/engine_single_node.hpp"
|
||||
#include "transactions/transaction.hpp"
|
||||
@ -189,7 +189,7 @@ class GraphDbAccessor {
|
||||
* ignored).
|
||||
* @return iterable collection
|
||||
*/
|
||||
auto Vertices(const Label &label, bool current_state) {
|
||||
auto Vertices(storage::Label label, bool current_state) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return iter::imap(
|
||||
[this](auto vlist) { return VertexAccessor(vlist, *this); },
|
||||
@ -209,7 +209,7 @@ class GraphDbAccessor {
|
||||
* ignored).
|
||||
* @return iterable collection
|
||||
*/
|
||||
auto Vertices(const Label &label, const Property &property,
|
||||
auto Vertices(storage::Label label, storage::Property property,
|
||||
bool current_state) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
DCHECK(db_.storage().label_property_index_.IndexExists(
|
||||
@ -235,7 +235,7 @@ class GraphDbAccessor {
|
||||
* ignored).
|
||||
* @return iterable collection
|
||||
*/
|
||||
auto Vertices(const Label &label, const Property &property,
|
||||
auto Vertices(storage::Label label, storage::Property property,
|
||||
const PropertyValue &value, bool current_state) {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
DCHECK(db_.storage().label_property_index_.IndexExists(
|
||||
@ -278,7 +278,7 @@ class GraphDbAccessor {
|
||||
* satisfy the bounds and are visible to the current transaction.
|
||||
*/
|
||||
auto Vertices(
|
||||
const Label &label, const Property &property,
|
||||
storage::Label label, storage::Property property,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> upper,
|
||||
bool current_state) {
|
||||
@ -312,7 +312,7 @@ class GraphDbAccessor {
|
||||
* @return An accessor to the edge.
|
||||
*/
|
||||
EdgeAccessor InsertEdge(VertexAccessor &from, VertexAccessor &to,
|
||||
EdgeType type,
|
||||
storage::EdgeType type,
|
||||
std::experimental::optional<gid::Gid> requested_gid =
|
||||
std::experimental::nullopt);
|
||||
|
||||
@ -416,14 +416,14 @@ class GraphDbAccessor {
|
||||
* @param label - label to build for
|
||||
* @param property - property to build for
|
||||
*/
|
||||
void BuildIndex(const Label &label, const Property &property);
|
||||
void BuildIndex(storage::Label label, storage::Property property);
|
||||
|
||||
/**
|
||||
* @brief - Returns true if the given label+property index already exists and
|
||||
* is ready for use.
|
||||
*/
|
||||
bool LabelPropertyIndexExists(const Label &label,
|
||||
const Property &property) const {
|
||||
bool LabelPropertyIndexExists(storage::Label label,
|
||||
storage::Property property) const {
|
||||
DCHECK(!commited_ && !aborted_) << "Accessor committed or aborted";
|
||||
return db_.storage().label_property_index_.IndexExists(
|
||||
LabelPropertyIndex::Key(label, property));
|
||||
@ -456,7 +456,7 @@ class GraphDbAccessor {
|
||||
* @param label - label to check for
|
||||
* @return number of vertices with the given label
|
||||
*/
|
||||
int64_t VerticesCount(const Label &label) const;
|
||||
int64_t VerticesCount(storage::Label label) const;
|
||||
|
||||
/**
|
||||
* Return approximate number of vertices under indexes with the given label
|
||||
@ -468,7 +468,7 @@ class GraphDbAccessor {
|
||||
* @return number of vertices with the given label, fails if no such
|
||||
* label+property index exists.
|
||||
*/
|
||||
int64_t VerticesCount(const Label &label, const Property &property) const;
|
||||
int64_t VerticesCount(storage::Label label, storage::Property property) const;
|
||||
|
||||
/**
|
||||
* Returns approximate number of vertices that have the given label
|
||||
@ -476,7 +476,7 @@ class GraphDbAccessor {
|
||||
*
|
||||
* Assumes that an index for that (label, property) exists.
|
||||
*/
|
||||
int64_t VerticesCount(const Label &label, const Property &property,
|
||||
int64_t VerticesCount(storage::Label label, storage::Property property,
|
||||
const PropertyValue &value) const;
|
||||
|
||||
/**
|
||||
@ -489,7 +489,7 @@ class GraphDbAccessor {
|
||||
* Assumes that an index for that (label, property) exists.
|
||||
*/
|
||||
int64_t VerticesCount(
|
||||
const Label &label, const Property &property,
|
||||
storage::Label label, storage::Property property,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
|
||||
const;
|
||||
@ -498,7 +498,7 @@ class GraphDbAccessor {
|
||||
* Obtains the Label for the label's name.
|
||||
* @return See above.
|
||||
*/
|
||||
Label Label(const std::string &label_name);
|
||||
storage::Label Label(const std::string &label_name);
|
||||
|
||||
/**
|
||||
* Obtains the label name (a string) for the given label.
|
||||
@ -506,13 +506,13 @@ class GraphDbAccessor {
|
||||
* @param label a Label.
|
||||
* @return See above.
|
||||
*/
|
||||
const std::string &LabelName(const class Label label) const;
|
||||
const std::string &LabelName(storage::Label label) const;
|
||||
|
||||
/**
|
||||
* Obtains the EdgeType for it's name.
|
||||
* @return See above.
|
||||
*/
|
||||
EdgeType EdgeType(const std::string &edge_type_name);
|
||||
storage::EdgeType EdgeType(const std::string &edge_type_name);
|
||||
|
||||
/**
|
||||
* Obtains the edge type name (a string) for the given edge type.
|
||||
@ -520,13 +520,13 @@ class GraphDbAccessor {
|
||||
* @param edge_type an EdgeType.
|
||||
* @return See above.
|
||||
*/
|
||||
const std::string &EdgeTypeName(const class EdgeType edge_type) const;
|
||||
const std::string &EdgeTypeName(storage::EdgeType edge_type) const;
|
||||
|
||||
/**
|
||||
* Obtains the Property for it's name.
|
||||
* @return See above.
|
||||
*/
|
||||
Property Property(const std::string &property_name);
|
||||
storage::Property Property(const std::string &property_name);
|
||||
|
||||
/**
|
||||
* Obtains the property name (a string) for the given property.
|
||||
@ -534,7 +534,7 @@ class GraphDbAccessor {
|
||||
* @param property a Property.
|
||||
* @return See above.
|
||||
*/
|
||||
const std::string &PropertyName(const class Property property) const;
|
||||
const std::string &PropertyName(storage::Property property) const;
|
||||
|
||||
/** Returns the id of this accessor's transaction */
|
||||
tx::transaction_id_t transaction_id() const;
|
||||
@ -607,7 +607,7 @@ class GraphDbAccessor {
|
||||
* @param vertex_accessor - vertex_accessor to insert
|
||||
* @param vertex - vertex record to insert
|
||||
*/
|
||||
void UpdateLabelIndices(const class Label &label,
|
||||
void UpdateLabelIndices(storage::Label label,
|
||||
const VertexAccessor &vertex_accessor,
|
||||
const Vertex *const vertex);
|
||||
|
||||
@ -618,7 +618,7 @@ class GraphDbAccessor {
|
||||
* @param vertex_accessor - vertex accessor to insert
|
||||
* @param vertex - vertex to insert
|
||||
*/
|
||||
void UpdatePropertyIndex(const class Property &property,
|
||||
void UpdatePropertyIndex(storage::Property property,
|
||||
const RecordAccessor<Vertex> &vertex_accessor,
|
||||
const Vertex *const vertex);
|
||||
};
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "data_structures/concurrent/concurrent_map.hpp"
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/indexes/index_common.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
#include "transactions/transaction.hpp"
|
||||
#include "utils/total_ordering.hpp"
|
||||
@ -174,7 +174,7 @@ class KeyIndex {
|
||||
* @param label - label to check for.
|
||||
* @return true if it contains, false otherwise.
|
||||
*/
|
||||
static bool Exists(const Label &label, const Vertex *const v) {
|
||||
static bool Exists(storage::Label label, const Vertex *const v) {
|
||||
DCHECK(v != nullptr) << "Vertex is nullptr.";
|
||||
// We have to check for existance of label because the transaction
|
||||
// might not see the label, or the label was deleted and not yet
|
||||
@ -188,7 +188,7 @@ class KeyIndex {
|
||||
* @param edge_type - edge_type to check for.
|
||||
* @return true if it has that edge_type, false otherwise.
|
||||
*/
|
||||
static bool Exists(const EdgeType &edge_type, const Edge *const e) {
|
||||
static bool Exists(storage::EdgeType edge_type, const Edge *const e) {
|
||||
DCHECK(e != nullptr) << "Edge is nullptr.";
|
||||
// We have to check for equality of edge types because the transaction
|
||||
// might not see the edge type, or the edge type was deleted and not yet
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "data_structures/concurrent/concurrent_map.hpp"
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/indexes/index_common.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
#include "transactions/transaction.hpp"
|
||||
#include "utils/bound.hpp"
|
||||
@ -46,10 +46,10 @@ class LabelPropertyIndex {
|
||||
*/
|
||||
class Key : public TotalOrdering<Key> {
|
||||
public:
|
||||
const Label label_;
|
||||
const Property property_;
|
||||
const storage::Label label_;
|
||||
const storage::Property property_;
|
||||
|
||||
Key(const Label &label, const Property &property)
|
||||
Key(storage::Label label, storage::Property property)
|
||||
: label_(label), property_(property) {}
|
||||
|
||||
// Comparison operators - we need them to keep this sorted inside skiplist.
|
||||
@ -121,7 +121,8 @@ class LabelPropertyIndex {
|
||||
* @param vlist - pointer to vlist entry to add
|
||||
* @param vertex - pointer to vertex record entry to add (contained in vlist)
|
||||
*/
|
||||
void UpdateOnLabel(const Label &label, mvcc::VersionList<Vertex> *const vlist,
|
||||
void UpdateOnLabel(storage::Label label,
|
||||
mvcc::VersionList<Vertex> *const vlist,
|
||||
const Vertex *const vertex) {
|
||||
for (auto index : indices_.access()) {
|
||||
if (index.first.label_ != label) continue;
|
||||
@ -141,7 +142,7 @@ class LabelPropertyIndex {
|
||||
* @param vlist - pointer to vlist entry to add
|
||||
* @param vertex - pointer to vertex record entry to add (contained in vlist)
|
||||
*/
|
||||
void UpdateOnProperty(const Property &property,
|
||||
void UpdateOnProperty(storage::Property property,
|
||||
mvcc::VersionList<Vertex> *const vlist,
|
||||
const Vertex *const vertex) {
|
||||
const auto &labels = vertex->labels_;
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include "data_structures/concurrent/concurrent_set.hpp"
|
||||
#include "database/indexes/key_index.hpp"
|
||||
#include "database/indexes/label_property_index.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
|
||||
namespace database {
|
||||
@ -45,7 +45,7 @@ class Storage {
|
||||
ConcurrentMap<gid::Gid, mvcc::VersionList<Edge> *> edges_;
|
||||
|
||||
// indexes
|
||||
KeyIndex<Label, Vertex> labels_index_;
|
||||
KeyIndex<storage::Label, Vertex> labels_index_;
|
||||
LabelPropertyIndex label_property_index_;
|
||||
|
||||
// Set of transactions ids which are building indexes currently
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
#include "utils/serialization.hpp"
|
||||
|
||||
@ -96,11 +96,11 @@ void LoadProperties(TArchive &ar, PropertyValueStore &store) {
|
||||
size_t count;
|
||||
ar >> count;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
database::Property::StorageT prop;
|
||||
storage::Property::StorageT prop;
|
||||
ar >> prop;
|
||||
query::TypedValue value;
|
||||
utils::LoadTypedValue(ar, value);
|
||||
store.set(database::Property(prop), static_cast<PropertyValue>(value));
|
||||
store.set(storage::Property(prop), static_cast<PropertyValue>(value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,14 +121,14 @@ std::unique_ptr<Vertex> LoadVertex(TArchive &ar) {
|
||||
ar >> count;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
auto vertex_address = impl::LoadVertexAddress(ar);
|
||||
database::EdgeType::StorageT edge_type;
|
||||
storage::EdgeType::StorageT edge_type;
|
||||
gid::Gid edge_id;
|
||||
ar >> edge_id;
|
||||
int edge_worker_id;
|
||||
ar >> edge_worker_id;
|
||||
ar >> edge_type;
|
||||
edges.emplace(vertex_address, {edge_id, edge_worker_id},
|
||||
database::EdgeType(edge_type));
|
||||
storage::EdgeType(edge_type));
|
||||
}
|
||||
};
|
||||
decode_edges(vertex->out_);
|
||||
@ -137,7 +137,7 @@ std::unique_ptr<Vertex> LoadVertex(TArchive &ar) {
|
||||
size_t count;
|
||||
ar >> count;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
database::Label::StorageT label;
|
||||
storage::Label::StorageT label;
|
||||
ar >> label;
|
||||
vertex->labels_.emplace_back(label);
|
||||
}
|
||||
@ -156,9 +156,9 @@ template <typename TArchive>
|
||||
std::unique_ptr<Edge> LoadEdge(TArchive &ar) {
|
||||
auto from = impl::LoadVertexAddress(ar);
|
||||
auto to = impl::LoadVertexAddress(ar);
|
||||
database::EdgeType::StorageT edge_type;
|
||||
storage::EdgeType::StorageT edge_type;
|
||||
ar >> edge_type;
|
||||
auto edge = std::make_unique<Edge>(from, to, database::EdgeType{edge_type});
|
||||
auto edge = std::make_unique<Edge>(from, to, storage::EdgeType{edge_type});
|
||||
impl::LoadProperties(ar, edge->properties_);
|
||||
|
||||
return edge;
|
||||
|
@ -12,9 +12,9 @@
|
||||
#include "communication/bolt/v1/encoder/primitive_encoder.hpp"
|
||||
#include "data_structures/ring_buffer.hpp"
|
||||
#include "database/state_delta.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/gid.hpp"
|
||||
#include "storage/property_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "transactions/type.hpp"
|
||||
#include "utils/scheduler.hpp"
|
||||
|
||||
|
@ -12,26 +12,26 @@
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "query/frontend/ast/ast_visitor.hpp"
|
||||
#include "query/frontend/semantic/symbol.hpp"
|
||||
#include "query/interpret/awesome_memgraph_functions.hpp"
|
||||
#include "query/parameters.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/serialization.hpp"
|
||||
|
||||
// Hash function for the key in pattern atom property maps.
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<std::pair<std::string, database::Property>> {
|
||||
struct hash<std::pair<std::string, storage::Property>> {
|
||||
size_t operator()(
|
||||
const std::pair<std::string, database::Property> &pair) const {
|
||||
const std::pair<std::string, storage::Property> &pair) const {
|
||||
return string_hash(pair.first) ^ property_hash(pair.second);
|
||||
};
|
||||
|
||||
private:
|
||||
std::hash<std::string> string_hash{};
|
||||
std::hash<database::Property> property_hash{};
|
||||
std::hash<storage::Property> property_hash{};
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
@ -1060,15 +1060,14 @@ class MapLiteral : public BaseLiteral {
|
||||
}
|
||||
|
||||
// maps (property_name, property) to expressions
|
||||
std::unordered_map<std::pair<std::string, database::Property>, Expression *>
|
||||
std::unordered_map<std::pair<std::string, storage::Property>, Expression *>
|
||||
elements_;
|
||||
|
||||
protected:
|
||||
explicit MapLiteral(int uid) : BaseLiteral(uid) {}
|
||||
MapLiteral(
|
||||
int uid,
|
||||
const std::unordered_map<std::pair<std::string, database::Property>,
|
||||
Expression *> &elements)
|
||||
MapLiteral(int uid,
|
||||
const std::unordered_map<std::pair<std::string, storage::Property>,
|
||||
Expression *> &elements)
|
||||
: BaseLiteral(uid), elements_(elements) {}
|
||||
|
||||
private:
|
||||
@ -1094,7 +1093,7 @@ class MapLiteral : public BaseLiteral {
|
||||
size_t size = 0;
|
||||
ar >> size;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
std::pair<std::string, database::Property> property;
|
||||
std::pair<std::string, storage::Property> property;
|
||||
ar >> property.first;
|
||||
ar >> property.second;
|
||||
Expression *expression = nullptr;
|
||||
@ -1164,17 +1163,17 @@ class PropertyLookup : public Expression {
|
||||
|
||||
Expression *expression_ = nullptr;
|
||||
std::string property_name_;
|
||||
database::Property property_;
|
||||
storage::Property property_;
|
||||
|
||||
protected:
|
||||
PropertyLookup(int uid, Expression *expression,
|
||||
const std::string &property_name, database::Property property)
|
||||
const std::string &property_name, storage::Property property)
|
||||
: Expression(uid),
|
||||
expression_(expression),
|
||||
property_name_(property_name),
|
||||
property_(property) {}
|
||||
PropertyLookup(int uid, Expression *expression,
|
||||
const std::pair<std::string, database::Property> &property)
|
||||
const std::pair<std::string, storage::Property> &property)
|
||||
: Expression(uid),
|
||||
expression_(expression),
|
||||
property_name_(property.first),
|
||||
@ -1224,11 +1223,11 @@ class LabelsTest : public Expression {
|
||||
}
|
||||
|
||||
Expression *expression_ = nullptr;
|
||||
std::vector<database::Label> labels_;
|
||||
std::vector<storage::Label> labels_;
|
||||
|
||||
protected:
|
||||
LabelsTest(int uid, Expression *expression,
|
||||
const std::vector<database::Label> &labels)
|
||||
const std::vector<storage::Label> &labels)
|
||||
: Expression(uid), expression_(expression), labels_(labels) {}
|
||||
|
||||
private:
|
||||
@ -1597,9 +1596,9 @@ class NodeAtom : public PatternAtom {
|
||||
return node_atom;
|
||||
}
|
||||
|
||||
std::vector<database::Label> labels_;
|
||||
std::vector<storage::Label> labels_;
|
||||
// maps (property_name, property) to an expression
|
||||
std::unordered_map<std::pair<std::string, database::Property>, Expression *>
|
||||
std::unordered_map<std::pair<std::string, storage::Property>, Expression *>
|
||||
properties_;
|
||||
|
||||
protected:
|
||||
@ -1630,7 +1629,7 @@ class NodeAtom : public PatternAtom {
|
||||
size_t size = 0;
|
||||
ar >> size;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
std::pair<std::string, database::Property> property;
|
||||
std::pair<std::string, storage::Property> property;
|
||||
ar >> property.first;
|
||||
ar >> property.second;
|
||||
Expression *expression = nullptr;
|
||||
@ -1704,8 +1703,8 @@ class EdgeAtom : public PatternAtom {
|
||||
|
||||
Type type_ = Type::SINGLE;
|
||||
Direction direction_ = Direction::BOTH;
|
||||
std::vector<database::EdgeType> edge_types_;
|
||||
std::unordered_map<std::pair<std::string, database::Property>, Expression *>
|
||||
std::vector<storage::EdgeType> edge_types_;
|
||||
std::unordered_map<std::pair<std::string, storage::Property>, Expression *>
|
||||
properties_;
|
||||
|
||||
// Used in variable length and BFS expansions. Bounds can be nullptr. Inner
|
||||
@ -1724,7 +1723,7 @@ class EdgeAtom : public PatternAtom {
|
||||
|
||||
// Creates an edge atom for a SINGLE expansion with the given .
|
||||
EdgeAtom(int uid, Identifier *identifier, Type type, Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types)
|
||||
const std::vector<storage::EdgeType> &edge_types)
|
||||
: PatternAtom(uid, identifier),
|
||||
type_(type),
|
||||
direction_(direction),
|
||||
@ -1764,7 +1763,7 @@ class EdgeAtom : public PatternAtom {
|
||||
size_t size = 0;
|
||||
ar >> size;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
std::pair<std::string, database::Property> property;
|
||||
std::pair<std::string, storage::Property> property;
|
||||
ar >> property.first;
|
||||
ar >> property.second;
|
||||
Expression *expression = nullptr;
|
||||
@ -2503,12 +2502,12 @@ class SetLabels : public Clause {
|
||||
}
|
||||
|
||||
Identifier *identifier_ = nullptr;
|
||||
std::vector<database::Label> labels_;
|
||||
std::vector<storage::Label> labels_;
|
||||
|
||||
protected:
|
||||
explicit SetLabels(int uid) : Clause(uid) {}
|
||||
SetLabels(int uid, Identifier *identifier,
|
||||
const std::vector<database::Label> &labels)
|
||||
const std::vector<storage::Label> &labels)
|
||||
: Clause(uid), identifier_(identifier), labels_(labels) {}
|
||||
|
||||
private:
|
||||
@ -2598,12 +2597,12 @@ class RemoveLabels : public Clause {
|
||||
}
|
||||
|
||||
Identifier *identifier_ = nullptr;
|
||||
std::vector<database::Label> labels_;
|
||||
std::vector<storage::Label> labels_;
|
||||
|
||||
protected:
|
||||
explicit RemoveLabels(int uid) : Clause(uid) {}
|
||||
RemoveLabels(int uid, Identifier *identifier,
|
||||
const std::vector<database::Label> &labels)
|
||||
const std::vector<storage::Label> &labels)
|
||||
: Clause(uid), identifier_(identifier), labels_(labels) {}
|
||||
|
||||
private:
|
||||
@ -2764,12 +2763,12 @@ class CreateIndex : public Clause {
|
||||
return storage.Create<CreateIndex>(label_, property_);
|
||||
}
|
||||
|
||||
database::Label label_;
|
||||
database::Property property_;
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
|
||||
protected:
|
||||
explicit CreateIndex(int uid) : Clause(uid) {}
|
||||
CreateIndex(int uid, database::Label label, database::Property property)
|
||||
CreateIndex(int uid, storage::Label label, storage::Property property)
|
||||
: Clause(uid), label_(label), property_(property) {}
|
||||
|
||||
private:
|
||||
@ -2832,9 +2831,9 @@ LOAD_AND_CONSTRUCT(query::PrimitiveLiteral, 0);
|
||||
LOAD_AND_CONSTRUCT(query::ListLiteral, 0);
|
||||
LOAD_AND_CONSTRUCT(query::MapLiteral, 0);
|
||||
LOAD_AND_CONSTRUCT(query::Identifier, 0, "");
|
||||
LOAD_AND_CONSTRUCT(query::PropertyLookup, 0, nullptr, "", database::Property());
|
||||
LOAD_AND_CONSTRUCT(query::PropertyLookup, 0, nullptr, "", storage::Property());
|
||||
LOAD_AND_CONSTRUCT(query::LabelsTest, 0, nullptr,
|
||||
std::vector<database::Label>());
|
||||
std::vector<storage::Label>());
|
||||
LOAD_AND_CONSTRUCT(query::Function, 0);
|
||||
LOAD_AND_CONSTRUCT(query::Aggregation, 0, nullptr, nullptr,
|
||||
query::Aggregation::Op::COUNT);
|
||||
|
@ -213,7 +213,7 @@ antlrcpp::Any CypherMainVisitor::visitCreate(CypherParser::CreateContext *ctx) {
|
||||
*/
|
||||
antlrcpp::Any CypherMainVisitor::visitCreateIndex(
|
||||
CypherParser::CreateIndexContext *ctx) {
|
||||
std::pair<std::string, database::Property> key =
|
||||
std::pair<std::string, storage::Property> key =
|
||||
ctx->propertyKeyName()->accept(this);
|
||||
return storage_.Create<CreateIndex>(
|
||||
ctx_.db_accessor_.Label(ctx->labelName()->accept(this)), key.second);
|
||||
@ -305,13 +305,13 @@ antlrcpp::Any CypherMainVisitor::visitNodePattern(
|
||||
}
|
||||
if (ctx->nodeLabels()) {
|
||||
node->labels_ =
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<database::Label>>();
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<storage::Label>>();
|
||||
}
|
||||
if (ctx->properties()) {
|
||||
node->properties_ =
|
||||
ctx->properties()
|
||||
->accept(this)
|
||||
.as<std::unordered_map<std::pair<std::string, database::Property>,
|
||||
.as<std::unordered_map<std::pair<std::string, storage::Property>,
|
||||
Expression *>>();
|
||||
}
|
||||
return node;
|
||||
@ -319,7 +319,7 @@ antlrcpp::Any CypherMainVisitor::visitNodePattern(
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitNodeLabels(
|
||||
CypherParser::NodeLabelsContext *ctx) {
|
||||
std::vector<database::Label> labels;
|
||||
std::vector<storage::Label> labels;
|
||||
for (auto *node_label : ctx->nodeLabel()) {
|
||||
labels.push_back(ctx_.db_accessor_.Label(node_label->accept(this)));
|
||||
}
|
||||
@ -341,10 +341,10 @@ antlrcpp::Any CypherMainVisitor::visitProperties(
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitMapLiteral(
|
||||
CypherParser::MapLiteralContext *ctx) {
|
||||
std::unordered_map<std::pair<std::string, database::Property>, Expression *>
|
||||
std::unordered_map<std::pair<std::string, storage::Property>, Expression *>
|
||||
map;
|
||||
for (int i = 0; i < static_cast<int>(ctx->propertyKeyName().size()); ++i) {
|
||||
std::pair<std::string, database::Property> key =
|
||||
std::pair<std::string, storage::Property> key =
|
||||
ctx->propertyKeyName()[i]->accept(this);
|
||||
Expression *value = ctx->expression()[i]->accept(this);
|
||||
if (!map.insert({key, value}).second) {
|
||||
@ -499,7 +499,7 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipPattern(
|
||||
edge->edge_types_ = ctx->relationshipDetail()
|
||||
->relationshipTypes()
|
||||
->accept(this)
|
||||
.as<std::vector<database::EdgeType>>();
|
||||
.as<std::vector<storage::EdgeType>>();
|
||||
}
|
||||
|
||||
auto relationshipLambdas = relationshipDetail->relationshipLambda();
|
||||
@ -539,7 +539,7 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipPattern(
|
||||
edge->properties_ =
|
||||
properties[0]
|
||||
->accept(this)
|
||||
.as<std::unordered_map<std::pair<std::string, database::Property>,
|
||||
.as<std::unordered_map<std::pair<std::string, storage::Property>,
|
||||
Expression *>>();
|
||||
break;
|
||||
}
|
||||
@ -564,7 +564,7 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipLambda(
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitRelationshipTypes(
|
||||
CypherParser::RelationshipTypesContext *ctx) {
|
||||
std::vector<database::EdgeType> types;
|
||||
std::vector<storage::EdgeType> types;
|
||||
for (auto *edge_type : ctx->relTypeName()) {
|
||||
types.push_back(ctx_.db_accessor_.EdgeType(edge_type->accept(this)));
|
||||
}
|
||||
@ -815,7 +815,7 @@ antlrcpp::Any CypherMainVisitor::visitExpression2a(
|
||||
Expression *expression = ctx->expression2b()->accept(this);
|
||||
if (ctx->nodeLabels()) {
|
||||
auto labels =
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<database::Label>>();
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<storage::Label>>();
|
||||
expression = storage_.Create<LabelsTest>(expression, labels);
|
||||
}
|
||||
return expression;
|
||||
@ -825,7 +825,7 @@ antlrcpp::Any CypherMainVisitor::visitExpression2b(
|
||||
CypherParser::Expression2bContext *ctx) {
|
||||
Expression *expression = ctx->atom()->accept(this);
|
||||
for (auto *lookup : ctx->propertyLookup()) {
|
||||
std::pair<std::string, database::Property> key = lookup->accept(this);
|
||||
std::pair<std::string, storage::Property> key = lookup->accept(this);
|
||||
auto property_lookup =
|
||||
storage_.Create<PropertyLookup>(expression, key.first, key.second);
|
||||
expression = property_lookup;
|
||||
@ -912,7 +912,7 @@ antlrcpp::Any CypherMainVisitor::visitLiteral(
|
||||
return static_cast<Expression *>(storage_.Create<MapLiteral>(
|
||||
ctx->mapLiteral()
|
||||
->accept(this)
|
||||
.as<std::unordered_map<std::pair<std::string, database::Property>,
|
||||
.as<std::unordered_map<std::pair<std::string, storage::Property>,
|
||||
Expression *>>()));
|
||||
}
|
||||
return visitChildren(ctx);
|
||||
@ -1072,7 +1072,7 @@ antlrcpp::Any CypherMainVisitor::visitSetItem(
|
||||
set_labels->identifier_ = storage_.Create<Identifier>(
|
||||
ctx->variable()->accept(this).as<std::string>());
|
||||
set_labels->labels_ =
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<database::Label>>();
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<storage::Label>>();
|
||||
return static_cast<Clause *>(set_labels);
|
||||
}
|
||||
|
||||
@ -1098,7 +1098,7 @@ antlrcpp::Any CypherMainVisitor::visitRemoveItem(
|
||||
remove_labels->identifier_ = storage_.Create<Identifier>(
|
||||
ctx->variable()->accept(this).as<std::string>());
|
||||
remove_labels->labels_ =
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<database::Label>>();
|
||||
ctx->nodeLabels()->accept(this).as<std::vector<storage::Label>>();
|
||||
return static_cast<Clause *>(remove_labels);
|
||||
}
|
||||
|
||||
@ -1106,7 +1106,7 @@ antlrcpp::Any CypherMainVisitor::visitPropertyExpression(
|
||||
CypherParser::PropertyExpressionContext *ctx) {
|
||||
Expression *expression = ctx->atom()->accept(this);
|
||||
for (auto *lookup : ctx->propertyLookup()) {
|
||||
std::pair<std::string, database::Property> key = lookup->accept(this);
|
||||
std::pair<std::string, storage::Property> key = lookup->accept(this);
|
||||
auto property_lookup =
|
||||
storage_.Create<PropertyLookup>(expression, key.first, key.second);
|
||||
expression = property_lookup;
|
||||
|
@ -214,12 +214,12 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor {
|
||||
CypherParser::NodePatternContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return vector<database::Label>
|
||||
* @return vector<storage::Label>
|
||||
*/
|
||||
antlrcpp::Any visitNodeLabels(CypherParser::NodeLabelsContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return unordered_map<database::Property, Expression*>
|
||||
* @return unordered_map<storage::Property, Expression*>
|
||||
*/
|
||||
antlrcpp::Any visitProperties(CypherParser::PropertiesContext *ctx) override;
|
||||
|
||||
@ -235,7 +235,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor {
|
||||
CypherParser::ListLiteralContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return database::Property
|
||||
* @return storage::Property
|
||||
*/
|
||||
antlrcpp::Any visitPropertyKeyName(
|
||||
CypherParser::PropertyKeyNameContext *ctx) override;
|
||||
@ -290,7 +290,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor {
|
||||
CypherParser::RelationshipLambdaContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return vector<database::EdgeType>
|
||||
* @return vector<storage::EdgeType>
|
||||
*/
|
||||
antlrcpp::Any visitRelationshipTypes(
|
||||
CypherParser::RelationshipTypesContext *ctx) override;
|
||||
|
@ -30,7 +30,7 @@ namespace {
|
||||
// TypedValue cannot be converted to PropertyValue,
|
||||
// QueryRuntimeException is raised.
|
||||
template <class TRecordAccessor>
|
||||
void PropsSetChecked(TRecordAccessor &record, database::Property key,
|
||||
void PropsSetChecked(TRecordAccessor &record, storage::Property key,
|
||||
TypedValue value) {
|
||||
try {
|
||||
record.PropsSet(key, value);
|
||||
@ -273,7 +273,7 @@ std::unique_ptr<Cursor> ScanAll::MakeCursor(
|
||||
}
|
||||
|
||||
ScanAllByLabel::ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, database::Label label,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
GraphView graph_view)
|
||||
: ScanAll(input, output_symbol, graph_view), label_(label) {}
|
||||
|
||||
@ -290,7 +290,7 @@ std::unique_ptr<Cursor> ScanAllByLabel::MakeCursor(
|
||||
|
||||
ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
database::Label label, database::Property property,
|
||||
storage::Label label, storage::Property property,
|
||||
std::experimental::optional<Bound> lower_bound,
|
||||
std::experimental::optional<Bound> upper_bound, GraphView graph_view)
|
||||
: ScanAll(input, output_symbol, graph_view),
|
||||
@ -323,7 +323,7 @@ std::unique_ptr<Cursor> ScanAllByLabelPropertyRange::MakeCursor(
|
||||
|
||||
ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue(
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
database::Label label, database::Property property, Expression *expression,
|
||||
storage::Label label, storage::Property property, Expression *expression,
|
||||
GraphView graph_view)
|
||||
: ScanAll(input, output_symbol, graph_view),
|
||||
label_(label),
|
||||
@ -390,7 +390,7 @@ std::unique_ptr<Cursor> ScanAllByLabelPropertyValue::MakeCursor(
|
||||
|
||||
ExpandCommon::ExpandCommon(Symbol node_symbol, Symbol edge_symbol,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, bool existing_node,
|
||||
GraphView graph_view)
|
||||
@ -558,7 +558,7 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, Context &context) {
|
||||
ExpandVariable::ExpandVariable(
|
||||
Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Type type,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types, bool is_reverse,
|
||||
const std::vector<storage::EdgeType> &edge_types, bool is_reverse,
|
||||
Expression *lower_bound, Expression *upper_bound,
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
bool existing_node, Symbol inner_edge_symbol, Symbol inner_node_symbol,
|
||||
@ -594,7 +594,7 @@ namespace {
|
||||
*/
|
||||
auto ExpandFromVertex(const VertexAccessor &vertex,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types) {
|
||||
const std::vector<storage::EdgeType> &edge_types) {
|
||||
// wraps an EdgeAccessor into a pair <accessor, direction>
|
||||
auto wrapper = [](EdgeAtom::Direction direction, auto &&vertices) {
|
||||
return iter::imap(
|
||||
@ -1388,7 +1388,7 @@ template void SetProperties::SetPropertiesCursor::Set(
|
||||
|
||||
SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol,
|
||||
const std::vector<database::Label> &labels)
|
||||
const std::vector<storage::Label> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(SetLabels)
|
||||
@ -1463,7 +1463,7 @@ void RemoveProperty::RemovePropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol,
|
||||
const std::vector<database::Label> &labels)
|
||||
const std::vector<storage::Label> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(RemoveLabels)
|
||||
@ -2410,7 +2410,7 @@ void Distinct::DistinctCursor::Reset() {
|
||||
seen_rows_.clear();
|
||||
}
|
||||
|
||||
CreateIndex::CreateIndex(database::Label label, database::Property property)
|
||||
CreateIndex::CreateIndex(storage::Label label, storage::Property property)
|
||||
: label_(label), property_(property) {}
|
||||
|
||||
bool CreateIndex::Accept(HierarchicalLogicalOperatorVisitor &visitor) {
|
||||
|
@ -14,12 +14,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "query/common.hpp"
|
||||
#include "query/exceptions.hpp"
|
||||
#include "query/frontend/semantic/symbol_table.hpp"
|
||||
#include "query/path.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/bound.hpp"
|
||||
#include "utils/hashing/fnv.hpp"
|
||||
#include "utils/visitor.hpp"
|
||||
@ -353,16 +353,16 @@ class ScanAll : public LogicalOperator {
|
||||
class ScanAllByLabel : public ScanAll {
|
||||
public:
|
||||
ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, database::Label label,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
GraphView graph_view = GraphView::OLD);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(
|
||||
database::GraphDbAccessor &db) const override;
|
||||
|
||||
database::Label label() const { return label_; }
|
||||
storage::Label label() const { return label_; }
|
||||
|
||||
private:
|
||||
const database::Label label_;
|
||||
const storage::Label label_;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -392,8 +392,8 @@ class ScanAllByLabelPropertyRange : public ScanAll {
|
||||
* @param graph_view GraphView used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyRange(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, database::Label label,
|
||||
database::Property property,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
storage::Property property,
|
||||
std::experimental::optional<Bound> lower_bound,
|
||||
std::experimental::optional<Bound> upper_bound,
|
||||
GraphView graph_view = GraphView::OLD);
|
||||
@ -408,8 +408,8 @@ class ScanAllByLabelPropertyRange : public ScanAll {
|
||||
auto upper_bound() const { return upper_bound_; }
|
||||
|
||||
private:
|
||||
const database::Label label_;
|
||||
const database::Property property_;
|
||||
const storage::Label label_;
|
||||
const storage::Property property_;
|
||||
std::experimental::optional<Bound> lower_bound_;
|
||||
std::experimental::optional<Bound> upper_bound_;
|
||||
};
|
||||
@ -435,8 +435,8 @@ class ScanAllByLabelPropertyValue : public ScanAll {
|
||||
* @param graph_view GraphView used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyValue(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, database::Label label,
|
||||
database::Property property,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
storage::Property property,
|
||||
Expression *expression,
|
||||
GraphView graph_view = GraphView::OLD);
|
||||
|
||||
@ -449,8 +449,8 @@ class ScanAllByLabelPropertyValue : public ScanAll {
|
||||
auto expression() const { return expression_; }
|
||||
|
||||
private:
|
||||
const database::Label label_;
|
||||
const database::Property property_;
|
||||
const storage::Label label_;
|
||||
const storage::Property property_;
|
||||
Expression *expression_;
|
||||
};
|
||||
|
||||
@ -487,7 +487,7 @@ class ExpandCommon {
|
||||
* @param direction EdgeAtom::Direction determining the direction of edge
|
||||
* expansion. The direction is relative to the starting vertex for each
|
||||
* expansion.
|
||||
* @param edge_types database::EdgeType specifying which edges we
|
||||
* @param edge_types storage::EdgeType specifying which edges we
|
||||
* want to expand. If empty, all edges are valid. If not empty, only edges
|
||||
* with one of the given types are valid.
|
||||
* @param input Optional LogicalOperator that preceeds this one.
|
||||
@ -498,7 +498,7 @@ class ExpandCommon {
|
||||
*/
|
||||
ExpandCommon(Symbol node_symbol, Symbol edge_symbol,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, bool existing_node,
|
||||
GraphView graph_view = GraphView::AS_IS);
|
||||
@ -514,7 +514,7 @@ class ExpandCommon {
|
||||
const Symbol node_symbol_;
|
||||
const Symbol edge_symbol_;
|
||||
const EdgeAtom::Direction direction_;
|
||||
const std::vector<database::EdgeType> edge_types_;
|
||||
const std::vector<storage::EdgeType> edge_types_;
|
||||
|
||||
// the input op and the symbol under which the op's result
|
||||
// can be found in the frame
|
||||
@ -639,7 +639,7 @@ class ExpandVariable : public LogicalOperator, public ExpandCommon {
|
||||
*/
|
||||
ExpandVariable(Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Type type,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
bool is_reverse, Expression *lower_bound,
|
||||
Expression *upper_bound,
|
||||
const std::shared_ptr<LogicalOperator> &input,
|
||||
@ -901,7 +901,7 @@ class SetProperties : public LogicalOperator {
|
||||
class SetLabels : public LogicalOperator {
|
||||
public:
|
||||
SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<database::Label> &labels);
|
||||
const std::vector<storage::Label> &labels);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(
|
||||
database::GraphDbAccessor &db) const override;
|
||||
@ -909,7 +909,7 @@ class SetLabels : public LogicalOperator {
|
||||
private:
|
||||
const std::shared_ptr<LogicalOperator> input_;
|
||||
const Symbol input_symbol_;
|
||||
const std::vector<database::Label> labels_;
|
||||
const std::vector<storage::Label> labels_;
|
||||
|
||||
class SetLabelsCursor : public Cursor {
|
||||
public:
|
||||
@ -962,7 +962,7 @@ class RemoveProperty : public LogicalOperator {
|
||||
class RemoveLabels : public LogicalOperator {
|
||||
public:
|
||||
RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, const std::vector<database::Label> &labels);
|
||||
Symbol input_symbol, const std::vector<storage::Label> &labels);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(
|
||||
database::GraphDbAccessor &db) const override;
|
||||
@ -970,7 +970,7 @@ class RemoveLabels : public LogicalOperator {
|
||||
private:
|
||||
const std::shared_ptr<LogicalOperator> input_;
|
||||
const Symbol input_symbol_;
|
||||
const std::vector<database::Label> labels_;
|
||||
const std::vector<storage::Label> labels_;
|
||||
|
||||
class RemoveLabelsCursor : public Cursor {
|
||||
public:
|
||||
@ -1570,7 +1570,7 @@ class Distinct : public LogicalOperator {
|
||||
*/
|
||||
class CreateIndex : public LogicalOperator {
|
||||
public:
|
||||
CreateIndex(database::Label label, database::Property property);
|
||||
CreateIndex(storage::Label label, storage::Property property);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
std::unique_ptr<Cursor> MakeCursor(
|
||||
database::GraphDbAccessor &db) const override;
|
||||
@ -1579,8 +1579,8 @@ class CreateIndex : public LogicalOperator {
|
||||
auto property() const { return property_; }
|
||||
|
||||
private:
|
||||
database::Label label_;
|
||||
database::Property property_;
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -173,8 +173,7 @@ auto SplitExpressionOnAnd(Expression *expression) {
|
||||
} // namespace
|
||||
|
||||
PropertyFilter::PropertyFilter(const SymbolTable &symbol_table,
|
||||
const Symbol &symbol,
|
||||
const database::Property &property,
|
||||
const Symbol &symbol, storage::Property property,
|
||||
Expression *value)
|
||||
: symbol_(symbol), property_(property), value_(value) {
|
||||
UsedSymbolsCollector collector(symbol_table);
|
||||
@ -184,7 +183,7 @@ PropertyFilter::PropertyFilter(const SymbolTable &symbol_table,
|
||||
|
||||
PropertyFilter::PropertyFilter(
|
||||
const SymbolTable &symbol_table, const Symbol &symbol,
|
||||
const database::Property &property,
|
||||
storage::Property property,
|
||||
const std::experimental::optional<PropertyFilter::Bound> &lower_bound,
|
||||
const std::experimental::optional<PropertyFilter::Bound> &upper_bound)
|
||||
: symbol_(symbol),
|
||||
@ -211,8 +210,7 @@ void Filters::EraseFilter(const FilterInfo &filter) {
|
||||
all_filters_.end());
|
||||
}
|
||||
|
||||
void Filters::EraseLabelFilter(const Symbol &symbol,
|
||||
const database::Label &label) {
|
||||
void Filters::EraseLabelFilter(const Symbol &symbol, storage::Label label) {
|
||||
for (auto filter_it = all_filters_.begin();
|
||||
filter_it != all_filters_.end();) {
|
||||
if (filter_it->type != FilterInfo::Type::Label) {
|
||||
|
@ -36,16 +36,15 @@ class PropertyFilter {
|
||||
public:
|
||||
using Bound = ScanAllByLabelPropertyRange::Bound;
|
||||
|
||||
PropertyFilter(const SymbolTable &, const Symbol &,
|
||||
const database::Property &, Expression *);
|
||||
PropertyFilter(const SymbolTable &, const Symbol &,
|
||||
const database::Property &,
|
||||
PropertyFilter(const SymbolTable &, const Symbol &, storage::Property,
|
||||
Expression *);
|
||||
PropertyFilter(const SymbolTable &, const Symbol &, storage::Property,
|
||||
const std::experimental::optional<Bound> &,
|
||||
const std::experimental::optional<Bound> &);
|
||||
|
||||
/// Symbol whose property is looked up.
|
||||
Symbol symbol_;
|
||||
database::Property property_;
|
||||
storage::Property property_;
|
||||
/// True if the same symbol is used in expressions for value or bounds.
|
||||
bool is_symbol_in_value_ = false;
|
||||
/// Expression which when evaluated produces the value a property must
|
||||
@ -70,7 +69,7 @@ struct FilterInfo {
|
||||
/// Set of used symbols by the filter @c expression.
|
||||
std::unordered_set<Symbol> used_symbols;
|
||||
/// Labels for Type::Label filtering.
|
||||
std::vector<database::Label> labels;
|
||||
std::vector<storage::Label> labels;
|
||||
/// Property information for Type::Property filtering.
|
||||
std::experimental::optional<PropertyFilter> property_filter;
|
||||
};
|
||||
@ -101,7 +100,7 @@ class Filters {
|
||||
}
|
||||
|
||||
auto FilteredLabels(const Symbol &symbol) const {
|
||||
std::unordered_set<database::Label> labels;
|
||||
std::unordered_set<storage::Label> labels;
|
||||
for (const auto &filter : all_filters_) {
|
||||
if (filter.type == FilterInfo::Type::Label &&
|
||||
utils::Contains(filter.used_symbols, symbol)) {
|
||||
@ -119,7 +118,7 @@ class Filters {
|
||||
void EraseFilter(const FilterInfo &);
|
||||
|
||||
// Remove a label filter for symbol; may invalidate iterators.
|
||||
void EraseLabelFilter(const Symbol &, const database::Label &);
|
||||
void EraseLabelFilter(const Symbol &, storage::Label);
|
||||
|
||||
// Returns a vector of FilterInfo for properties.
|
||||
auto PropertyFilters(const Symbol &symbol) const {
|
||||
|
@ -196,7 +196,7 @@ class RuleBasedPlanner {
|
||||
TPlanningContext &context_;
|
||||
|
||||
struct LabelPropertyIndex {
|
||||
database::Label label;
|
||||
storage::Label label;
|
||||
// FilterInfo with PropertyFilter.
|
||||
FilterInfo filter;
|
||||
int64_t vertex_count;
|
||||
@ -240,8 +240,8 @@ class RuleBasedPlanner {
|
||||
return found;
|
||||
}
|
||||
|
||||
const database::Label &FindBestLabelIndex(
|
||||
const std::unordered_set<database::Label> &labels) {
|
||||
storage::Label FindBestLabelIndex(
|
||||
const std::unordered_set<storage::Label> &labels) {
|
||||
DCHECK(!labels.empty())
|
||||
<< "Trying to find the best label without any labels.";
|
||||
return *std::min_element(labels.begin(), labels.end(),
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#include <experimental/optional>
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "storage/property_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/bound.hpp"
|
||||
#include "utils/hashing/fnv.hpp"
|
||||
|
||||
@ -22,14 +22,14 @@ class VertexCountCache {
|
||||
return *vertices_count_;
|
||||
}
|
||||
|
||||
int64_t VerticesCount(const database::Label &label) const {
|
||||
int64_t VerticesCount(storage::Label label) const {
|
||||
if (label_vertex_count_.find(label) == label_vertex_count_.end())
|
||||
label_vertex_count_[label] = db_.VerticesCount(label);
|
||||
return label_vertex_count_.at(label);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(const database::Label &label,
|
||||
const database::Property &property) const {
|
||||
int64_t VerticesCount(storage::Label label,
|
||||
storage::Property property) const {
|
||||
auto key = std::make_pair(label, property);
|
||||
if (label_property_vertex_count_.find(key) ==
|
||||
label_property_vertex_count_.end())
|
||||
@ -37,8 +37,7 @@ class VertexCountCache {
|
||||
return label_property_vertex_count_.at(key);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(const database::Label &label,
|
||||
const database::Property &property,
|
||||
int64_t VerticesCount(storage::Label label, storage::Property property,
|
||||
const PropertyValue &value) const {
|
||||
auto label_prop = std::make_pair(label, property);
|
||||
auto &value_vertex_count = property_value_vertex_count_[label_prop];
|
||||
@ -48,7 +47,7 @@ class VertexCountCache {
|
||||
}
|
||||
|
||||
int64_t VerticesCount(
|
||||
const database::Label &label, const database::Property &property,
|
||||
storage::Label label, storage::Property property,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> &lower,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> &upper)
|
||||
const {
|
||||
@ -61,18 +60,18 @@ class VertexCountCache {
|
||||
return bounds_vertex_count.at(bounds);
|
||||
}
|
||||
|
||||
bool LabelPropertyIndexExists(const database::Label &label,
|
||||
const database::Property &property) const {
|
||||
bool LabelPropertyIndexExists(storage::Label label,
|
||||
storage::Property property) const {
|
||||
return db_.LabelPropertyIndexExists(label, property);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::pair<database::Label, database::Property> LabelPropertyKey;
|
||||
typedef std::pair<storage::Label, storage::Property> LabelPropertyKey;
|
||||
|
||||
struct LabelPropertyHash {
|
||||
size_t operator()(const LabelPropertyKey &key) const {
|
||||
return HashCombine<database::Label, database::Property>{}(key.first,
|
||||
key.second);
|
||||
return HashCombine<storage::Label, storage::Property>{}(key.first,
|
||||
key.second);
|
||||
}
|
||||
};
|
||||
|
||||
@ -112,7 +111,7 @@ class VertexCountCache {
|
||||
|
||||
const TDbAccessor &db_;
|
||||
mutable std::experimental::optional<int64_t> vertices_count_;
|
||||
mutable std::unordered_map<database::Label, int64_t> label_vertex_count_;
|
||||
mutable std::unordered_map<storage::Label, int64_t> label_vertex_count_;
|
||||
mutable std::unordered_map<LabelPropertyKey, int64_t, LabelPropertyHash>
|
||||
label_property_vertex_count_;
|
||||
mutable std::unordered_map<
|
||||
|
@ -10,7 +10,7 @@ namespace storage {
|
||||
* for the master (single source of truth) and worker (must query master).
|
||||
* Both implementations must be concurrent.
|
||||
*
|
||||
* @TParam TId - One of database::GraphDb types (Label, EdgeType, Property).
|
||||
* @TParam TId - One of storage types (Label, EdgeType, Property).
|
||||
*/
|
||||
template <typename TId>
|
||||
class ConcurrentIdMapper {
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "storage/concurrent_id_mapper_master.hpp"
|
||||
#include "storage/concurrent_id_mapper_rpc_messages.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
namespace storage {
|
||||
|
||||
@ -22,7 +22,7 @@ void RegisterRpc(MasterConcurrentIdMapper<TId> &mapper,
|
||||
}); \
|
||||
}
|
||||
|
||||
using namespace database;
|
||||
using namespace storage;
|
||||
ID_VALUE_RPC_CALLS(Label)
|
||||
ID_VALUE_RPC_CALLS(EdgeType)
|
||||
ID_VALUE_RPC_CALLS(Property)
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <chrono>
|
||||
|
||||
#include "communication/rpc/rpc.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "transactions/commit_log.hpp"
|
||||
#include "transactions/snapshot.hpp"
|
||||
#include "transactions/type.hpp"
|
||||
@ -16,10 +16,10 @@ const auto kConcurrentIdMapperRpcTimeout = 300ms;
|
||||
|
||||
#define ID_VALUE_RPC(type) \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(type##IdReq, std::string); \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(type##IdRes, database::type); \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(type##IdRes, storage::type); \
|
||||
using type##IdRpc = \
|
||||
communication::rpc::RequestResponse<type##IdReq, type##IdRes>; \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(Id##type##Req, database::type); \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(Id##type##Req, storage::type); \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(Id##type##Res, std::string); \
|
||||
using Id##type##Rpc = \
|
||||
communication::rpc::RequestResponse<Id##type##Req, Id##type##Res>;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "concurrent_id_mapper_worker.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/concurrent_id_mapper_rpc_messages.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
namespace storage {
|
||||
|
||||
@ -24,7 +24,7 @@ namespace storage {
|
||||
return response->member; \
|
||||
}
|
||||
|
||||
using namespace database;
|
||||
using namespace storage;
|
||||
ID_VALUE_RPC_CALLS(Label)
|
||||
ID_VALUE_RPC_CALLS(EdgeType)
|
||||
ID_VALUE_RPC_CALLS(Property)
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/record.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/address.hpp"
|
||||
#include "storage/property_value_store.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
class Vertex;
|
||||
|
||||
@ -12,7 +12,7 @@ class Edge : public mvcc::Record<Edge> {
|
||||
using VertexAddress = storage::Address<mvcc::VersionList<Vertex>>;
|
||||
|
||||
public:
|
||||
Edge(VertexAddress from, VertexAddress to, database::EdgeType edge_type)
|
||||
Edge(VertexAddress from, VertexAddress to, storage::EdgeType edge_type)
|
||||
: from_(from), to_(to), edge_type_(edge_type) {}
|
||||
|
||||
// Returns new Edge with copy of data stored in this Edge, but without
|
||||
@ -21,7 +21,7 @@ class Edge : public mvcc::Record<Edge> {
|
||||
|
||||
VertexAddress from_;
|
||||
VertexAddress to_;
|
||||
database::EdgeType edge_type_;
|
||||
storage::EdgeType edge_type_;
|
||||
PropertyValueStore properties_;
|
||||
|
||||
private:
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "storage/vertex_accessor.hpp"
|
||||
#include "utils/algorithm.hpp"
|
||||
|
||||
database::EdgeType EdgeAccessor::EdgeType() const { return edge_type_; }
|
||||
storage::EdgeType EdgeAccessor::EdgeType() const { return edge_type_; }
|
||||
|
||||
VertexAccessor EdgeAccessor::from() const {
|
||||
return VertexAccessor(from_, db_accessor());
|
||||
|
@ -42,13 +42,13 @@ class EdgeAccessor : public RecordAccessor<Edge> {
|
||||
* performance, see class docs). */
|
||||
EdgeAccessor(EdgeAddress address, database::GraphDbAccessor &db_accessor,
|
||||
VertexAddress from, VertexAddress to,
|
||||
database::EdgeType edge_type)
|
||||
storage::EdgeType edge_type)
|
||||
: RecordAccessor(address, db_accessor),
|
||||
from_(from),
|
||||
to_(to),
|
||||
edge_type_(edge_type) {}
|
||||
|
||||
database::EdgeType EdgeType() const;
|
||||
storage::EdgeType EdgeType() const;
|
||||
|
||||
/** Returns an accessor to the originating Vertex of this edge. */
|
||||
VertexAccessor from() const;
|
||||
@ -71,7 +71,7 @@ class EdgeAccessor : public RecordAccessor<Edge> {
|
||||
private:
|
||||
VertexAddress from_;
|
||||
VertexAddress to_;
|
||||
database::EdgeType edge_type_;
|
||||
storage::EdgeType edge_type_;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &, const EdgeAccessor &);
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/address.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/algorithm.hpp"
|
||||
|
||||
// forward declare Vertex and Edge because they need this data structure
|
||||
@ -28,7 +28,7 @@ class Edges {
|
||||
struct Element {
|
||||
VertexAddress vertex;
|
||||
EdgeAddress edge;
|
||||
database::EdgeType edge_type;
|
||||
storage::EdgeType edge_type;
|
||||
};
|
||||
|
||||
/** Custom iterator that takes care of skipping edges when the destination
|
||||
@ -56,7 +56,7 @@ class Edges {
|
||||
*/
|
||||
Iterator(std::vector<Element>::const_iterator position,
|
||||
std::vector<Element>::const_iterator end, VertexAddress vertex,
|
||||
const std::vector<database::EdgeType> *edge_types)
|
||||
const std::vector<storage::EdgeType> *edge_types)
|
||||
: position_(position),
|
||||
end_(end),
|
||||
vertex_(vertex),
|
||||
@ -88,7 +88,7 @@ class Edges {
|
||||
// iterator. Only one can be not-null in the current implementation.
|
||||
VertexAddress vertex_{nullptr};
|
||||
// For edge types we use a vector pointer because it's optional.
|
||||
const std::vector<database::EdgeType> *edge_types_ = nullptr;
|
||||
const std::vector<storage::EdgeType> *edge_types_ = nullptr;
|
||||
|
||||
/** Helper function that skips edges that don't satisfy the predicate
|
||||
* present in this iterator. */
|
||||
@ -116,7 +116,7 @@ class Edges {
|
||||
* @param edge_type - Type of the edge.
|
||||
*/
|
||||
void emplace(VertexAddress vertex, EdgeAddress edge,
|
||||
database::EdgeType edge_type) {
|
||||
storage::EdgeType edge_type) {
|
||||
storage_.emplace_back(Element{vertex, edge, edge_type});
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class Edges {
|
||||
* If nullptr edges are not filtered on type.
|
||||
*/
|
||||
auto begin(VertexAddress vertex,
|
||||
const std::vector<database::EdgeType> *edge_types) const {
|
||||
const std::vector<storage::EdgeType> *edge_types) const {
|
||||
if (edge_types && edge_types->empty()) edge_types = nullptr;
|
||||
return Iterator(storage_.begin(), storage_.end(), vertex, edge_types);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "property_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
/**
|
||||
* A collection of properties accessed in a map-like way
|
||||
@ -14,7 +14,7 @@
|
||||
* The underlying implementation is not necessarily std::map.
|
||||
*/
|
||||
class PropertyValueStore {
|
||||
using Property = database::Property;
|
||||
using Property = storage::Property;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -14,12 +14,12 @@ RecordAccessor<TRecord>::RecordAccessor(AddressT address,
|
||||
|
||||
template <typename TRecord>
|
||||
const PropertyValue &RecordAccessor<TRecord>::PropsAt(
|
||||
database::Property key) const {
|
||||
storage::Property key) const {
|
||||
return current().properties_.at(key);
|
||||
}
|
||||
|
||||
template <>
|
||||
void RecordAccessor<Vertex>::PropsSet(database::Property key,
|
||||
void RecordAccessor<Vertex>::PropsSet(storage::Property key,
|
||||
PropertyValue value) {
|
||||
Vertex &vertex = update();
|
||||
vertex.properties_.set(key, value);
|
||||
@ -33,7 +33,7 @@ void RecordAccessor<Vertex>::PropsSet(database::Property key,
|
||||
}
|
||||
|
||||
template <>
|
||||
void RecordAccessor<Edge>::PropsSet(database::Property key,
|
||||
void RecordAccessor<Edge>::PropsSet(storage::Property key,
|
||||
PropertyValue value) {
|
||||
update().properties_.set(key, value);
|
||||
auto &dba = db_accessor();
|
||||
@ -43,7 +43,7 @@ void RecordAccessor<Edge>::PropsSet(database::Property key,
|
||||
}
|
||||
|
||||
template <>
|
||||
size_t RecordAccessor<Vertex>::PropsErase(database::Property key) {
|
||||
size_t RecordAccessor<Vertex>::PropsErase(storage::Property key) {
|
||||
auto &dba = db_accessor();
|
||||
// TODO use the delta for handling.
|
||||
dba.wal().Emplace(StateDelta::PropsSetVertex(
|
||||
@ -52,7 +52,7 @@ size_t RecordAccessor<Vertex>::PropsErase(database::Property key) {
|
||||
}
|
||||
|
||||
template <>
|
||||
size_t RecordAccessor<Edge>::PropsErase(database::Property key) {
|
||||
size_t RecordAccessor<Edge>::PropsErase(storage::Property key) {
|
||||
auto &dba = db_accessor();
|
||||
// TODO use the delta for handling.
|
||||
dba.wal().Emplace(StateDelta::PropsSetEdge(
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/address.hpp"
|
||||
#include "storage/gid.hpp"
|
||||
#include "storage/property_value.hpp"
|
||||
#include "storage/property_value_store.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/total_ordering.hpp"
|
||||
|
||||
namespace database {
|
||||
@ -68,13 +68,13 @@ class RecordAccessor : public TotalOrdering<RecordAccessor<TRecord>> {
|
||||
RecordAccessor &operator=(RecordAccessor &&other) = default;
|
||||
|
||||
/** Gets the property for the given key. */
|
||||
const PropertyValue &PropsAt(database::Property key) const;
|
||||
const PropertyValue &PropsAt(storage::Property key) const;
|
||||
|
||||
/** Sets a value on the record for the given property. */
|
||||
void PropsSet(database::Property key, PropertyValue value);
|
||||
void PropsSet(storage::Property key, PropertyValue value);
|
||||
|
||||
/** Erases the property for the given key. */
|
||||
size_t PropsErase(database::Property key);
|
||||
size_t PropsErase(storage::Property key);
|
||||
|
||||
/** Removes all the properties from this record. */
|
||||
void PropsClear();
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "utils/total_ordering.hpp"
|
||||
|
||||
namespace database {
|
||||
namespace storage {
|
||||
|
||||
template <typename TSpecificType>
|
||||
class Common : public TotalOrdering<TSpecificType> {
|
||||
@ -74,18 +74,17 @@ class Property : public Common<Property> {
|
||||
ar &boost::serialization::base_object<Common<Property>>(*this);
|
||||
}
|
||||
};
|
||||
}; // namespace database
|
||||
}; // namespace storage
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<database::Label> : public database::Common<database::Label>::Hash {
|
||||
};
|
||||
struct hash<storage::Label> : public storage::Common<storage::Label>::Hash {};
|
||||
template <>
|
||||
struct hash<database::EdgeType>
|
||||
: public database::Common<database::EdgeType>::Hash {};
|
||||
struct hash<storage::EdgeType>
|
||||
: public storage::Common<storage::EdgeType>::Hash {};
|
||||
template <>
|
||||
struct hash<database::Property>
|
||||
: public database::Common<database::Property>::Hash {};
|
||||
struct hash<storage::Property>
|
||||
: public storage::Common<storage::Property>::Hash {};
|
||||
|
||||
} // namespace std
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/record.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/address.hpp"
|
||||
#include "storage/edges.hpp"
|
||||
#include "storage/property_value_store.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
class Vertex : public mvcc::Record<Vertex> {
|
||||
public:
|
||||
@ -16,7 +16,7 @@ class Vertex : public mvcc::Record<Vertex> {
|
||||
|
||||
Edges out_;
|
||||
Edges in_;
|
||||
std::vector<database::Label> labels_;
|
||||
std::vector<storage::Label> labels_;
|
||||
PropertyValueStore properties_;
|
||||
|
||||
private:
|
||||
|
@ -9,7 +9,7 @@ size_t VertexAccessor::out_degree() const { return current().out_.size(); }
|
||||
|
||||
size_t VertexAccessor::in_degree() const { return current().in_.size(); }
|
||||
|
||||
bool VertexAccessor::add_label(database::Label label) {
|
||||
bool VertexAccessor::add_label(storage::Label label) {
|
||||
auto &labels_view = current().labels_;
|
||||
auto found = std::find(labels_view.begin(), labels_view.end(), label);
|
||||
if (found != labels_view.end()) return false;
|
||||
@ -25,7 +25,7 @@ bool VertexAccessor::add_label(database::Label label) {
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t VertexAccessor::remove_label(database::Label label) {
|
||||
size_t VertexAccessor::remove_label(storage::Label label) {
|
||||
auto &labels = update().labels_;
|
||||
auto found = std::find(labels.begin(), labels.end(), label);
|
||||
if (found == labels.end()) return 0;
|
||||
@ -39,12 +39,12 @@ size_t VertexAccessor::remove_label(database::Label label) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool VertexAccessor::has_label(database::Label label) const {
|
||||
bool VertexAccessor::has_label(storage::Label label) const {
|
||||
auto &labels = this->current().labels_;
|
||||
return std::find(labels.begin(), labels.end(), label) != labels.end();
|
||||
}
|
||||
|
||||
const std::vector<database::Label> &VertexAccessor::labels() const {
|
||||
const std::vector<storage::Label> &VertexAccessor::labels() const {
|
||||
return this->current().labels_;
|
||||
}
|
||||
|
||||
|
@ -63,17 +63,17 @@ class VertexAccessor : public RecordAccessor<Vertex> {
|
||||
/** Adds a label to the Vertex. If the Vertex already has that label the call
|
||||
* has no effect. */
|
||||
// TODO revise return value, is it necessary?
|
||||
bool add_label(database::Label label);
|
||||
bool add_label(storage::Label label);
|
||||
|
||||
/** Removes a label from the Vertex. Return number of removed (0, 1). */
|
||||
// TODO reves return value, is it necessary?
|
||||
size_t remove_label(database::Label label);
|
||||
size_t remove_label(storage::Label label);
|
||||
|
||||
/** Indicates if the Vertex has the given label. */
|
||||
bool has_label(database::Label label) const;
|
||||
bool has_label(storage::Label label) const;
|
||||
|
||||
/** Returns all the Labels of the Vertex. */
|
||||
const std::vector<database::Label> &labels() const;
|
||||
const std::vector<storage::Label> &labels() const;
|
||||
|
||||
/** Returns EdgeAccessors for all incoming edges. */
|
||||
auto in() const {
|
||||
@ -89,7 +89,7 @@ class VertexAccessor : public RecordAccessor<Vertex> {
|
||||
* or empty, the parameter is ignored.
|
||||
*/
|
||||
auto in(const VertexAccessor &dest,
|
||||
const std::vector<database::EdgeType> *edge_types = nullptr) const {
|
||||
const std::vector<storage::EdgeType> *edge_types = nullptr) const {
|
||||
return MakeAccessorIterator(current().in_.begin(dest.address(), edge_types),
|
||||
current().in_.end(), false, address(),
|
||||
db_accessor());
|
||||
@ -101,7 +101,7 @@ class VertexAccessor : public RecordAccessor<Vertex> {
|
||||
* @param edge_types - Edge types filter. At least one be matched. If nullptr
|
||||
* or empty, the parameter is ignored.
|
||||
*/
|
||||
auto in(const std::vector<database::EdgeType> *edge_types) const {
|
||||
auto in(const std::vector<storage::EdgeType> *edge_types) const {
|
||||
return MakeAccessorIterator(current().in_.begin(nullptr, edge_types),
|
||||
current().in_.end(), false, address(),
|
||||
db_accessor());
|
||||
@ -122,7 +122,7 @@ class VertexAccessor : public RecordAccessor<Vertex> {
|
||||
* or empty, the parameter is ignored.
|
||||
*/
|
||||
auto out(const VertexAccessor &dest,
|
||||
const std::vector<database::EdgeType> *edge_types = nullptr) const {
|
||||
const std::vector<storage::EdgeType> *edge_types = nullptr) const {
|
||||
return MakeAccessorIterator(
|
||||
current().out_.begin(dest.address(), edge_types), current().out_.end(),
|
||||
true, address(), db_accessor());
|
||||
@ -134,7 +134,7 @@ class VertexAccessor : public RecordAccessor<Vertex> {
|
||||
* @param edge_types - Edge types filter. At least one be matched. If nullptr
|
||||
* or empty, the parameter is ignored.
|
||||
*/
|
||||
auto out(const std::vector<database::EdgeType> *edge_types) const {
|
||||
auto out(const std::vector<storage::EdgeType> *edge_types) const {
|
||||
return MakeAccessorIterator(current().out_.begin(nullptr, edge_types),
|
||||
current().out_.end(), true, address(),
|
||||
db_accessor());
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include "data_structures/concurrent/skiplist.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "storage/property_value.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex_accessor.hpp"
|
||||
#include "threading/sync/lock_timeout_exception.hpp"
|
||||
|
||||
@ -62,7 +62,7 @@ class RandomGraphGenerator {
|
||||
void AddVertices(int count, const std::vector<std::string> &label_names,
|
||||
int thread_count, int batch_size = 2000) {
|
||||
database::GraphDbAccessor dba(db_);
|
||||
std::vector<database::Label> labels;
|
||||
std::vector<storage::Label> labels;
|
||||
for (const auto &label_name : label_names)
|
||||
labels.push_back(dba.Label(label_name));
|
||||
|
||||
|
@ -62,8 +62,8 @@ BENCHMARK(BM_PlanChainedMatches)
|
||||
->Unit(benchmark::kMillisecond);
|
||||
|
||||
static void AddIndexedMatches(
|
||||
int num_matches, const database::Label &label,
|
||||
const std::pair<std::string, database::Property> &property,
|
||||
int num_matches, storage::Label label,
|
||||
const std::pair<std::string, storage::Property> &property,
|
||||
query::AstTreeStorage &storage) {
|
||||
for (int i = 0; i < num_matches; ++i) {
|
||||
auto *match = storage.Create<query::Match>();
|
||||
@ -101,8 +101,8 @@ static auto CreateIndexedVertices(int index_count, int vertex_count,
|
||||
|
||||
static void BM_PlanAndEstimateIndexedMatching(benchmark::State &state) {
|
||||
database::SingleNode db;
|
||||
database::Label label;
|
||||
database::Property prop;
|
||||
storage::Label label;
|
||||
storage::Property prop;
|
||||
int index_count = state.range(0);
|
||||
int vertex_count = state.range(1);
|
||||
std::tie(label, prop) = CreateIndexedVertices(index_count, vertex_count, db);
|
||||
@ -134,8 +134,8 @@ static void BM_PlanAndEstimateIndexedMatching(benchmark::State &state) {
|
||||
static void BM_PlanAndEstimateIndexedMatchingWithCachedCounts(
|
||||
benchmark::State &state) {
|
||||
database::SingleNode db;
|
||||
database::Label label;
|
||||
database::Property prop;
|
||||
storage::Label label;
|
||||
storage::Property prop;
|
||||
int index_count = state.range(0);
|
||||
int vertex_count = state.range(1);
|
||||
std::tie(label, prop) = CreateIndexedVertices(index_count, vertex_count, db);
|
||||
|
@ -140,7 +140,7 @@ class InteractiveDbAccessor {
|
||||
|
||||
int64_t VerticesCount() const { return vertices_count_; }
|
||||
|
||||
int64_t VerticesCount(const database::Label &label_id) const {
|
||||
int64_t VerticesCount(storage::Label label_id) const {
|
||||
auto label = dba_.LabelName(label_id);
|
||||
if (label_vertex_count_.find(label) == label_vertex_count_.end()) {
|
||||
label_vertex_count_[label] = ReadVertexCount("label '" + label + "'");
|
||||
@ -148,8 +148,8 @@ class InteractiveDbAccessor {
|
||||
return label_vertex_count_.at(label);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(const database::Label &label_id,
|
||||
const database::Property &property_id) const {
|
||||
int64_t VerticesCount(storage::Label label_id,
|
||||
storage::Property property_id) const {
|
||||
auto label = dba_.LabelName(label_id);
|
||||
auto property = dba_.PropertyName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
@ -161,8 +161,7 @@ class InteractiveDbAccessor {
|
||||
return label_property_vertex_count_.at(key);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(const database::Label &label_id,
|
||||
const database::Property &property_id,
|
||||
int64_t VerticesCount(storage::Label label_id, storage::Property property_id,
|
||||
const PropertyValue &value) const {
|
||||
auto label = dba_.LabelName(label_id);
|
||||
auto property = dba_.PropertyName(property_id);
|
||||
@ -182,7 +181,7 @@ class InteractiveDbAccessor {
|
||||
}
|
||||
|
||||
int64_t VerticesCount(
|
||||
const database::Label &label_id, const database::Property &property_id,
|
||||
storage::Label label_id, storage::Property property_id,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::experimental::optional<utils::Bound<PropertyValue>> upper)
|
||||
const {
|
||||
@ -202,8 +201,8 @@ class InteractiveDbAccessor {
|
||||
"' in range " + range_string.str());
|
||||
}
|
||||
|
||||
bool LabelPropertyIndexExists(const database::Label &label_id,
|
||||
const database::Property &property_id) const {
|
||||
bool LabelPropertyIndexExists(storage::Label label_id,
|
||||
storage::Property property_id) const {
|
||||
auto label = dba_.LabelName(label_id);
|
||||
auto property = dba_.PropertyName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
|
@ -3,23 +3,21 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "communication/messaging/distributed.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/concurrent_id_mapper_master.hpp"
|
||||
#include "storage/concurrent_id_mapper_worker.hpp"
|
||||
|
||||
using namespace communication::messaging;
|
||||
using namespace storage;
|
||||
using namespace database;
|
||||
#include "storage/types.hpp"
|
||||
|
||||
template <typename TId>
|
||||
class DistributedConcurrentIdMapperTest : public ::testing::Test {
|
||||
const std::string kLocal{"127.0.0.1"};
|
||||
|
||||
protected:
|
||||
System master_system_{{kLocal, 0}};
|
||||
std::experimental::optional<MasterConcurrentIdMapper<TId>> master_mapper_;
|
||||
System worker_system_{{kLocal, 0}};
|
||||
std::experimental::optional<WorkerConcurrentIdMapper<TId>> worker_mapper_;
|
||||
communication::messaging::System master_system_{{kLocal, 0}};
|
||||
std::experimental::optional<storage::MasterConcurrentIdMapper<TId>>
|
||||
master_mapper_;
|
||||
communication::messaging::System worker_system_{{kLocal, 0}};
|
||||
std::experimental::optional<storage::WorkerConcurrentIdMapper<TId>>
|
||||
worker_mapper_;
|
||||
|
||||
void SetUp() override {
|
||||
master_mapper_.emplace(master_system_);
|
||||
@ -31,7 +29,8 @@ class DistributedConcurrentIdMapperTest : public ::testing::Test {
|
||||
}
|
||||
};
|
||||
|
||||
typedef ::testing::Types<Label, EdgeType, Property> GraphDbTestTypes;
|
||||
typedef ::testing::Types<storage::Label, storage::EdgeType, storage::Property>
|
||||
GraphDbTestTypes;
|
||||
TYPED_TEST_CASE(DistributedConcurrentIdMapperTest, GraphDbTestTypes);
|
||||
|
||||
TYPED_TEST(DistributedConcurrentIdMapperTest, Basic) {
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "storage/concurrent_id_mapper_single_node.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
using Id = database::Label;
|
||||
using Id = storage::Label;
|
||||
using Mapper = storage::SingleNodeConcurrentIdMapper<Id>;
|
||||
|
||||
TEST(ConcurrentIdMapper, SameValueGivesSameId) {
|
||||
|
@ -889,7 +889,7 @@ TYPED_TEST(CypherMainVisitorTest, NodePattern) {
|
||||
UnorderedElementsAre(ast_generator.db_accessor_.Label("label1"),
|
||||
ast_generator.db_accessor_.Label("label2"),
|
||||
ast_generator.db_accessor_.Label("label3")));
|
||||
std::map<std::pair<std::string, database::Property>, int64_t> properties;
|
||||
std::map<std::pair<std::string, storage::Property>, int64_t> properties;
|
||||
for (auto x : node->properties_) {
|
||||
TypedValue value = LiteralValue(ast_generator.context_, x.second);
|
||||
ASSERT_TRUE(value.type() == TypedValue::Type::Int);
|
||||
@ -989,7 +989,7 @@ TYPED_TEST(CypherMainVisitorTest, RelationshipPatternDetails) {
|
||||
edge->edge_types_,
|
||||
UnorderedElementsAre(ast_generator.db_accessor_.EdgeType("type1"),
|
||||
ast_generator.db_accessor_.EdgeType("type2")));
|
||||
std::map<std::pair<std::string, database::Property>, int64_t> properties;
|
||||
std::map<std::pair<std::string, storage::Property>, int64_t> properties;
|
||||
for (auto x : edge->properties_) {
|
||||
TypedValue value = LiteralValue(ast_generator.context_, x.second);
|
||||
ASSERT_TRUE(value.type() == TypedValue::Type::Int);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
#include "transactions/engine_single_node.hpp"
|
||||
|
||||
@ -13,7 +13,7 @@ using testing::UnorderedElementsAreArray;
|
||||
|
||||
// Test index does it insert everything uniquely
|
||||
TEST(LabelsIndex, UniqueInsert) {
|
||||
database::KeyIndex<database::Label, Vertex> index;
|
||||
database::KeyIndex<storage::Label, Vertex> index;
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba(db);
|
||||
tx::SingleNodeEngine engine;
|
||||
@ -43,7 +43,7 @@ TEST(LabelsIndex, UniqueInsert) {
|
||||
// Check if index filters duplicates.
|
||||
TEST(LabelsIndex, UniqueFilter) {
|
||||
database::SingleNode db;
|
||||
database::KeyIndex<database::Label, Vertex> index;
|
||||
database::KeyIndex<storage::Label, Vertex> index;
|
||||
database::GraphDbAccessor dba(db);
|
||||
tx::SingleNodeEngine engine;
|
||||
|
||||
@ -82,7 +82,7 @@ TEST(LabelsIndex, UniqueFilter) {
|
||||
|
||||
// Delete not anymore relevant recods from index.
|
||||
TEST(LabelsIndex, Refresh) {
|
||||
database::KeyIndex<database::Label, Vertex> index;
|
||||
database::KeyIndex<storage::Label, Vertex> index;
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor access(db);
|
||||
tx::SingleNodeEngine engine;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/indexes/label_property_index.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
#include "mvcc_gc_common.hpp"
|
||||
|
||||
@ -51,10 +51,10 @@ class LabelPropertyIndexComplexTest : public ::testing::Test {
|
||||
mvcc::VersionList<Vertex> *vlist;
|
||||
Vertex *vertex;
|
||||
|
||||
Label label;
|
||||
Property property;
|
||||
Label label2;
|
||||
Property property2;
|
||||
storage::Label label;
|
||||
storage::Property property;
|
||||
storage::Label label2;
|
||||
storage::Property property2;
|
||||
};
|
||||
|
||||
TEST(LabelPropertyIndex, CreateIndex) {
|
||||
|
@ -4,16 +4,16 @@
|
||||
#include "boost/archive/binary_iarchive.hpp"
|
||||
#include "boost/archive/binary_oarchive.hpp"
|
||||
|
||||
#include "database/types.hpp"
|
||||
#include "distributed/serialization.hpp"
|
||||
#include "mvcc/version_list.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/edge.hpp"
|
||||
#include "storage/property_value_store.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex.hpp"
|
||||
#include "transactions/engine_single_node.hpp"
|
||||
|
||||
using namespace database;
|
||||
using namespace storage;
|
||||
|
||||
template <typename TAddress>
|
||||
TAddress ToGlobal(const TAddress &address, int worker_id) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/indexes/label_property_index.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "storage/types.hpp"
|
||||
|
||||
TEST(GraphDbTest, GarbageCollectIndices) {
|
||||
database::Config config;
|
||||
|
@ -3,11 +3,12 @@
|
||||
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
|
||||
#include "storage/edge_accessor.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "storage/vertex_accessor.hpp"
|
||||
|
||||
using namespace database;
|
||||
using namespace storage;
|
||||
|
||||
template <typename TIterable>
|
||||
auto Count(TIterable iterable) {
|
||||
|
@ -24,9 +24,9 @@ class GraphDbAccessorIndex : public testing::Test {
|
||||
protected:
|
||||
database::SingleNode db;
|
||||
std::experimental::optional<database::GraphDbAccessor> dba{db};
|
||||
database::Property property = dba->Property("property");
|
||||
database::Label label = dba->Label("label");
|
||||
database::EdgeType edge_type = dba->EdgeType("edge_type");
|
||||
storage::Property property = dba->Property("property");
|
||||
storage::Label label = dba->Label("label");
|
||||
storage::EdgeType edge_type = dba->EdgeType("edge_type");
|
||||
|
||||
auto AddVertex() {
|
||||
auto vertex = dba->InsertVertex();
|
||||
|
@ -12,12 +12,12 @@ class PropertyValueStoreTest : public ::testing::Test {
|
||||
PropertyValueStore props_;
|
||||
|
||||
void Set(int key, PropertyValue value) {
|
||||
props_.set(database::Property(key), value);
|
||||
props_.set(storage::Property(key), value);
|
||||
}
|
||||
|
||||
PropertyValue At(int key) { return props_.at(database::Property(key)); }
|
||||
PropertyValue At(int key) { return props_.at(storage::Property(key)); }
|
||||
|
||||
auto Erase(int key) { return props_.erase(database::Property(key)); }
|
||||
auto Erase(int key) { return props_.erase(storage::Property(key)); }
|
||||
};
|
||||
|
||||
TEST_F(PropertyValueStoreTest, At) {
|
||||
|
@ -30,9 +30,9 @@
|
||||
|
||||
#include "database/graph_db.hpp"
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "query/frontend/ast/ast.hpp"
|
||||
#include "query/interpret/awesome_memgraph_functions.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace query {
|
||||
@ -110,26 +110,26 @@ auto GetOrderBy(T... exprs) {
|
||||
/// Name is used to create the Identifier which is used for property lookup.
|
||||
///
|
||||
auto GetPropertyLookup(AstTreeStorage &storage, database::GraphDb &db,
|
||||
const std::string &name, database::Property property) {
|
||||
const std::string &name, storage::Property property) {
|
||||
database::GraphDbAccessor dba(db);
|
||||
return storage.Create<PropertyLookup>(storage.Create<Identifier>(name),
|
||||
dba.PropertyName(property), property);
|
||||
}
|
||||
auto GetPropertyLookup(AstTreeStorage &storage, database::GraphDb &db,
|
||||
Expression *expr, database::Property property) {
|
||||
Expression *expr, storage::Property property) {
|
||||
database::GraphDbAccessor dba(db);
|
||||
return storage.Create<PropertyLookup>(expr, dba.PropertyName(property),
|
||||
property);
|
||||
}
|
||||
auto GetPropertyLookup(
|
||||
AstTreeStorage &storage, database::GraphDb &, const std::string &name,
|
||||
const std::pair<std::string, database::Property> &prop_pair) {
|
||||
const std::pair<std::string, storage::Property> &prop_pair) {
|
||||
return storage.Create<PropertyLookup>(storage.Create<Identifier>(name),
|
||||
prop_pair.first, prop_pair.second);
|
||||
}
|
||||
auto GetPropertyLookup(
|
||||
AstTreeStorage &storage, database::GraphDb &, Expression *expr,
|
||||
const std::pair<std::string, database::Property> &prop_pair) {
|
||||
const std::pair<std::string, storage::Property> &prop_pair) {
|
||||
return storage.Create<PropertyLookup>(expr, prop_pair.first,
|
||||
prop_pair.second);
|
||||
}
|
||||
@ -141,7 +141,7 @@ auto GetPropertyLookup(
|
||||
///
|
||||
auto GetEdge(AstTreeStorage &storage, const std::string &name,
|
||||
EdgeAtom::Direction dir = EdgeAtom::Direction::BOTH,
|
||||
const std::vector<database::EdgeType> &edge_types = {}) {
|
||||
const std::vector<storage::EdgeType> &edge_types = {}) {
|
||||
return storage.Create<EdgeAtom>(storage.Create<Identifier>(name),
|
||||
EdgeAtom::Type::SINGLE, dir, edge_types);
|
||||
}
|
||||
@ -154,7 +154,7 @@ auto GetEdge(AstTreeStorage &storage, const std::string &name,
|
||||
///
|
||||
auto GetEdgeVariable(AstTreeStorage &storage, const std::string &name,
|
||||
EdgeAtom::Direction dir = EdgeAtom::Direction::BOTH,
|
||||
const std::vector<database::EdgeType> &edge_types = {},
|
||||
const std::vector<storage::EdgeType> &edge_types = {},
|
||||
Identifier *inner_edge = nullptr,
|
||||
Identifier *inner_node = nullptr) {
|
||||
auto r_val =
|
||||
@ -175,7 +175,7 @@ auto GetEdgeVariable(AstTreeStorage &storage, const std::string &name,
|
||||
/// Name is used to create the Identifier which is assigned to the node.
|
||||
///
|
||||
auto GetNode(AstTreeStorage &storage, const std::string &name,
|
||||
std::experimental::optional<database::Label> label =
|
||||
std::experimental::optional<storage::Label> label =
|
||||
std::experimental::nullopt) {
|
||||
auto node = storage.Create<NodeAtom>(storage.Create<Identifier>(name));
|
||||
if (label) node->labels_.emplace_back(*label);
|
||||
@ -433,7 +433,7 @@ auto GetSet(AstTreeStorage &storage, const std::string &name, Expression *expr,
|
||||
/// Create a set labels clause for given identifier name and labels.
|
||||
///
|
||||
auto GetSet(AstTreeStorage &storage, const std::string &name,
|
||||
std::vector<database::Label> labels) {
|
||||
std::vector<storage::Label> labels) {
|
||||
return storage.Create<SetLabels>(storage.Create<Identifier>(name), labels);
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ auto GetRemove(AstTreeStorage &storage, PropertyLookup *prop_lookup) {
|
||||
/// Create a remove labels clause for given identifier name and labels.
|
||||
///
|
||||
auto GetRemove(AstTreeStorage &storage, const std::string &name,
|
||||
std::vector<database::Label> labels) {
|
||||
std::vector<storage::Label> labels) {
|
||||
return storage.Create<RemoveLabels>(storage.Create<Identifier>(name), labels);
|
||||
}
|
||||
|
||||
@ -510,9 +510,9 @@ auto GetMerge(AstTreeStorage &storage, Pattern *pattern, OnMatch on_match,
|
||||
#define LIST(...) \
|
||||
storage.Create<query::ListLiteral>( \
|
||||
std::vector<query::Expression *>{__VA_ARGS__})
|
||||
#define MAP(...) \
|
||||
storage.Create<query::MapLiteral>( \
|
||||
std::unordered_map<std::pair<std::string, database::Property>, \
|
||||
#define MAP(...) \
|
||||
storage.Create<query::MapLiteral>( \
|
||||
std::unordered_map<std::pair<std::string, storage::Property>, \
|
||||
query::Expression *>{__VA_ARGS__})
|
||||
#define PROPERTY_PAIR(property_name) \
|
||||
std::make_pair(property_name, \
|
||||
|
@ -23,8 +23,8 @@ class QueryCostEstimator : public ::testing::Test {
|
||||
protected:
|
||||
database::SingleNode db;
|
||||
std::experimental::optional<database::GraphDbAccessor> dba{db};
|
||||
database::Label label = dba->Label("label");
|
||||
database::Property property = dba->Property("property");
|
||||
storage::Label label = dba->Label("label");
|
||||
storage::Property property = dba->Property("property");
|
||||
|
||||
// we incrementally build the logical operator plan
|
||||
// start it off with Once
|
||||
@ -162,7 +162,7 @@ TEST_F(QueryCostEstimator, ScanAllByLabelPropertyRangeConstExpr) {
|
||||
|
||||
TEST_F(QueryCostEstimator, Expand) {
|
||||
MakeOp<Expand>(NextSymbol(), NextSymbol(), EdgeAtom::Direction::IN,
|
||||
std::vector<database::EdgeType>{}, last_op_, NextSymbol(),
|
||||
std::vector<storage::EdgeType>{}, last_op_, NextSymbol(),
|
||||
false);
|
||||
EXPECT_COST(CardParam::kExpand * CostParam::kExpand);
|
||||
}
|
||||
@ -170,7 +170,7 @@ TEST_F(QueryCostEstimator, Expand) {
|
||||
TEST_F(QueryCostEstimator, ExpandVariable) {
|
||||
MakeOp<ExpandVariable>(NextSymbol(), NextSymbol(),
|
||||
EdgeAtom::Type::DEPTH_FIRST, EdgeAtom::Direction::IN,
|
||||
std::vector<database::EdgeType>{}, false, nullptr,
|
||||
std::vector<storage::EdgeType>{}, false, nullptr,
|
||||
nullptr, last_op_, NextSymbol(), false, NextSymbol(),
|
||||
NextSymbol(), nullptr);
|
||||
EXPECT_COST(CardParam::kExpandVariable * CostParam::kExpandVariable);
|
||||
|
@ -8,13 +8,13 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/types.hpp"
|
||||
#include "query/frontend/ast/ast.hpp"
|
||||
#include "query/frontend/opencypher/parser.hpp"
|
||||
#include "query/interpret/awesome_memgraph_functions.hpp"
|
||||
#include "query/interpret/eval.hpp"
|
||||
#include "query/interpret/frame.hpp"
|
||||
#include "query/path.hpp"
|
||||
#include "storage/types.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
#include "query_common.hpp"
|
||||
@ -419,7 +419,7 @@ TEST(ExpressionEvaluator, MapIndexing) {
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba(db);
|
||||
auto *map_literal = storage.Create<MapLiteral>(
|
||||
std::unordered_map<std::pair<std::string, database::Property>,
|
||||
std::unordered_map<std::pair<std::string, storage::Property>,
|
||||
Expression *>{
|
||||
{PROPERTY_PAIR("a"), storage.Create<PrimitiveLiteral>(1)},
|
||||
{PROPERTY_PAIR("b"), storage.Create<PrimitiveLiteral>(2)},
|
||||
@ -625,15 +625,15 @@ class ExpressionEvaluatorPropertyLookup : public testing::Test {
|
||||
NoContextExpressionEvaluator eval;
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba{db};
|
||||
std::pair<std::string, database::Property> prop_age = PROPERTY_PAIR("age");
|
||||
std::pair<std::string, database::Property> prop_height =
|
||||
std::pair<std::string, storage::Property> prop_age = PROPERTY_PAIR("age");
|
||||
std::pair<std::string, storage::Property> prop_height =
|
||||
PROPERTY_PAIR("height");
|
||||
Expression *identifier = storage.Create<Identifier>("element");
|
||||
Symbol symbol = eval.symbol_table.CreateSymbol("element", true);
|
||||
|
||||
void SetUp() { eval.symbol_table[*identifier] = symbol; }
|
||||
|
||||
auto Value(std::pair<std::string, database::Property> property) {
|
||||
auto Value(std::pair<std::string, storage::Property> property) {
|
||||
auto *op = storage.Create<PropertyLookup>(identifier, property);
|
||||
return op->Accept(eval.eval);
|
||||
}
|
||||
@ -684,15 +684,15 @@ TEST(ExpressionEvaluator, LabelsTest) {
|
||||
{
|
||||
auto *op = storage.Create<LabelsTest>(
|
||||
identifier,
|
||||
std::vector<database::Label>{dba.Label("DOG"), dba.Label("ANIMAL")});
|
||||
std::vector<storage::Label>{dba.Label("DOG"), dba.Label("ANIMAL")});
|
||||
auto value = op->Accept(eval.eval);
|
||||
EXPECT_EQ(value.Value<bool>(), true);
|
||||
}
|
||||
{
|
||||
auto *op = storage.Create<LabelsTest>(
|
||||
identifier,
|
||||
std::vector<database::Label>{dba.Label("DOG"), dba.Label("BAD_DOG"),
|
||||
dba.Label("ANIMAL")});
|
||||
std::vector<storage::Label>{dba.Label("DOG"), dba.Label("BAD_DOG"),
|
||||
dba.Label("ANIMAL")});
|
||||
auto value = op->Accept(eval.eval);
|
||||
EXPECT_EQ(value.Value<bool>(), false);
|
||||
}
|
||||
@ -700,8 +700,8 @@ TEST(ExpressionEvaluator, LabelsTest) {
|
||||
eval.frame[node_symbol] = TypedValue::Null;
|
||||
auto *op = storage.Create<LabelsTest>(
|
||||
identifier,
|
||||
std::vector<database::Label>{dba.Label("DOG"), dba.Label("BAD_DOG"),
|
||||
dba.Label("ANIMAL")});
|
||||
std::vector<storage::Label>{dba.Label("DOG"), dba.Label("BAD_DOG"),
|
||||
dba.Label("ANIMAL")});
|
||||
auto value = op->Accept(eval.eval);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ class QueryPlanAggregateOps : public ::testing::Test {
|
||||
protected:
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba{db};
|
||||
database::Property prop = dba.Property("prop");
|
||||
storage::Property prop = dba.Property("prop");
|
||||
|
||||
AstTreeStorage storage;
|
||||
SymbolTable symbol_table;
|
||||
|
@ -116,7 +116,7 @@ ScanAllTuple MakeScanAll(AstTreeStorage &storage, SymbolTable &symbol_table,
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabel(
|
||||
AstTreeStorage &storage, SymbolTable &symbol_table,
|
||||
const std::string &identifier, const database::Label &label,
|
||||
const std::string &identifier, storage::Label label,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
GraphView graph_view = GraphView::OLD) {
|
||||
auto node = NODE(identifier);
|
||||
@ -135,7 +135,7 @@ ScanAllTuple MakeScanAllByLabel(
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabelPropertyRange(
|
||||
AstTreeStorage &storage, SymbolTable &symbol_table, std::string identifier,
|
||||
database::Label label, database::Property property,
|
||||
storage::Label label, storage::Property property,
|
||||
std::experimental::optional<Bound> lower_bound,
|
||||
std::experimental::optional<Bound> upper_bound,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
@ -156,7 +156,7 @@ ScanAllTuple MakeScanAllByLabelPropertyRange(
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabelPropertyValue(
|
||||
AstTreeStorage &storage, SymbolTable &symbol_table, std::string identifier,
|
||||
database::Label label, database::Property property, Expression *value,
|
||||
storage::Label label, storage::Property property, Expression *value,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
GraphView graph_view = GraphView::OLD) {
|
||||
auto node = NODE(identifier);
|
||||
@ -179,7 +179,7 @@ ExpandTuple MakeExpand(AstTreeStorage &storage, SymbolTable &symbol_table,
|
||||
std::shared_ptr<LogicalOperator> input,
|
||||
Symbol input_symbol, const std::string &edge_identifier,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::string &node_identifier, bool existing_node,
|
||||
GraphView graph_view = GraphView::AS_IS) {
|
||||
auto edge = EDGE(edge_identifier, direction);
|
||||
|
@ -25,7 +25,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) {
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba(db);
|
||||
|
||||
database::Label label = dba.Label("Person");
|
||||
storage::Label label = dba.Label("Person");
|
||||
auto property = PROPERTY_PAIR("prop");
|
||||
|
||||
AstTreeStorage storage;
|
||||
@ -59,7 +59,7 @@ TEST(QueryPlan, CreateReturn) {
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba(db);
|
||||
|
||||
database::Label label = dba.Label("Person");
|
||||
storage::Label label = dba.Label("Person");
|
||||
auto property = PROPERTY_PAIR("property");
|
||||
|
||||
AstTreeStorage storage;
|
||||
@ -100,10 +100,10 @@ TEST(QueryPlan, CreateExpand) {
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba(db);
|
||||
|
||||
database::Label label_node_1 = dba.Label("Node1");
|
||||
database::Label label_node_2 = dba.Label("Node2");
|
||||
storage::Label label_node_1 = dba.Label("Node1");
|
||||
storage::Label label_node_2 = dba.Label("Node2");
|
||||
auto property = PROPERTY_PAIR("property");
|
||||
database::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
storage::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
|
||||
SymbolTable symbol_table;
|
||||
AstTreeStorage storage;
|
||||
@ -151,7 +151,7 @@ TEST(QueryPlan, CreateExpand) {
|
||||
|
||||
for (VertexAccessor vertex : dba.Vertices(false)) {
|
||||
EXPECT_EQ(vertex.labels().size(), 1);
|
||||
database::Label label = vertex.labels()[0];
|
||||
storage::Label label = vertex.labels()[0];
|
||||
if (label == label_node_1) {
|
||||
// node created by first op
|
||||
EXPECT_EQ(vertex.PropsAt(property.second).Value<int64_t>(), 1);
|
||||
@ -207,10 +207,10 @@ TEST(QueryPlan, MatchCreateExpand) {
|
||||
dba.InsertVertex();
|
||||
dba.AdvanceCommand();
|
||||
|
||||
// database::Label label_node_1 = dba.Label("Node1");
|
||||
// database::Label label_node_2 = dba.Label("Node2");
|
||||
// database::Property property = dba.Label("prop");
|
||||
database::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
// storage::Label label_node_1 = dba.Label("Node1");
|
||||
// storage::Label label_node_2 = dba.Label("Node2");
|
||||
// storage::Property property = dba.Label("prop");
|
||||
storage::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
|
||||
SymbolTable symbol_table;
|
||||
AstTreeStorage storage;
|
||||
@ -591,7 +591,7 @@ TEST(QueryPlan, SetLabels) {
|
||||
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto label_set = std::make_shared<plan::SetLabels>(
|
||||
n.op_, n.sym_, std::vector<database::Label>{label2, label3});
|
||||
n.op_, n.sym_, std::vector<storage::Label>{label2, label3});
|
||||
EXPECT_EQ(2, PullAll(label_set, dba, symbol_table));
|
||||
|
||||
for (VertexAccessor vertex : dba.Vertices(false)) {
|
||||
@ -675,7 +675,7 @@ TEST(QueryPlan, RemoveLabels) {
|
||||
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
auto label_remove = std::make_shared<plan::RemoveLabels>(
|
||||
n.op_, n.sym_, std::vector<database::Label>{label1, label2});
|
||||
n.op_, n.sym_, std::vector<storage::Label>{label1, label2});
|
||||
EXPECT_EQ(2, PullAll(label_remove, dba, symbol_table));
|
||||
|
||||
for (VertexAccessor vertex : dba.Vertices(false)) {
|
||||
@ -776,10 +776,9 @@ TEST(QueryPlan, SetRemove) {
|
||||
// MATCH (n) SET n :label1 :label2 REMOVE n :label1 :label2
|
||||
auto scan_all = MakeScanAll(storage, symbol_table, "n");
|
||||
auto set = std::make_shared<plan::SetLabels>(
|
||||
scan_all.op_, scan_all.sym_,
|
||||
std::vector<database::Label>{label1, label2});
|
||||
scan_all.op_, scan_all.sym_, std::vector<storage::Label>{label1, label2});
|
||||
auto rem = std::make_shared<plan::RemoveLabels>(
|
||||
set, scan_all.sym_, std::vector<database::Label>{label1, label2});
|
||||
set, scan_all.sym_, std::vector<storage::Label>{label1, label2});
|
||||
EXPECT_EQ(1, PullAll(rem, dba, symbol_table));
|
||||
dba.AdvanceCommand();
|
||||
v.Reconstruct();
|
||||
@ -901,7 +900,7 @@ TEST(QueryPlan, SetLabelsOnNull) {
|
||||
auto optional = std::make_shared<plan::Optional>(nullptr, n.op_,
|
||||
std::vector<Symbol>{n.sym_});
|
||||
auto set_op = std::make_shared<plan::SetLabels>(
|
||||
optional, n.sym_, std::vector<database::Label>{label});
|
||||
optional, n.sym_, std::vector<storage::Label>{label});
|
||||
EXPECT_EQ(0, CountIterable(dba.Vertices(false)));
|
||||
EXPECT_EQ(1, PullAll(set_op, dba, symbol_table));
|
||||
}
|
||||
@ -933,7 +932,7 @@ TEST(QueryPlan, RemoveLabelsOnNull) {
|
||||
auto optional = std::make_shared<plan::Optional>(nullptr, n.op_,
|
||||
std::vector<Symbol>{n.sym_});
|
||||
auto remove_op = std::make_shared<plan::RemoveLabels>(
|
||||
optional, n.sym_, std::vector<database::Label>{label});
|
||||
optional, n.sym_, std::vector<storage::Label>{label});
|
||||
EXPECT_EQ(0, CountIterable(dba.Vertices(false)));
|
||||
EXPECT_EQ(1, PullAll(remove_op, dba, symbol_table));
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) {
|
||||
database::GraphDbAccessor dba(db);
|
||||
|
||||
// add a few nodes to the database
|
||||
database::Label label = dba.Label("Label");
|
||||
storage::Label label = dba.Label("Label");
|
||||
auto property = PROPERTY_PAIR("Property");
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto v2 = dba.InsertVertex();
|
||||
@ -206,9 +206,9 @@ TEST(QueryPlan, NodeFilterMultipleLabels) {
|
||||
database::GraphDbAccessor dba(db);
|
||||
|
||||
// add a few nodes to the database
|
||||
database::Label label1 = dba.Label("label1");
|
||||
database::Label label2 = dba.Label("label2");
|
||||
database::Label label3 = dba.Label("label3");
|
||||
storage::Label label1 = dba.Label("label1");
|
||||
storage::Label label2 = dba.Label("label2");
|
||||
storage::Label label3 = dba.Label("label3");
|
||||
// the test will look for nodes that have label1 and label2
|
||||
dba.InsertVertex(); // NOT accepted
|
||||
dba.InsertVertex().add_label(label1); // NOT accepted
|
||||
@ -262,7 +262,7 @@ class ExpandFixture : public testing::Test {
|
||||
VertexAccessor v1 = dba_.InsertVertex();
|
||||
VertexAccessor v2 = dba_.InsertVertex();
|
||||
VertexAccessor v3 = dba_.InsertVertex();
|
||||
database::EdgeType edge_type = dba_.EdgeType("Edge");
|
||||
storage::EdgeType edge_type = dba_.EdgeType("Edge");
|
||||
EdgeAccessor r1 = dba_.InsertEdge(v1, v2, edge_type);
|
||||
EdgeAccessor r2 = dba_.InsertEdge(v1, v3, edge_type);
|
||||
|
||||
@ -356,9 +356,9 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
database::SingleNode db_;
|
||||
database::GraphDbAccessor dba_{db_};
|
||||
// labels for layers in the double chain
|
||||
std::vector<database::Label> labels;
|
||||
std::vector<storage::Label> labels;
|
||||
// for all the edges
|
||||
database::EdgeType edge_type = dba_.EdgeType("edge_type");
|
||||
storage::EdgeType edge_type = dba_.EdgeType("edge_type");
|
||||
|
||||
AstTreeStorage storage;
|
||||
SymbolTable symbol_table;
|
||||
@ -409,7 +409,7 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
std::shared_ptr<LogicalOperator> AddMatch(
|
||||
std::shared_ptr<LogicalOperator> input_op, const std::string &node_from,
|
||||
int layer, EdgeAtom::Direction direction,
|
||||
const std::vector<database::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
std::experimental::optional<size_t> lower,
|
||||
std::experimental::optional<size_t> upper, Symbol edge_sym,
|
||||
const std::string &node_to, GraphView graph_view = GraphView::AS_IS,
|
||||
@ -418,7 +418,7 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
auto filter_op = std::make_shared<Filter>(
|
||||
n_from.op_, storage.Create<query::LabelsTest>(
|
||||
n_from.node_->identifier_,
|
||||
std::vector<database::Label>{labels[layer]}));
|
||||
std::vector<storage::Label>{labels[layer]}));
|
||||
|
||||
auto n_to = NODE(node_to);
|
||||
auto n_to_sym = symbol_table.CreateSymbol(node_to, true);
|
||||
@ -620,7 +620,7 @@ TEST_F(QueryPlanExpandVariable, EdgeUniquenessTwoVariableExpansions) {
|
||||
|
||||
TEST_F(QueryPlanExpandVariable, GraphState) {
|
||||
auto test_expand = [&](GraphView graph_view,
|
||||
const std::vector<database::EdgeType> &edge_types) {
|
||||
const std::vector<storage::EdgeType> &edge_types) {
|
||||
auto e = Edge("r", EdgeAtom::Direction::OUT);
|
||||
return GetEdgeListSizes(
|
||||
AddMatch<ExpandVariable>(nullptr, "n", 0, EdgeAtom::Direction::OUT,
|
||||
@ -699,8 +699,8 @@ class QueryPlanExpandBreadthFirst : public testing::Test {
|
||||
// macro requirements
|
||||
database::SingleNode db;
|
||||
database::GraphDbAccessor dba{db};
|
||||
std::pair<std::string, database::Property> prop = PROPERTY_PAIR("property");
|
||||
database::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
std::pair<std::string, storage::Property> prop = PROPERTY_PAIR("property");
|
||||
storage::EdgeType edge_type = dba.EdgeType("edge_type");
|
||||
|
||||
// make 4 vertices because we'll need to compare against them exactly
|
||||
// v[0] has `prop` with the value 0
|
||||
@ -765,7 +765,7 @@ class QueryPlanExpandBreadthFirst : public testing::Test {
|
||||
auto edge_list_sym = symbol_table.CreateSymbol("edgelist_", true);
|
||||
last_op = std::make_shared<ExpandVariable>(
|
||||
node_sym, edge_list_sym, EdgeAtom::Type::BREADTH_FIRST, direction,
|
||||
std::vector<database::EdgeType>{}, false, nullptr, LITERAL(max_depth),
|
||||
std::vector<storage::EdgeType>{}, false, nullptr, LITERAL(max_depth),
|
||||
last_op, n.sym_, existing_node_input != nullptr, inner_edge, inner_node,
|
||||
where, graph_view);
|
||||
|
||||
@ -1059,7 +1059,7 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) {
|
||||
auto node = NODE("n");
|
||||
symbol_table[*node->identifier_] = with_n_sym;
|
||||
auto expand = std::make_shared<plan::Expand>(
|
||||
with_n_sym, edge_sym, edge_direction, std::vector<database::EdgeType>{},
|
||||
with_n_sym, edge_sym, edge_direction, std::vector<storage::EdgeType>{},
|
||||
m.op_, m.sym_, true);
|
||||
// RETURN m
|
||||
auto m_ne = NEXPR("m", IDENT("m"));
|
||||
@ -1093,7 +1093,7 @@ TEST(QueryPlan, ExpandExistingNode) {
|
||||
if (with_existing)
|
||||
r_n.op_ = std::make_shared<Expand>(
|
||||
n.sym_, r_n.edge_sym_, r_n.edge_->direction_,
|
||||
std::vector<database::EdgeType>{}, n.op_, n.sym_, with_existing);
|
||||
std::vector<storage::EdgeType>{}, n.op_, n.sym_, with_existing);
|
||||
|
||||
// make a named expression and a produce
|
||||
auto output = NEXPR("n", IDENT("n"));
|
||||
@ -1137,7 +1137,7 @@ TEST(QueryPlan, EdgeFilter) {
|
||||
// where only one edge will qualify
|
||||
// and there are all combinations of
|
||||
// (edge_type yes|no) * (property yes|absent|no)
|
||||
std::vector<database::EdgeType> edge_types;
|
||||
std::vector<storage::EdgeType> edge_types;
|
||||
for (int j = 0; j < 2; ++j)
|
||||
edge_types.push_back(dba.EdgeType("et" + std::to_string(j)));
|
||||
std::vector<VertexAccessor> vertices;
|
||||
|
@ -243,8 +243,8 @@ class ExpectScanAllByLabelPropertyValue
|
||||
: public OpChecker<ScanAllByLabelPropertyValue> {
|
||||
public:
|
||||
ExpectScanAllByLabelPropertyValue(
|
||||
database::Label label,
|
||||
const std::pair<std::string, database::Property> &prop_pair,
|
||||
storage::Label label,
|
||||
const std::pair<std::string, storage::Property> &prop_pair,
|
||||
query::Expression *expression)
|
||||
: label_(label), property_(prop_pair.second), expression_(expression) {}
|
||||
|
||||
@ -256,8 +256,8 @@ class ExpectScanAllByLabelPropertyValue
|
||||
}
|
||||
|
||||
private:
|
||||
database::Label label_;
|
||||
database::Property property_;
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
query::Expression *expression_;
|
||||
};
|
||||
|
||||
@ -265,7 +265,7 @@ class ExpectScanAllByLabelPropertyRange
|
||||
: public OpChecker<ScanAllByLabelPropertyRange> {
|
||||
public:
|
||||
ExpectScanAllByLabelPropertyRange(
|
||||
database::Label label, database::Property property,
|
||||
storage::Label label, storage::Property property,
|
||||
std::experimental::optional<Bound> lower_bound,
|
||||
std::experimental::optional<Bound> upper_bound)
|
||||
: label_(label),
|
||||
@ -290,15 +290,15 @@ class ExpectScanAllByLabelPropertyRange
|
||||
}
|
||||
|
||||
private:
|
||||
database::Label label_;
|
||||
database::Property property_;
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
std::experimental::optional<Bound> lower_bound_;
|
||||
std::experimental::optional<Bound> upper_bound_;
|
||||
};
|
||||
|
||||
class ExpectCreateIndex : public OpChecker<CreateIndex> {
|
||||
public:
|
||||
ExpectCreateIndex(database::Label label, database::Property property)
|
||||
ExpectCreateIndex(storage::Label label, storage::Property property)
|
||||
: label_(label), property_(property) {}
|
||||
|
||||
void ExpectOp(CreateIndex &create_index, const SymbolTable &) override {
|
||||
@ -307,8 +307,8 @@ class ExpectCreateIndex : public OpChecker<CreateIndex> {
|
||||
}
|
||||
|
||||
private:
|
||||
database::Label label_;
|
||||
database::Property property_;
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
};
|
||||
|
||||
auto MakeSymbolTable(query::Query &query) {
|
||||
@ -1254,7 +1254,7 @@ TEST(TestLogicalPlanner, AtomPropertyWhereLabelIndexing) {
|
||||
MATCH(PATTERN(node)),
|
||||
WHERE(AND(PROPERTY_LOOKUP("n", not_indexed),
|
||||
storage.Create<query::LabelsTest>(
|
||||
IDENT("n"), std::vector<database::Label>{label}))),
|
||||
IDENT("n"), std::vector<storage::Label>{label}))),
|
||||
RETURN("n")));
|
||||
auto symbol_table = MakeSymbolTable(*storage.query());
|
||||
auto planning_context = MakePlanningContext(storage, symbol_table, dba);
|
||||
@ -1558,7 +1558,7 @@ TEST(TestLogicalPlanner, MatchBreadthFirst) {
|
||||
AstTreeStorage storage;
|
||||
auto *bfs = storage.Create<query::EdgeAtom>(
|
||||
IDENT("r"), query::EdgeAtom::Type::BREADTH_FIRST, Direction::OUT,
|
||||
std::vector<database::EdgeType>{edge_type});
|
||||
std::vector<storage::EdgeType>{edge_type});
|
||||
bfs->inner_edge_ = IDENT("r");
|
||||
bfs->inner_node_ = IDENT("n");
|
||||
bfs->filter_expression_ = IDENT("n");
|
||||
|
@ -800,7 +800,7 @@ TEST_F(TestSymbolGenerator, MatchBfsReturn) {
|
||||
auto *n_prop = PROPERTY_LOOKUP("n", prop);
|
||||
auto *bfs = storage.Create<EdgeAtom>(
|
||||
IDENT("r"), EdgeAtom::Type::BREADTH_FIRST, EdgeAtom::Direction::OUT,
|
||||
std::vector<database::EdgeType>{});
|
||||
std::vector<storage::EdgeType>{});
|
||||
bfs->inner_edge_ = IDENT("r");
|
||||
bfs->inner_node_ = IDENT("n");
|
||||
bfs->filter_expression_ = r_prop;
|
||||
|
@ -306,7 +306,7 @@ TEST(TestVariableStartPlanner, MatchBfs) {
|
||||
AstTreeStorage storage;
|
||||
auto *bfs = storage.Create<query::EdgeAtom>(
|
||||
IDENT("r"), EdgeAtom::Type::BREADTH_FIRST, Direction::OUT,
|
||||
std::vector<database::EdgeType>{});
|
||||
std::vector<storage::EdgeType>{});
|
||||
bfs->inner_edge_ = IDENT("r");
|
||||
bfs->inner_node_ = IDENT("n");
|
||||
bfs->filter_expression_ = NEQ(PROPERTY_LOOKUP("n", id), LITERAL(3));
|
||||
|
@ -136,8 +136,8 @@ TEST(RecordAccessor, VertexLabels) {
|
||||
|
||||
EXPECT_EQ(v1.labels().size(), 0);
|
||||
|
||||
database::Label l1 = dba.Label("label1");
|
||||
database::Label l2 = dba.Label("label2");
|
||||
storage::Label l1 = dba.Label("label1");
|
||||
storage::Label l2 = dba.Label("label2");
|
||||
|
||||
// adding labels
|
||||
EXPECT_FALSE(v1.has_label(l1));
|
||||
@ -157,7 +157,7 @@ TEST(RecordAccessor, VertexLabels) {
|
||||
EXPECT_EQ(labels.size(), 2);
|
||||
|
||||
// removing labels
|
||||
database::Label l3 = dba.Label("label3");
|
||||
storage::Label l3 = dba.Label("label3");
|
||||
EXPECT_EQ(v1.remove_label(l3), 0);
|
||||
EXPECT_EQ(labels.size(), 2);
|
||||
|
||||
@ -175,8 +175,8 @@ TEST(RecordAccessor, EdgeType) {
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto v2 = dba.InsertVertex();
|
||||
|
||||
database::EdgeType likes = dba.EdgeType("likes");
|
||||
database::EdgeType hates = dba.EdgeType("hates");
|
||||
storage::EdgeType likes = dba.EdgeType("likes");
|
||||
storage::EdgeType hates = dba.EdgeType("hates");
|
||||
|
||||
auto edge = dba.InsertEdge(v1, v2, likes);
|
||||
EXPECT_EQ(edge.EdgeType(), likes);
|
||||
@ -280,9 +280,9 @@ TEST(RecordAccessor, VertexEdgeConnectionsWithEdgeType) {
|
||||
TEST_EDGE_ITERABLE(v1.in(), {eb_1, eb_2});
|
||||
TEST_EDGE_ITERABLE(v2.in(), {ea, ec});
|
||||
|
||||
std::vector<database::EdgeType> edges_a{a};
|
||||
std::vector<database::EdgeType> edges_b{b};
|
||||
std::vector<database::EdgeType> edges_ac{a, c};
|
||||
std::vector<storage::EdgeType> edges_a{a};
|
||||
std::vector<storage::EdgeType> edges_b{b};
|
||||
std::vector<storage::EdgeType> edges_ac{a, c};
|
||||
TEST_EDGE_ITERABLE(v1.in(&edges_a));
|
||||
TEST_EDGE_ITERABLE(v1.in(&edges_b), {eb_1, eb_2});
|
||||
TEST_EDGE_ITERABLE(v1.out(&edges_a), {ea});
|
||||
|
Loading…
Reference in New Issue
Block a user