Remove old storage types
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2633
This commit is contained in:
parent
1a50165c22
commit
98dc7e2849
@ -10,32 +10,32 @@
|
||||
|
||||
namespace audit {
|
||||
|
||||
// Helper function that converts a `PropertyValue` to `nlohmann::json`.
|
||||
inline nlohmann::json PropertyValueToJson(const PropertyValue &pv) {
|
||||
// Helper function that converts a `storage::PropertyValue` to `nlohmann::json`.
|
||||
inline nlohmann::json PropertyValueToJson(const storage::PropertyValue &pv) {
|
||||
nlohmann::json ret;
|
||||
switch (pv.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
break;
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
ret = pv.ValueBool();
|
||||
break;
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
ret = pv.ValueInt();
|
||||
break;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
ret = pv.ValueDouble();
|
||||
break;
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
ret = pv.ValueString();
|
||||
break;
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
ret = nlohmann::json::array();
|
||||
for (const auto &item : pv.ValueList()) {
|
||||
ret.push_back(PropertyValueToJson(item));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
ret = nlohmann::json::object();
|
||||
for (const auto &item : pv.ValueMap()) {
|
||||
ret.push_back(nlohmann::json::object_t::value_type(
|
||||
@ -79,7 +79,8 @@ Log::~Log() {
|
||||
}
|
||||
|
||||
void Log::Record(const std::string &address, const std::string &username,
|
||||
const std::string &query, const PropertyValue ¶ms) {
|
||||
const std::string &query,
|
||||
const storage::PropertyValue ¶ms) {
|
||||
if (!started_.load(std::memory_order_relaxed)) return;
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include "data_structures/ring_buffer.hpp"
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/scheduler.hpp"
|
||||
|
||||
@ -23,7 +23,7 @@ class Log {
|
||||
std::string address;
|
||||
std::string username;
|
||||
std::string query;
|
||||
PropertyValue params;
|
||||
storage::PropertyValue params;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -44,7 +44,7 @@ class Log {
|
||||
|
||||
/// Adds an entry to the audit log. Thread-safe.
|
||||
void Record(const std::string &address, const std::string &username,
|
||||
const std::string &query, const PropertyValue ¶ms);
|
||||
const std::string &query, const storage::PropertyValue ¶ms);
|
||||
|
||||
/// Reopens the log file. Used for log file rotation. Thread-safe.
|
||||
void ReopenLog();
|
||||
|
@ -271,30 +271,30 @@ communication::bolt::Path ToBoltPath(const query::Path &path,
|
||||
return communication::bolt::Path(vertices, edges);
|
||||
}
|
||||
|
||||
PropertyValue ToPropertyValue(const Value &value) {
|
||||
storage::PropertyValue ToPropertyValue(const Value &value) {
|
||||
switch (value.type()) {
|
||||
case Value::Type::Null:
|
||||
return PropertyValue();
|
||||
return storage::PropertyValue();
|
||||
case Value::Type::Bool:
|
||||
return PropertyValue(value.ValueBool());
|
||||
return storage::PropertyValue(value.ValueBool());
|
||||
case Value::Type::Int:
|
||||
return PropertyValue(value.ValueInt());
|
||||
return storage::PropertyValue(value.ValueInt());
|
||||
case Value::Type::Double:
|
||||
return PropertyValue(value.ValueDouble());
|
||||
return storage::PropertyValue(value.ValueDouble());
|
||||
case Value::Type::String:
|
||||
return PropertyValue(value.ValueString());
|
||||
return storage::PropertyValue(value.ValueString());
|
||||
case Value::Type::List: {
|
||||
std::vector<PropertyValue> vec;
|
||||
std::vector<storage::PropertyValue> vec;
|
||||
vec.reserve(value.ValueList().size());
|
||||
for (const auto &value : value.ValueList())
|
||||
vec.emplace_back(ToPropertyValue(value));
|
||||
return PropertyValue(std::move(vec));
|
||||
return storage::PropertyValue(std::move(vec));
|
||||
}
|
||||
case Value::Type::Map: {
|
||||
std::map<std::string, PropertyValue> map;
|
||||
std::map<std::string, storage::PropertyValue> map;
|
||||
for (const auto &kv : value.ValueMap())
|
||||
map.emplace(kv.first, ToPropertyValue(kv.second));
|
||||
return PropertyValue(std::move(map));
|
||||
return storage::PropertyValue(std::move(map));
|
||||
}
|
||||
case Value::Type::Vertex:
|
||||
case Value::Type::Edge:
|
||||
@ -305,20 +305,20 @@ PropertyValue ToPropertyValue(const Value &value) {
|
||||
}
|
||||
}
|
||||
|
||||
Value ToBoltValue(const PropertyValue &value) {
|
||||
Value ToBoltValue(const storage::PropertyValue &value) {
|
||||
switch (value.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
return Value();
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
return Value(value.ValueBool());
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
return Value(value.ValueInt());
|
||||
break;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
return Value(value.ValueDouble());
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
return Value(value.ValueString());
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
const auto &values = value.ValueList();
|
||||
std::vector<Value> vec;
|
||||
vec.reserve(values.size());
|
||||
@ -327,7 +327,7 @@ Value ToBoltValue(const PropertyValue &value) {
|
||||
}
|
||||
return Value(std::move(vec));
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
const auto &map = value.ValueMap();
|
||||
std::map<std::string, Value> dv_map;
|
||||
for (const auto &kv : map) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "communication/bolt/v1/value.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "storage/v2/view.hpp"
|
||||
|
||||
#ifdef MG_SINGLE_NODE_V2
|
||||
@ -70,8 +70,8 @@ communication::bolt::Value ToBoltValue(const query::TypedValue &value,
|
||||
|
||||
query::TypedValue ToTypedValue(const communication::bolt::Value &value);
|
||||
|
||||
communication::bolt::Value ToBoltValue(const PropertyValue &value);
|
||||
communication::bolt::Value ToBoltValue(const storage::PropertyValue &value);
|
||||
|
||||
PropertyValue ToPropertyValue(const communication::bolt::Value &value);
|
||||
storage::PropertyValue ToPropertyValue(const communication::bolt::Value &value);
|
||||
|
||||
} // namespace glue
|
||||
|
@ -50,12 +50,12 @@ using TEncoder =
|
||||
std::vector<std::string> BoltSession::Interpret(
|
||||
const std::string &query,
|
||||
const std::map<std::string, communication::bolt::Value> ¶ms) {
|
||||
std::map<std::string, PropertyValue> params_pv;
|
||||
std::map<std::string, storage::PropertyValue> params_pv;
|
||||
for (const auto &kv : params)
|
||||
params_pv.emplace(kv.first, glue::ToPropertyValue(kv.second));
|
||||
#ifndef MG_SINGLE_NODE_HA
|
||||
audit_log_->Record(endpoint_.address(), user_ ? user_->username() : "", query,
|
||||
PropertyValue(params_pv));
|
||||
storage::PropertyValue(params_pv));
|
||||
#endif
|
||||
try {
|
||||
auto result = interpreter_.Prepare(query, params_pv);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "query/frontend/ast/ast.hpp"
|
||||
#include "query/frontend/semantic/symbol.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/common/types/types.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
#include "storage/v2/view.hpp"
|
||||
|
||||
namespace query {
|
||||
@ -73,10 +73,10 @@ inline void ExpectType(const Symbol &symbol, const TypedValue &value,
|
||||
///
|
||||
/// @throw QueryRuntimeException if value cannot be set as a property value
|
||||
template <class TRecordAccessor>
|
||||
void PropsSetChecked(TRecordAccessor *record, const storage::Property &key,
|
||||
void PropsSetChecked(TRecordAccessor *record, const storage::PropertyId &key,
|
||||
const TypedValue &value) {
|
||||
try {
|
||||
auto maybe_error = record->SetProperty(key, PropertyValue(value));
|
||||
auto maybe_error = record->SetProperty(key, storage::PropertyValue(value));
|
||||
if (maybe_error.HasError()) {
|
||||
switch (maybe_error.GetError()) {
|
||||
case storage::Error::SERIALIZATION_ERROR:
|
||||
|
@ -18,17 +18,17 @@ struct EvaluationContext {
|
||||
int64_t timestamp{-1};
|
||||
Parameters parameters;
|
||||
/// All properties indexable via PropertyIx
|
||||
std::vector<storage::Property> properties;
|
||||
std::vector<storage::PropertyId> properties;
|
||||
/// All labels indexable via LabelIx
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
/// All counters generated by `counter` function, mutable because the function
|
||||
/// modifies the values
|
||||
mutable std::unordered_map<std::string, int64_t> counters;
|
||||
};
|
||||
|
||||
inline std::vector<storage::Property> NamesToProperties(
|
||||
inline std::vector<storage::PropertyId> NamesToProperties(
|
||||
const std::vector<std::string> &property_names, DbAccessor *dba) {
|
||||
std::vector<storage::Property> properties;
|
||||
std::vector<storage::PropertyId> properties;
|
||||
properties.reserve(property_names.size());
|
||||
for (const auto &name : property_names) {
|
||||
properties.push_back(dba->NameToProperty(name));
|
||||
@ -36,9 +36,9 @@ inline std::vector<storage::Property> NamesToProperties(
|
||||
return properties;
|
||||
}
|
||||
|
||||
inline std::vector<storage::Label> NamesToLabels(
|
||||
inline std::vector<storage::LabelId> NamesToLabels(
|
||||
const std::vector<std::string> &label_names, DbAccessor *dba) {
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
labels.reserve(label_names.size());
|
||||
for (const auto &name : label_names) {
|
||||
labels.push_back(dba->NameToLabel(name));
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include <cppitertools/imap.hpp>
|
||||
|
||||
#include "query/exceptions.hpp"
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/common/types/types.hpp"
|
||||
#include "storage/edge_accessor.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "storage/v2/result.hpp"
|
||||
#include "storage/v2/view.hpp"
|
||||
#include "storage/vertex_accessor.hpp"
|
||||
@ -33,22 +33,22 @@ class EdgeAccessor final {
|
||||
public:
|
||||
explicit EdgeAccessor(storage::EdgeAccessor impl) : impl_(std::move(impl)) {}
|
||||
|
||||
storage::EdgeType EdgeType() const { return impl_.EdgeType(); }
|
||||
storage::EdgeTypeId EdgeType() const { return impl_.EdgeType(); }
|
||||
|
||||
auto Properties(storage::View view) const { return impl_.Properties(view); }
|
||||
|
||||
storage::Result<PropertyValue> GetProperty(storage::View view,
|
||||
storage::Property key) const {
|
||||
storage::Result<storage::PropertyValue> GetProperty(storage::View view,
|
||||
storage::PropertyId key) const {
|
||||
return impl_.GetProperty(key, view);
|
||||
}
|
||||
|
||||
storage::Result<bool> SetProperty(storage::Property key,
|
||||
const PropertyValue &value) {
|
||||
storage::Result<bool> SetProperty(storage::PropertyId key,
|
||||
const storage::PropertyValue &value) {
|
||||
return impl_.SetProperty(key, value);
|
||||
}
|
||||
|
||||
storage::Result<bool> RemoveProperty(storage::Property key) {
|
||||
return SetProperty(key, PropertyValue());
|
||||
storage::Result<bool> RemoveProperty(storage::PropertyId key) {
|
||||
return SetProperty(key, storage::PropertyValue());
|
||||
}
|
||||
|
||||
utils::BasicResult<storage::Error, void> ClearProperties() {
|
||||
@ -86,33 +86,33 @@ class VertexAccessor final {
|
||||
|
||||
auto Labels(storage::View view) const { return impl_.Labels(view); }
|
||||
|
||||
storage::Result<bool> AddLabel(storage::Label label) {
|
||||
storage::Result<bool> AddLabel(storage::LabelId label) {
|
||||
return impl_.AddLabel(label);
|
||||
}
|
||||
|
||||
storage::Result<bool> RemoveLabel(storage::Label label) {
|
||||
storage::Result<bool> RemoveLabel(storage::LabelId label) {
|
||||
return impl_.RemoveLabel(label);
|
||||
}
|
||||
|
||||
storage::Result<bool> HasLabel(storage::View view,
|
||||
storage::Label label) const {
|
||||
storage::LabelId label) const {
|
||||
return impl_.HasLabel(label, view);
|
||||
}
|
||||
|
||||
auto Properties(storage::View view) const { return impl_.Properties(view); }
|
||||
|
||||
storage::Result<PropertyValue> GetProperty(storage::View view,
|
||||
storage::Property key) const {
|
||||
storage::Result<storage::PropertyValue> GetProperty(storage::View view,
|
||||
storage::PropertyId key) const {
|
||||
return impl_.GetProperty(key, view);
|
||||
}
|
||||
|
||||
storage::Result<bool> SetProperty(storage::Property key,
|
||||
const PropertyValue &value) {
|
||||
storage::Result<bool> SetProperty(storage::PropertyId key,
|
||||
const storage::PropertyValue &value) {
|
||||
return impl_.SetProperty(key, value);
|
||||
}
|
||||
|
||||
storage::Result<bool> RemoveProperty(storage::Property key) {
|
||||
return SetProperty(key, PropertyValue());
|
||||
storage::Result<bool> RemoveProperty(storage::PropertyId key) {
|
||||
return SetProperty(key, storage::PropertyValue());
|
||||
}
|
||||
|
||||
utils::BasicResult<storage::Error, void> ClearProperties() {
|
||||
@ -122,7 +122,7 @@ class VertexAccessor final {
|
||||
}
|
||||
|
||||
auto InEdges(storage::View view,
|
||||
const std::vector<storage::EdgeType> &edge_types) const
|
||||
const std::vector<storage::EdgeTypeId> &edge_types) const
|
||||
-> storage::Result<decltype(iter::imap(MakeEdgeAccessor,
|
||||
*impl_.InEdges(view)))> {
|
||||
auto maybe_edges = impl_.InEdges(view, edge_types);
|
||||
@ -133,7 +133,7 @@ class VertexAccessor final {
|
||||
auto InEdges(storage::View view) const { return InEdges(view, {}); }
|
||||
|
||||
auto InEdges(storage::View view,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
const VertexAccessor &dest) const
|
||||
-> storage::Result<decltype(iter::imap(MakeEdgeAccessor,
|
||||
*impl_.InEdges(view)))> {
|
||||
@ -143,7 +143,7 @@ class VertexAccessor final {
|
||||
}
|
||||
|
||||
auto OutEdges(storage::View view,
|
||||
const std::vector<storage::EdgeType> &edge_types) const
|
||||
const std::vector<storage::EdgeTypeId> &edge_types) const
|
||||
-> storage::Result<decltype(iter::imap(MakeEdgeAccessor,
|
||||
*impl_.OutEdges(view)))> {
|
||||
auto maybe_edges = impl_.OutEdges(view, edge_types);
|
||||
@ -154,7 +154,7 @@ class VertexAccessor final {
|
||||
auto OutEdges(storage::View view) const { return OutEdges(view, {}); }
|
||||
|
||||
auto OutEdges(storage::View view,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
const VertexAccessor &dest) const
|
||||
-> storage::Result<decltype(iter::imap(MakeEdgeAccessor,
|
||||
*impl_.OutEdges(view)))> {
|
||||
@ -525,20 +525,20 @@ class DbAccessor final {
|
||||
return VerticesIterable(accessor_->Vertices(view));
|
||||
}
|
||||
|
||||
VerticesIterable Vertices(storage::View view, storage::Label label) {
|
||||
VerticesIterable Vertices(storage::View view, storage::LabelId label) {
|
||||
return VerticesIterable(accessor_->Vertices(label, view));
|
||||
}
|
||||
|
||||
VerticesIterable Vertices(storage::View view, storage::Label label,
|
||||
storage::Property property,
|
||||
const PropertyValue &value) {
|
||||
VerticesIterable Vertices(storage::View view, storage::LabelId label,
|
||||
storage::PropertyId property,
|
||||
const storage::PropertyValue &value) {
|
||||
return VerticesIterable(accessor_->Vertices(label, property, value, view));
|
||||
}
|
||||
|
||||
VerticesIterable Vertices(
|
||||
storage::View view, storage::Label label, storage::Property property,
|
||||
const std::optional<utils::Bound<PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<PropertyValue>> &upper) {
|
||||
storage::View view, storage::LabelId label, storage::PropertyId property,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &upper) {
|
||||
return VerticesIterable(
|
||||
accessor_->Vertices(label, property, lower, upper, view));
|
||||
}
|
||||
@ -549,7 +549,7 @@ class DbAccessor final {
|
||||
|
||||
storage::Result<EdgeAccessor> InsertEdge(VertexAccessor *from,
|
||||
VertexAccessor *to,
|
||||
const storage::EdgeType &edge_type) {
|
||||
const storage::EdgeTypeId &edge_type) {
|
||||
auto maybe_edge =
|
||||
accessor_->CreateEdge(&from->impl_, &to->impl_, edge_type);
|
||||
if (maybe_edge.HasError())
|
||||
@ -569,29 +569,29 @@ class DbAccessor final {
|
||||
return accessor_->DeleteVertex(&vertex_accessor->impl_);
|
||||
}
|
||||
|
||||
storage::Property NameToProperty(const std::string_view &name) {
|
||||
storage::PropertyId NameToProperty(const std::string_view &name) {
|
||||
// TODO: New storage should work with string_view to avoid needless
|
||||
// allocation.
|
||||
return accessor_->NameToProperty(std::string(name));
|
||||
}
|
||||
|
||||
storage::Label NameToLabel(const std::string_view &name) {
|
||||
storage::LabelId NameToLabel(const std::string_view &name) {
|
||||
return accessor_->NameToLabel(std::string(name));
|
||||
}
|
||||
|
||||
storage::EdgeType NameToEdgeType(const std::string_view &name) {
|
||||
storage::EdgeTypeId NameToEdgeType(const std::string_view &name) {
|
||||
return accessor_->NameToEdgeType(std::string(name));
|
||||
}
|
||||
|
||||
const std::string &PropertyToName(storage::Property prop) const {
|
||||
const std::string &PropertyToName(storage::PropertyId prop) const {
|
||||
return accessor_->PropertyToName(prop);
|
||||
}
|
||||
|
||||
const std::string &LabelToName(storage::Label label) const {
|
||||
const std::string &LabelToName(storage::LabelId label) const {
|
||||
return accessor_->LabelToName(label);
|
||||
}
|
||||
|
||||
const std::string &EdgeTypeToName(storage::EdgeType type) const {
|
||||
const std::string &EdgeTypeToName(storage::EdgeTypeId type) const {
|
||||
return accessor_->EdgeTypeToName(type);
|
||||
}
|
||||
|
||||
@ -603,35 +603,35 @@ class DbAccessor final {
|
||||
|
||||
void Abort() { accessor_->Abort(); }
|
||||
|
||||
bool LabelIndexExists(storage::Label label) const {
|
||||
bool LabelIndexExists(storage::LabelId label) const {
|
||||
return accessor_->LabelIndexExists(label);
|
||||
}
|
||||
|
||||
bool LabelPropertyIndexExists(storage::Label label,
|
||||
storage::Property prop) const {
|
||||
bool LabelPropertyIndexExists(storage::LabelId label,
|
||||
storage::PropertyId prop) const {
|
||||
return accessor_->LabelPropertyIndexExists(label, prop);
|
||||
}
|
||||
|
||||
int64_t VerticesCount() const { return accessor_->ApproximateVertexCount(); }
|
||||
|
||||
int64_t VerticesCount(storage::Label label) const {
|
||||
int64_t VerticesCount(storage::LabelId label) const {
|
||||
return accessor_->ApproximateVertexCount(label);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label,
|
||||
storage::Property property) const {
|
||||
int64_t VerticesCount(storage::LabelId label,
|
||||
storage::PropertyId property) const {
|
||||
return accessor_->ApproximateVertexCount(label, property);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label, storage::Property property,
|
||||
const PropertyValue &value) const {
|
||||
int64_t VerticesCount(storage::LabelId label, storage::PropertyId property,
|
||||
const storage::PropertyValue &value) const {
|
||||
return accessor_->ApproximateVertexCount(label, property, value);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(
|
||||
storage::Label label, storage::Property property,
|
||||
const std::optional<utils::Bound<PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<PropertyValue>> &upper) const {
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &upper) const {
|
||||
return accessor_->ApproximateVertexCount(label, property, lower, upper);
|
||||
}
|
||||
|
||||
|
@ -36,24 +36,24 @@ void DumpPreciseDouble(std::ostream *os, double value) {
|
||||
*os << temp_oss.str();
|
||||
}
|
||||
|
||||
void DumpPropertyValue(std::ostream *os, const PropertyValue &value) {
|
||||
void DumpPropertyValue(std::ostream *os, const storage::PropertyValue &value) {
|
||||
switch (value.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
*os << "Null";
|
||||
return;
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
*os << (value.ValueBool() ? "true" : "false");
|
||||
return;
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
*os << ::utils::Escape(value.ValueString());
|
||||
return;
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
*os << value.ValueInt();
|
||||
return;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
DumpPreciseDouble(os, value.ValueDouble());
|
||||
return;
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
*os << "[";
|
||||
const auto &list = value.ValueList();
|
||||
utils::PrintIterable(*os, list, ", ", [](auto &os, const auto &item) {
|
||||
@ -62,7 +62,7 @@ void DumpPropertyValue(std::ostream *os, const PropertyValue &value) {
|
||||
*os << "]";
|
||||
return;
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
*os << "{";
|
||||
const auto &map = value.ValueMap();
|
||||
utils::PrintIterable(*os, map, ", ", [](auto &os, const auto &kv) {
|
||||
@ -75,13 +75,14 @@ void DumpPropertyValue(std::ostream *os, const PropertyValue &value) {
|
||||
}
|
||||
}
|
||||
|
||||
void DumpProperties(std::ostream *os, query::DbAccessor *dba,
|
||||
void DumpProperties(
|
||||
std::ostream *os, query::DbAccessor *dba,
|
||||
#ifdef MG_SINGLE_NODE_V2
|
||||
const std::map<storage::Property, PropertyValue> &store,
|
||||
const std::map<storage::PropertyId, storage::PropertyValue> &store,
|
||||
#else
|
||||
const PropertyValueStore &store,
|
||||
const PropertyValueStore &store,
|
||||
#endif
|
||||
std::optional<uint64_t> property_id = std::nullopt) {
|
||||
std::optional<uint64_t> property_id = std::nullopt) {
|
||||
*os << "{";
|
||||
if (property_id) {
|
||||
*os << kInternalPropertyId << ": " << *property_id;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "query/frontend/semantic/symbol.hpp"
|
||||
#include "query/interpret/awesome_memgraph_functions.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "utils/typeinfo.hpp"
|
||||
|
||||
cpp<#
|
||||
@ -579,7 +579,7 @@ cpp<#
|
||||
(:clone))
|
||||
|
||||
(lcp:define-class primitive-literal (base-literal)
|
||||
((value "PropertyValue" :scope :public)
|
||||
((value "::storage::PropertyValue" :scope :public)
|
||||
(token-position :int32_t :scope :public :initval -1
|
||||
:documentation "This field contains token position of literal used to create PrimitiveLiteral object. If PrimitiveLiteral object is not created from query, leave its value at -1."))
|
||||
(:public
|
||||
|
@ -77,7 +77,7 @@ void PrintObject(std::ostream *out, Expression *expr);
|
||||
|
||||
void PrintObject(std::ostream *out, Identifier *expr);
|
||||
|
||||
void PrintObject(std::ostream *out, const PropertyValue &value);
|
||||
void PrintObject(std::ostream *out, const storage::PropertyValue &value);
|
||||
|
||||
template <typename T>
|
||||
void PrintObject(std::ostream *out, const std::vector<T> &vec);
|
||||
@ -117,33 +117,33 @@ void PrintObject(std::ostream *out, Identifier *expr) {
|
||||
PrintObject(out, static_cast<Expression *>(expr));
|
||||
}
|
||||
|
||||
void PrintObject(std::ostream *out, const PropertyValue &value) {
|
||||
void PrintObject(std::ostream *out, const storage::PropertyValue &value) {
|
||||
switch (value.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
*out << "null";
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
PrintObject(out, value.ValueString());
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
*out << (value.ValueBool() ? "true" : "false");
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
PrintObject(out, value.ValueInt());
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
PrintObject(out, value.ValueDouble());
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::List:
|
||||
case storage::PropertyValue::Type::List:
|
||||
PrintObject(out, value.ValueList());
|
||||
break;
|
||||
|
||||
case PropertyValue::Type::Map:
|
||||
case storage::PropertyValue::Type::Map:
|
||||
PrintObject(out, value.ValueMap());
|
||||
break;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ StrippedQuery::StrippedQuery(const std::string &query) : original_(query) {
|
||||
auto replace_stripped = [this, &token_strings](int position,
|
||||
const auto &value,
|
||||
const std::string &new_value) {
|
||||
literals_.Add(position, PropertyValue(value));
|
||||
literals_.Add(position, storage::PropertyValue(value));
|
||||
token_strings.push_back(new_value);
|
||||
};
|
||||
|
||||
|
@ -558,8 +558,8 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
|
||||
private:
|
||||
template <class TRecordAccessor>
|
||||
PropertyValue GetProperty(const TRecordAccessor &record_accessor,
|
||||
PropertyIx prop) {
|
||||
storage::PropertyValue GetProperty(const TRecordAccessor &record_accessor,
|
||||
PropertyIx prop) {
|
||||
auto maybe_prop =
|
||||
record_accessor.GetProperty(view_, ctx_->properties[prop.ix]);
|
||||
if (maybe_prop.HasError() &&
|
||||
@ -592,8 +592,8 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
}
|
||||
|
||||
template <class TRecordAccessor>
|
||||
PropertyValue GetProperty(const TRecordAccessor &record_accessor,
|
||||
const std::string_view &name) {
|
||||
storage::PropertyValue GetProperty(const TRecordAccessor &record_accessor,
|
||||
const std::string_view &name) {
|
||||
auto maybe_prop =
|
||||
record_accessor.GetProperty(view_, dba_->NameToProperty(name));
|
||||
if (maybe_prop.HasError() &&
|
||||
@ -625,7 +625,7 @@ class ExpressionEvaluator : public ExpressionVisitor<TypedValue> {
|
||||
return *maybe_prop;
|
||||
}
|
||||
|
||||
storage::Label GetLabel(LabelIx label) { return ctx_->labels[label.ix]; }
|
||||
storage::LabelId GetLabel(LabelIx label) { return ctx_->labels[label.ix]; }
|
||||
|
||||
Frame *frame_;
|
||||
const SymbolTable *symbol_table_;
|
||||
|
@ -38,7 +38,7 @@ namespace query {
|
||||
*/
|
||||
struct ParsedQuery {
|
||||
std::string query_string;
|
||||
std::map<std::string, PropertyValue> user_parameters;
|
||||
std::map<std::string, storage::PropertyValue> user_parameters;
|
||||
Parameters parameters;
|
||||
frontend::StrippedQuery stripped_query;
|
||||
AstStorage ast_storage;
|
||||
@ -46,10 +46,10 @@ struct ParsedQuery {
|
||||
std::vector<AuthQuery::Privilege> required_privileges;
|
||||
};
|
||||
|
||||
ParsedQuery ParseQuery(const std::string &query_string,
|
||||
const std::map<std::string, PropertyValue> ¶ms,
|
||||
utils::SkipList<QueryCacheEntry> *cache,
|
||||
utils::SpinLock *antlr_lock) {
|
||||
ParsedQuery ParseQuery(
|
||||
const std::string &query_string,
|
||||
const std::map<std::string, storage::PropertyValue> ¶ms,
|
||||
utils::SkipList<QueryCacheEntry> *cache, utils::SpinLock *antlr_lock) {
|
||||
// Strip the query for caching purposes. The process of stripping a query
|
||||
// "normalizes" it by replacing any literals with new parameters . This
|
||||
// results in just the *structure* of the query being taken into account for
|
||||
@ -1117,8 +1117,9 @@ PreparedQuery PrepareConstraintQuery(
|
||||
}
|
||||
|
||||
std::pair<std::vector<std::string>, std::vector<query::AuthQuery::Privilege>>
|
||||
Interpreter::Prepare(const std::string &query_string,
|
||||
const std::map<std::string, PropertyValue> ¶ms) {
|
||||
Interpreter::Prepare(
|
||||
const std::string &query_string,
|
||||
const std::map<std::string, storage::PropertyValue> ¶ms) {
|
||||
// Clear the last prepared query.
|
||||
prepared_query_ = std::nullopt;
|
||||
execution_memory_.Release();
|
||||
|
@ -250,7 +250,7 @@ class Interpreter final {
|
||||
*/
|
||||
std::pair<std::vector<std::string>, std::vector<query::AuthQuery::Privilege>>
|
||||
Prepare(const std::string &query,
|
||||
const std::map<std::string, PropertyValue> ¶ms);
|
||||
const std::map<std::string, storage::PropertyValue> ¶ms);
|
||||
|
||||
/**
|
||||
* Execute the last prepared query and stream *all* of the results into the
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
|
||||
/**
|
||||
* Encapsulates user provided parameters (and stripped literals)
|
||||
@ -22,7 +22,7 @@ struct Parameters {
|
||||
* @param position Token position in query of value.
|
||||
* @param value
|
||||
*/
|
||||
void Add(int position, const PropertyValue &value) {
|
||||
void Add(int position, const storage::PropertyValue &value) {
|
||||
storage_.emplace_back(position, value);
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ struct Parameters {
|
||||
* @param position Token position in query of value.
|
||||
* @return Value for the given token position.
|
||||
*/
|
||||
const PropertyValue &AtTokenPosition(int position) const {
|
||||
const storage::PropertyValue &AtTokenPosition(int position) const {
|
||||
auto found =
|
||||
std::find_if(storage_.begin(), storage_.end(),
|
||||
[&](const auto &a) { return a.first == position; });
|
||||
@ -48,7 +48,7 @@ struct Parameters {
|
||||
* @param position Which stripped param is sought.
|
||||
* @return Token position and value for sought param.
|
||||
*/
|
||||
const std::pair<int, PropertyValue> &At(int position) const {
|
||||
const std::pair<int, storage::PropertyValue> &At(int position) const {
|
||||
CHECK(position < static_cast<int>(storage_.size())) << "Invalid position";
|
||||
return storage_[position];
|
||||
}
|
||||
@ -60,7 +60,7 @@ struct Parameters {
|
||||
auto end() const { return storage_.end(); }
|
||||
|
||||
private:
|
||||
std::vector<std::pair<int, PropertyValue>> storage_;
|
||||
std::vector<std::pair<int, storage::PropertyValue>> storage_;
|
||||
};
|
||||
|
||||
} // namespace query
|
||||
|
@ -205,19 +205,20 @@ class CostEstimator : public HierarchicalLogicalOperatorVisitor {
|
||||
// converts an optional ScanAll range bound into a property value
|
||||
// if the bound is present and is a constant expression convertible to
|
||||
// a property value. otherwise returns nullopt
|
||||
std::optional<utils::Bound<PropertyValue>> BoundToPropertyValue(
|
||||
std::optional<utils::Bound<storage::PropertyValue>> BoundToPropertyValue(
|
||||
std::optional<ScanAllByLabelPropertyRange::Bound> bound) {
|
||||
if (bound) {
|
||||
auto property_value = ConstPropertyValue(bound->value());
|
||||
if (property_value)
|
||||
return utils::Bound<PropertyValue>(*property_value, bound->type());
|
||||
return utils::Bound<storage::PropertyValue>(*property_value,
|
||||
bound->type());
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// If the expression is a constant property value, it is returned. Otherwise,
|
||||
// return nullopt.
|
||||
std::optional<PropertyValue> ConstPropertyValue(
|
||||
std::optional<storage::PropertyValue> ConstPropertyValue(
|
||||
const Expression *expression) {
|
||||
if (auto *literal = utils::Downcast<const PrimitiveLiteral>(expression)) {
|
||||
return literal->value_;
|
||||
|
@ -384,7 +384,7 @@ std::vector<Symbol> ScanAll::ModifiedSymbols(const SymbolTable &table) const {
|
||||
}
|
||||
|
||||
ScanAllByLabel::ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::View view)
|
||||
: ScanAll(input, output_symbol, view), label_(label) {}
|
||||
|
||||
@ -401,7 +401,7 @@ UniqueCursorPtr ScanAllByLabel::MakeCursor(utils::MemoryResource *mem) const {
|
||||
|
||||
ScanAllByLabelPropertyRange::ScanAllByLabelPropertyRange(
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
storage::Label label, storage::Property property,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::string &property_name, std::optional<Bound> lower_bound,
|
||||
std::optional<Bound> upper_bound, storage::View view)
|
||||
: ScanAll(input, output_symbol, view),
|
||||
@ -424,13 +424,12 @@ UniqueCursorPtr ScanAllByLabelPropertyRange::MakeCursor(
|
||||
ExpressionEvaluator evaluator(&frame, context.symbol_table,
|
||||
context.evaluation_context,
|
||||
context.db_accessor, view_);
|
||||
auto convert =
|
||||
[&evaluator](
|
||||
const auto &bound) -> std::optional<utils::Bound<PropertyValue>> {
|
||||
auto convert = [&evaluator](const auto &bound)
|
||||
-> std::optional<utils::Bound<storage::PropertyValue>> {
|
||||
if (!bound) return std::nullopt;
|
||||
const auto &value = bound->value()->Accept(evaluator);
|
||||
try {
|
||||
const auto &property_value = PropertyValue(value);
|
||||
const auto &property_value = storage::PropertyValue(value);
|
||||
switch (property_value.type()) {
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::List:
|
||||
@ -447,8 +446,8 @@ UniqueCursorPtr ScanAllByLabelPropertyRange::MakeCursor(
|
||||
// These are all fine, there's also Point, Date and Time data types
|
||||
// which were added to Cypher, but we don't have support for those
|
||||
// yet.
|
||||
return std::make_optional(
|
||||
utils::Bound<PropertyValue>(property_value, bound->type()));
|
||||
return std::make_optional(utils::Bound<storage::PropertyValue>(
|
||||
property_value, bound->type()));
|
||||
}
|
||||
} catch (const TypedValueException &) {
|
||||
throw QueryRuntimeException("'{}' cannot be used as a property value.",
|
||||
@ -470,7 +469,7 @@ UniqueCursorPtr ScanAllByLabelPropertyRange::MakeCursor(
|
||||
|
||||
ScanAllByLabelPropertyValue::ScanAllByLabelPropertyValue(
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol output_symbol,
|
||||
storage::Label label, storage::Property property,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::string &property_name, Expression *expression,
|
||||
storage::View view)
|
||||
: ScanAll(input, output_symbol, view),
|
||||
@ -487,7 +486,7 @@ UniqueCursorPtr ScanAllByLabelPropertyValue::MakeCursor(
|
||||
utils::MemoryResource *mem) const {
|
||||
auto vertices = [this](Frame &frame, ExecutionContext &context)
|
||||
-> std::optional<decltype(context.db_accessor->Vertices(
|
||||
view_, label_, property_, PropertyValue()))> {
|
||||
view_, label_, property_, storage::PropertyValue()))> {
|
||||
auto *db = context.db_accessor;
|
||||
ExpressionEvaluator evaluator(&frame, context.symbol_table,
|
||||
context.evaluation_context,
|
||||
@ -499,7 +498,7 @@ UniqueCursorPtr ScanAllByLabelPropertyValue::MakeCursor(
|
||||
value.type());
|
||||
}
|
||||
return std::make_optional(
|
||||
db->Vertices(view_, label_, property_, PropertyValue(value)));
|
||||
db->Vertices(view_, label_, property_, storage::PropertyValue(value)));
|
||||
};
|
||||
return MakeUniqueCursorPtr<ScanAllCursor<decltype(vertices)>>(
|
||||
mem, output_symbol_, input_->MakeCursor(mem), std::move(vertices));
|
||||
@ -567,7 +566,7 @@ auto UnwrapEdgesResult(storage::Result<TEdges> &&result) {
|
||||
Expand::Expand(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, Symbol node_symbol, Symbol edge_symbol,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
bool existing_node, storage::View view)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
input_symbol_(input_symbol),
|
||||
@ -712,16 +711,14 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) {
|
||||
}
|
||||
}
|
||||
|
||||
ExpandVariable::ExpandVariable(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, Symbol node_symbol,
|
||||
Symbol edge_symbol, EdgeAtom::Type type,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
bool is_reverse, Expression *lower_bound,
|
||||
Expression *upper_bound, bool existing_node,
|
||||
ExpansionLambda filter_lambda,
|
||||
std::optional<ExpansionLambda> weight_lambda,
|
||||
std::optional<Symbol> total_weight)
|
||||
ExpandVariable::ExpandVariable(
|
||||
const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Type type,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types, bool is_reverse,
|
||||
Expression *lower_bound, Expression *upper_bound, bool existing_node,
|
||||
ExpansionLambda filter_lambda, std::optional<ExpansionLambda> weight_lambda,
|
||||
std::optional<Symbol> total_weight)
|
||||
: input_(input ? input : std::make_shared<Once>()),
|
||||
input_symbol_(input_symbol),
|
||||
common_{node_symbol, edge_symbol, direction, edge_types, existing_node},
|
||||
@ -784,7 +781,7 @@ size_t UnwrapDegreeResult(storage::Result<size_t> maybe_degree) {
|
||||
*/
|
||||
auto ExpandFromVertex(const VertexAccessor &vertex,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
utils::MemoryResource *memory) {
|
||||
// wraps an EdgeAccessor into a pair <accessor, direction>
|
||||
auto wrapper = [](EdgeAtom::Direction direction, auto &&edges) {
|
||||
@ -2042,7 +2039,7 @@ void Delete::DeleteCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
void Delete::DeleteCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
SetProperty::SetProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||
storage::Property property, PropertyLookup *lhs,
|
||||
storage::PropertyId property, PropertyLookup *lhs,
|
||||
Expression *rhs)
|
||||
: input_(input), property_(property), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
@ -2255,7 +2252,7 @@ void SetProperties::SetPropertiesCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
SetLabels::SetLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol,
|
||||
const std::vector<storage::Label> &labels)
|
||||
const std::vector<storage::LabelId> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(SetLabels)
|
||||
@ -2308,7 +2305,8 @@ void SetLabels::SetLabelsCursor::Shutdown() { input_cursor_->Shutdown(); }
|
||||
void SetLabels::SetLabelsCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
RemoveProperty::RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||
storage::Property property, PropertyLookup *lhs)
|
||||
storage::PropertyId property,
|
||||
PropertyLookup *lhs)
|
||||
: input_(input), property_(property), lhs_(lhs) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(RemoveProperty)
|
||||
@ -2385,7 +2383,7 @@ void RemoveProperty::RemovePropertyCursor::Reset() { input_cursor_->Reset(); }
|
||||
|
||||
RemoveLabels::RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol,
|
||||
const std::vector<storage::Label> &labels)
|
||||
const std::vector<storage::LabelId> &labels)
|
||||
: input_(input), input_symbol_(input_symbol), labels_(labels) {}
|
||||
|
||||
ACCEPT_WITH_INPUT(RemoveLabels)
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "query/frontend/ast/ast.hpp"
|
||||
#include "query/frontend/semantic/symbol.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/common/types/types.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
#include "utils/bound.hpp"
|
||||
#include "utils/future.hpp"
|
||||
#include "utils/hashing/fnv.hpp"
|
||||
@ -336,7 +336,7 @@ and false on every following Pull.")
|
||||
slk::Load(&size, reader);
|
||||
self->${member}.resize(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
storage::Property prop;
|
||||
storage::PropertyId prop;
|
||||
slk::Load(&prop, reader);
|
||||
auto *expr = query::LoadAstPointer<query::Expression>(
|
||||
&helper->ast_storage, reader);
|
||||
@ -346,8 +346,8 @@ and false on every following Pull.")
|
||||
|
||||
(lcp:define-struct node-creation-info ()
|
||||
((symbol "Symbol")
|
||||
(labels "std::vector<storage::Label>")
|
||||
(properties "std::vector<std::pair<storage::Property, Expression *>>"
|
||||
(labels "std::vector<storage::LabelId>")
|
||||
(properties "std::vector<std::pair<storage::PropertyId, Expression *>>"
|
||||
:slk-save #'slk-save-properties
|
||||
:slk-load #'slk-load-properties))
|
||||
(:serialize (:slk :save-args '((helper "query::plan::LogicalOperator::SaveHelper *"))
|
||||
@ -417,10 +417,10 @@ a preceeding `MATCH`), or multiple nodes (`MATCH ... CREATE` or
|
||||
|
||||
(lcp:define-struct edge-creation-info ()
|
||||
((symbol "Symbol")
|
||||
(properties "std::vector<std::pair<storage::Property, Expression *>>"
|
||||
(properties "std::vector<std::pair<storage::PropertyId, Expression *>>"
|
||||
:slk-save #'slk-save-properties
|
||||
:slk-load #'slk-load-properties)
|
||||
(edge-type "::storage::EdgeType")
|
||||
(edge-type "::storage::EdgeTypeId")
|
||||
(direction "::EdgeAtom::Direction" :initval "EdgeAtom::Direction::BOTH"))
|
||||
(:serialize (:slk :save-args '((helper "query::plan::LogicalOperator::SaveHelper *"))
|
||||
:load-args '((helper "query::plan::LogicalOperator::SlkLoadHelper *"))))
|
||||
@ -564,7 +564,7 @@ with a constructor argument.
|
||||
(:clone))
|
||||
|
||||
(lcp:define-class scan-all-by-label (scan-all)
|
||||
((label "::storage::Label" :scope :public))
|
||||
((label "::storage::LabelId" :scope :public))
|
||||
(:documentation
|
||||
"Behaves like @c ScanAll, but this operator produces only vertices with
|
||||
given label.
|
||||
@ -576,7 +576,7 @@ given label.
|
||||
#>cpp
|
||||
ScanAllByLabel() {}
|
||||
ScanAllByLabel(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::View view = storage::View::OLD);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
@ -642,8 +642,8 @@ given label.
|
||||
cpp<#)
|
||||
|
||||
(lcp:define-class scan-all-by-label-property-range (scan-all)
|
||||
((label "::storage::Label" :scope :public)
|
||||
(property "::storage::Property" :scope :public)
|
||||
((label "::storage::LabelId" :scope :public)
|
||||
(property "::storage::PropertyId" :scope :public)
|
||||
(property-name "std::string" :scope :public)
|
||||
(lower-bound "std::optional<Bound>" :scope :public
|
||||
:slk-save #'slk-save-optional-bound
|
||||
@ -680,8 +680,8 @@ property value which is inside a range (inclusive or exlusive).
|
||||
* @param view storage::View used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyRange(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
storage::Property property,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::PropertyId property,
|
||||
const std::string &property_name,
|
||||
std::optional<Bound> lower_bound,
|
||||
std::optional<Bound> upper_bound,
|
||||
@ -694,8 +694,8 @@ property value which is inside a range (inclusive or exlusive).
|
||||
(:clone))
|
||||
|
||||
(lcp:define-class scan-all-by-label-property-value (scan-all)
|
||||
((label "::storage::Label" :scope :public)
|
||||
(property "::storage::Property" :scope :public)
|
||||
((label "::storage::LabelId" :scope :public)
|
||||
(property "::storage::PropertyId" :scope :public)
|
||||
(property-name "std::string" :scope :public)
|
||||
(expression "Expression *" :scope :public
|
||||
:slk-save #'slk-save-ast-pointer
|
||||
@ -721,8 +721,8 @@ property value.
|
||||
* @param view storage::View used when obtaining vertices.
|
||||
*/
|
||||
ScanAllByLabelPropertyValue(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol output_symbol, storage::Label label,
|
||||
storage::Property property,
|
||||
Symbol output_symbol, storage::LabelId label,
|
||||
storage::PropertyId property,
|
||||
const std::string &property_name,
|
||||
Expression *expression,
|
||||
storage::View view = storage::View::OLD);
|
||||
@ -764,8 +764,8 @@ This is where a TypedValue containing a list of expanded edges will be stored.")
|
||||
(direction "::EdgeAtom::Direction"
|
||||
:documentation "EdgeAtom::Direction determining the direction of edge
|
||||
expansion. The direction is relative to the starting vertex for each expansion.")
|
||||
(edge-types "std::vector<storage::EdgeType>"
|
||||
:documentation "storage::EdgeType specifying which edges we want
|
||||
(edge-types "std::vector<storage::EdgeTypeId>"
|
||||
:documentation "storage::EdgeTypeId 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.")
|
||||
(existing-node :bool :documentation "If the given node atom refer to a symbol
|
||||
@ -806,7 +806,7 @@ pulled.")
|
||||
*/
|
||||
Expand(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
Symbol node_symbol, Symbol edge_symbol, EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types, bool existing_node,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types, bool existing_node,
|
||||
storage::View view);
|
||||
|
||||
Expand() {}
|
||||
@ -953,7 +953,7 @@ pulled.")
|
||||
ExpandVariable(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, Symbol node_symbol, Symbol edge_symbol,
|
||||
EdgeAtom::Type type, EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
bool is_reverse, Expression *lower_bound,
|
||||
Expression *upper_bound, bool existing_node,
|
||||
ExpansionLambda filter_lambda,
|
||||
@ -1159,7 +1159,7 @@ Has a flag for using DETACH DELETE when deleting vertices.")
|
||||
((input "std::shared_ptr<LogicalOperator>" :scope :public
|
||||
:slk-save #'slk-save-operator-pointer
|
||||
:slk-load #'slk-load-operator-pointer)
|
||||
(property "::storage::Property" :scope :public)
|
||||
(property "::storage::PropertyId" :scope :public)
|
||||
(lhs "PropertyLookup *" :scope :public
|
||||
:slk-save #'slk-save-ast-pointer
|
||||
:slk-load (slk-load-ast-pointer "PropertyLookup"))
|
||||
@ -1176,7 +1176,7 @@ can be stored (a TypedValue that can be converted to PropertyValue).")
|
||||
SetProperty() {}
|
||||
|
||||
SetProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||
storage::Property property, PropertyLookup *lhs,
|
||||
storage::PropertyId property, PropertyLookup *lhs,
|
||||
Expression *rhs);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
@ -1269,7 +1269,7 @@ that the old properties are discarded and replaced with new ones.")
|
||||
:slk-save #'slk-save-operator-pointer
|
||||
:slk-load #'slk-load-operator-pointer)
|
||||
(input-symbol "Symbol" :scope :public)
|
||||
(labels "std::vector<storage::Label>" :scope :public))
|
||||
(labels "std::vector<storage::LabelId>" :scope :public))
|
||||
(:documentation
|
||||
"Logical operator for setting an arbitrary number of labels on a Vertex.
|
||||
|
||||
@ -1279,7 +1279,7 @@ It does NOT remove labels that are already set on that Vertex.")
|
||||
SetLabels() {}
|
||||
|
||||
SetLabels(const std::shared_ptr<LogicalOperator> &input, Symbol input_symbol,
|
||||
const std::vector<storage::Label> &labels);
|
||||
const std::vector<storage::LabelId> &labels);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -1311,7 +1311,7 @@ It does NOT remove labels that are already set on that Vertex.")
|
||||
((input "std::shared_ptr<LogicalOperator>" :scope :public
|
||||
:slk-save #'slk-save-operator-pointer
|
||||
:slk-load #'slk-load-operator-pointer)
|
||||
(property "::storage::Property" :scope :public)
|
||||
(property "::storage::PropertyId" :scope :public)
|
||||
(lhs "PropertyLookup *" :scope :public
|
||||
:slk-save #'slk-save-ast-pointer
|
||||
:slk-load (slk-load-ast-pointer "PropertyLookup")))
|
||||
@ -1322,7 +1322,7 @@ It does NOT remove labels that are already set on that Vertex.")
|
||||
RemoveProperty() {}
|
||||
|
||||
RemoveProperty(const std::shared_ptr<LogicalOperator> &input,
|
||||
storage::Property property, PropertyLookup *lhs);
|
||||
storage::PropertyId property, PropertyLookup *lhs);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
@ -1355,7 +1355,7 @@ It does NOT remove labels that are already set on that Vertex.")
|
||||
:slk-save #'slk-save-operator-pointer
|
||||
:slk-load #'slk-load-operator-pointer)
|
||||
(input-symbol "Symbol" :scope :public)
|
||||
(labels "std::vector<storage::Label>" :scope :public))
|
||||
(labels "std::vector<storage::LabelId>" :scope :public))
|
||||
(:documentation
|
||||
"Logical operator for removing an arbitrary number of labels on a Vertex.
|
||||
|
||||
@ -1365,7 +1365,7 @@ If a label does not exist on a Vertex, nothing happens.")
|
||||
RemoveLabels() {}
|
||||
|
||||
RemoveLabels(const std::shared_ptr<LogicalOperator> &input,
|
||||
Symbol input_symbol, const std::vector<storage::Label> &labels);
|
||||
Symbol input_symbol, const std::vector<storage::LabelId> &labels);
|
||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||
|
@ -332,15 +332,15 @@ json ToJson(const utils::Bound<Expression *> &bound) {
|
||||
|
||||
json ToJson(const Symbol &symbol) { return symbol.name(); }
|
||||
|
||||
json ToJson(storage::EdgeType edge_type, const DbAccessor &dba) {
|
||||
json ToJson(storage::EdgeTypeId edge_type, const DbAccessor &dba) {
|
||||
return dba.EdgeTypeToName(edge_type);
|
||||
}
|
||||
|
||||
json ToJson(storage::Label label, const DbAccessor &dba) {
|
||||
json ToJson(storage::LabelId label, const DbAccessor &dba) {
|
||||
return dba.LabelToName(label);
|
||||
}
|
||||
|
||||
json ToJson(storage::Property property, const DbAccessor &dba) {
|
||||
json ToJson(storage::PropertyId property, const DbAccessor &dba) {
|
||||
return dba.PropertyToName(property);
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ json ToJson(NamedExpression *nexpr) {
|
||||
}
|
||||
|
||||
json ToJson(
|
||||
const std::vector<std::pair<storage::Property, Expression *>> &properties,
|
||||
const std::vector<std::pair<storage::PropertyId, Expression *>> &properties,
|
||||
const DbAccessor &dba) {
|
||||
json json;
|
||||
for (const auto &prop_pair : properties) {
|
||||
|
@ -120,16 +120,16 @@ nlohmann::json ToJson(const utils::Bound<Expression *> &bound);
|
||||
|
||||
nlohmann::json ToJson(const Symbol &symbol);
|
||||
|
||||
nlohmann::json ToJson(storage::EdgeType edge_type, const DbAccessor &dba);
|
||||
nlohmann::json ToJson(storage::EdgeTypeId edge_type, const DbAccessor &dba);
|
||||
|
||||
nlohmann::json ToJson(storage::Label label, const DbAccessor &dba);
|
||||
nlohmann::json ToJson(storage::LabelId label, const DbAccessor &dba);
|
||||
|
||||
nlohmann::json ToJson(storage::Property property, const DbAccessor &dba);
|
||||
nlohmann::json ToJson(storage::PropertyId property, const DbAccessor &dba);
|
||||
|
||||
nlohmann::json ToJson(NamedExpression *nexpr);
|
||||
|
||||
nlohmann::json ToJson(
|
||||
const std::vector<std::pair<storage::Property, Expression *>> &properties,
|
||||
const std::vector<std::pair<storage::PropertyId, Expression *>> &properties,
|
||||
const DbAccessor &dba);
|
||||
|
||||
nlohmann::json ToJson(const NodeCreationInfo &node_info, const DbAccessor &dba);
|
||||
|
@ -439,11 +439,11 @@ class IndexLookupRewriter final : public HierarchicalLogicalOperatorVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
storage::Label GetLabel(LabelIx label) {
|
||||
storage::LabelId GetLabel(LabelIx label) {
|
||||
return db_->NameToLabel(label.name);
|
||||
}
|
||||
|
||||
storage::Property GetProperty(PropertyIx prop) {
|
||||
storage::PropertyId GetProperty(PropertyIx prop) {
|
||||
return db_->NameToProperty(prop.name);
|
||||
}
|
||||
|
||||
|
@ -238,15 +238,15 @@ class RuleBasedPlanner {
|
||||
private:
|
||||
TPlanningContext *context_;
|
||||
|
||||
storage::Label GetLabel(LabelIx label) {
|
||||
storage::LabelId GetLabel(LabelIx label) {
|
||||
return context_->db->NameToLabel(label.name);
|
||||
}
|
||||
|
||||
storage::Property GetProperty(PropertyIx prop) {
|
||||
storage::PropertyId GetProperty(PropertyIx prop) {
|
||||
return context_->db->NameToProperty(prop.name);
|
||||
}
|
||||
|
||||
storage::EdgeType GetEdgeType(EdgeTypeIx edge_type) {
|
||||
storage::EdgeTypeId GetEdgeType(EdgeTypeIx edge_type) {
|
||||
return context_->db->NameToEdgeType(edge_type.name);
|
||||
}
|
||||
|
||||
@ -268,12 +268,12 @@ class RuleBasedPlanner {
|
||||
std::unordered_set<Symbol> &bound_symbols) {
|
||||
auto node_to_creation_info = [&](const NodeAtom &node) {
|
||||
const auto &node_symbol = symbol_table.at(*node.identifier_);
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
labels.reserve(node.labels_.size());
|
||||
for (const auto &label : node.labels_) {
|
||||
labels.push_back(GetLabel(label));
|
||||
}
|
||||
std::vector<std::pair<storage::Property, Expression *>> properties;
|
||||
std::vector<std::pair<storage::PropertyId, Expression *>> properties;
|
||||
properties.reserve(node.properties_.size());
|
||||
for (const auto &kv : node.properties_) {
|
||||
properties.push_back({GetProperty(kv.first), kv.second});
|
||||
@ -306,7 +306,7 @@ class RuleBasedPlanner {
|
||||
LOG(FATAL) << "Symbols used for created edges cannot be redeclared.";
|
||||
}
|
||||
auto node_info = node_to_creation_info(*node);
|
||||
std::vector<std::pair<storage::Property, Expression *>> properties;
|
||||
std::vector<std::pair<storage::PropertyId, Expression *>> properties;
|
||||
properties.reserve(edge->properties_.size());
|
||||
for (const auto &kv : edge->properties_) {
|
||||
properties.push_back({GetProperty(kv.first), kv.second});
|
||||
@ -362,7 +362,7 @@ class RuleBasedPlanner {
|
||||
std::move(input_op), input_symbol, set->expression_, op);
|
||||
} else if (auto *set = utils::Downcast<query::SetLabels>(clause)) {
|
||||
const auto &input_symbol = symbol_table.at(*set->identifier_);
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
labels.reserve(set->labels_.size());
|
||||
for (const auto &label : set->labels_) {
|
||||
labels.push_back(GetLabel(label));
|
||||
@ -375,7 +375,7 @@ class RuleBasedPlanner {
|
||||
rem->property_lookup_);
|
||||
} else if (auto *rem = utils::Downcast<query::RemoveLabels>(clause)) {
|
||||
const auto &input_symbol = symbol_table.at(*rem->identifier_);
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
labels.reserve(rem->labels_.size());
|
||||
for (const auto &label : rem->labels_) {
|
||||
labels.push_back(GetLabel(label));
|
||||
@ -427,7 +427,7 @@ class RuleBasedPlanner {
|
||||
const auto &edge_symbol = symbol_table.at(*edge->identifier_);
|
||||
CHECK(!utils::Contains(bound_symbols, edge_symbol))
|
||||
<< "Existing edges are not supported";
|
||||
std::vector<storage::EdgeType> edge_types;
|
||||
std::vector<storage::EdgeTypeId> edge_types;
|
||||
edge_types.reserve(edge->edge_types_.size());
|
||||
for (const auto &type : edge->edge_types_) {
|
||||
edge_types.push_back(GetEdgeType(type));
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <optional>
|
||||
|
||||
#include "query/typed_value.hpp"
|
||||
#include "storage/common/types/property_value.hpp"
|
||||
#include "storage/common/types/types.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
#include "storage/v2/property_value.hpp"
|
||||
#include "utils/bound.hpp"
|
||||
#include "utils/hashing/fnv.hpp"
|
||||
|
||||
@ -31,13 +31,13 @@ class VertexCountCache {
|
||||
return *vertices_count_;
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label) {
|
||||
int64_t VerticesCount(storage::LabelId label) {
|
||||
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(storage::Label label, storage::Property property) {
|
||||
int64_t VerticesCount(storage::LabelId label, storage::PropertyId property) {
|
||||
auto key = std::make_pair(label, property);
|
||||
if (label_property_vertex_count_.find(key) ==
|
||||
label_property_vertex_count_.end())
|
||||
@ -45,8 +45,8 @@ class VertexCountCache {
|
||||
return label_property_vertex_count_.at(key);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label, storage::Property property,
|
||||
const PropertyValue &value) {
|
||||
int64_t VerticesCount(storage::LabelId label, storage::PropertyId property,
|
||||
const storage::PropertyValue &value) {
|
||||
auto label_prop = std::make_pair(label, property);
|
||||
auto &value_vertex_count = property_value_vertex_count_[label_prop];
|
||||
// TODO: Why do we even need TypedValue in this whole file?
|
||||
@ -57,9 +57,9 @@ class VertexCountCache {
|
||||
}
|
||||
|
||||
int64_t VerticesCount(
|
||||
storage::Label label, storage::Property property,
|
||||
const std::optional<utils::Bound<PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<PropertyValue>> &upper) {
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &lower,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> &upper) {
|
||||
auto label_prop = std::make_pair(label, property);
|
||||
auto &bounds_vertex_count = property_bounds_vertex_count_[label_prop];
|
||||
BoundsKey bounds = std::make_pair(lower, upper);
|
||||
@ -69,27 +69,27 @@ class VertexCountCache {
|
||||
return bounds_vertex_count.at(bounds);
|
||||
}
|
||||
|
||||
bool LabelIndexExists(storage::Label label) {
|
||||
bool LabelIndexExists(storage::LabelId label) {
|
||||
return db_->LabelIndexExists(label);
|
||||
}
|
||||
|
||||
bool LabelPropertyIndexExists(storage::Label label,
|
||||
storage::Property property) {
|
||||
bool LabelPropertyIndexExists(storage::LabelId label,
|
||||
storage::PropertyId property) {
|
||||
return db_->LabelPropertyIndexExists(label, property);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::pair<storage::Label, storage::Property> LabelPropertyKey;
|
||||
typedef std::pair<storage::LabelId, storage::PropertyId> LabelPropertyKey;
|
||||
|
||||
struct LabelPropertyHash {
|
||||
size_t operator()(const LabelPropertyKey &key) const {
|
||||
return utils::HashCombine<storage::Label, storage::Property>{}(
|
||||
return utils::HashCombine<storage::LabelId, storage::PropertyId>{}(
|
||||
key.first, key.second);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::pair<std::optional<utils::Bound<PropertyValue>>,
|
||||
std::optional<utils::Bound<PropertyValue>>>
|
||||
typedef std::pair<std::optional<utils::Bound<storage::PropertyValue>>,
|
||||
std::optional<utils::Bound<storage::PropertyValue>>>
|
||||
BoundsKey;
|
||||
|
||||
struct BoundsHash {
|
||||
@ -124,7 +124,7 @@ class VertexCountCache {
|
||||
|
||||
TDbAccessor *db_;
|
||||
std::optional<int64_t> vertices_count_;
|
||||
std::unordered_map<storage::Label, int64_t> label_vertex_count_;
|
||||
std::unordered_map<storage::LabelId, int64_t> label_vertex_count_;
|
||||
std::unordered_map<LabelPropertyKey, int64_t, LabelPropertyHash>
|
||||
label_property_vertex_count_;
|
||||
std::unordered_map<
|
||||
|
@ -300,29 +300,29 @@ mgp_value::mgp_value(const query::TypedValue &tv, const mgp_graph *graph,
|
||||
}
|
||||
}
|
||||
|
||||
mgp_value::mgp_value(const PropertyValue &pv, utils::MemoryResource *m)
|
||||
mgp_value::mgp_value(const storage::PropertyValue &pv, utils::MemoryResource *m)
|
||||
: memory(m) {
|
||||
switch (pv.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
type = MGP_VALUE_TYPE_NULL;
|
||||
break;
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
type = MGP_VALUE_TYPE_BOOL;
|
||||
bool_v = pv.ValueBool();
|
||||
break;
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
type = MGP_VALUE_TYPE_INT;
|
||||
int_v = pv.ValueInt();
|
||||
break;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
type = MGP_VALUE_TYPE_DOUBLE;
|
||||
double_v = pv.ValueDouble();
|
||||
break;
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
type = MGP_VALUE_TYPE_STRING;
|
||||
new (&string_v) utils::pmr::string(pv.ValueString(), m);
|
||||
break;
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
// Fill the stack allocated container and then construct the actual member
|
||||
// value. This handles the case when filling the container throws
|
||||
// something and our destructor doesn't get called so member value isn't
|
||||
@ -337,7 +337,7 @@ mgp_value::mgp_value(const PropertyValue &pv, utils::MemoryResource *m)
|
||||
list_v = allocator.new_object<mgp_list>(std::move(elems));
|
||||
break;
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
// Fill the stack allocated container and then construct the actual member
|
||||
// value. This handles the case when filling the container throws
|
||||
// something and our destructor doesn't get called so member value isn't
|
||||
@ -922,7 +922,7 @@ mgp_label mgp_vertex_label_at(const mgp_vertex *v, size_t i) {
|
||||
}
|
||||
|
||||
int mgp_vertex_has_label_named(const mgp_vertex *v, const char *name) {
|
||||
storage::Label label;
|
||||
storage::LabelId label;
|
||||
try {
|
||||
// This will allocate a std::string from `name`, which may throw
|
||||
// std::bad_alloc or std::length_error. This could be avoided with a
|
||||
|
@ -58,9 +58,9 @@ struct mgp_value {
|
||||
mgp_value(const query::TypedValue &, const mgp_graph *,
|
||||
utils::MemoryResource *);
|
||||
|
||||
/// Construct by copying PropertyValue using utils::MemoryResource.
|
||||
/// Construct by copying storage::PropertyValue using utils::MemoryResource.
|
||||
/// @throw std::bad_alloc
|
||||
mgp_value(const PropertyValue &, utils::MemoryResource *);
|
||||
mgp_value(const storage::PropertyValue &, utils::MemoryResource *);
|
||||
|
||||
/// Copy construction without utils::MemoryResource is not allowed.
|
||||
mgp_value(const mgp_value &) = delete;
|
||||
@ -468,7 +468,6 @@ struct mgp_vertices_iterator {
|
||||
decltype(graph->impl->Vertices(graph->view)) vertices;
|
||||
decltype(vertices.begin()) current_it;
|
||||
std::optional<mgp_vertex> current_v;
|
||||
|
||||
};
|
||||
|
||||
struct mgp_type {
|
||||
|
@ -14,34 +14,34 @@
|
||||
|
||||
namespace query {
|
||||
|
||||
TypedValue::TypedValue(const PropertyValue &value)
|
||||
// TODO: MemoryResource in PropertyValue
|
||||
TypedValue::TypedValue(const storage::PropertyValue &value)
|
||||
// TODO: MemoryResource in storage::PropertyValue
|
||||
: TypedValue(value, utils::NewDeleteResource()) {}
|
||||
|
||||
TypedValue::TypedValue(const PropertyValue &value,
|
||||
TypedValue::TypedValue(const storage::PropertyValue &value,
|
||||
utils::MemoryResource *memory)
|
||||
: memory_(memory) {
|
||||
switch (value.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
type_ = Type::Null;
|
||||
return;
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
type_ = Type::Bool;
|
||||
bool_v = value.ValueBool();
|
||||
return;
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
type_ = Type::Int;
|
||||
int_v = value.ValueInt();
|
||||
return;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
type_ = Type::Double;
|
||||
double_v = value.ValueDouble();
|
||||
return;
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
type_ = Type::String;
|
||||
new (&string_v) TString(value.ValueString(), memory_);
|
||||
return;
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
type_ = Type::List;
|
||||
const auto &vec = value.ValueList();
|
||||
new (&list_v) TVector(memory_);
|
||||
@ -49,7 +49,7 @@ TypedValue::TypedValue(const PropertyValue &value,
|
||||
for (const auto &v : vec) list_v.emplace_back(v);
|
||||
return;
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
type_ = Type::Map;
|
||||
const auto &map = value.ValueMap();
|
||||
new (&map_v) TMap(memory_);
|
||||
@ -60,33 +60,34 @@ TypedValue::TypedValue(const PropertyValue &value,
|
||||
LOG(FATAL) << "Unsupported type";
|
||||
}
|
||||
|
||||
TypedValue::TypedValue(PropertyValue &&other) /* noexcept */
|
||||
// TODO: MemoryResource in PropertyValue, so this can be noexcept
|
||||
TypedValue::TypedValue(storage::PropertyValue &&other) /* noexcept */
|
||||
// TODO: MemoryResource in storage::PropertyValue, so this can be noexcept
|
||||
: TypedValue(std::move(other), utils::NewDeleteResource()) {}
|
||||
|
||||
TypedValue::TypedValue(PropertyValue &&other, utils::MemoryResource *memory)
|
||||
TypedValue::TypedValue(storage::PropertyValue &&other,
|
||||
utils::MemoryResource *memory)
|
||||
: memory_(memory) {
|
||||
switch (other.type()) {
|
||||
case PropertyValue::Type::Null:
|
||||
case storage::PropertyValue::Type::Null:
|
||||
type_ = Type::Null;
|
||||
break;
|
||||
case PropertyValue::Type::Bool:
|
||||
case storage::PropertyValue::Type::Bool:
|
||||
type_ = Type::Bool;
|
||||
bool_v = other.ValueBool();
|
||||
break;
|
||||
case PropertyValue::Type::Int:
|
||||
case storage::PropertyValue::Type::Int:
|
||||
type_ = Type::Int;
|
||||
int_v = other.ValueInt();
|
||||
break;
|
||||
case PropertyValue::Type::Double:
|
||||
case storage::PropertyValue::Type::Double:
|
||||
type_ = Type::Double;
|
||||
double_v = other.ValueDouble();
|
||||
break;
|
||||
case PropertyValue::Type::String:
|
||||
case storage::PropertyValue::Type::String:
|
||||
type_ = Type::String;
|
||||
new (&string_v) TString(other.ValueString(), memory_);
|
||||
break;
|
||||
case PropertyValue::Type::List: {
|
||||
case storage::PropertyValue::Type::List: {
|
||||
type_ = Type::List;
|
||||
auto &vec = other.ValueList();
|
||||
new (&list_v) TVector(memory_);
|
||||
@ -94,7 +95,7 @@ TypedValue::TypedValue(PropertyValue &&other, utils::MemoryResource *memory)
|
||||
for (auto &v : vec) list_v.emplace_back(std::move(v));
|
||||
break;
|
||||
}
|
||||
case PropertyValue::Type::Map: {
|
||||
case storage::PropertyValue::Type::Map: {
|
||||
type_ = Type::Map;
|
||||
auto &map = other.ValueMap();
|
||||
new (&map_v) TMap(memory_);
|
||||
@ -103,7 +104,7 @@ TypedValue::TypedValue(PropertyValue &&other, utils::MemoryResource *memory)
|
||||
}
|
||||
}
|
||||
|
||||
other = PropertyValue();
|
||||
other = storage::PropertyValue();
|
||||
}
|
||||
|
||||
TypedValue::TypedValue(const TypedValue &other)
|
||||
@ -186,25 +187,25 @@ TypedValue::TypedValue(TypedValue &&other, utils::MemoryResource *memory)
|
||||
other.DestroyValue();
|
||||
}
|
||||
|
||||
TypedValue::operator PropertyValue() const {
|
||||
TypedValue::operator storage::PropertyValue() const {
|
||||
switch (type_) {
|
||||
case TypedValue::Type::Null:
|
||||
return PropertyValue();
|
||||
return storage::PropertyValue();
|
||||
case TypedValue::Type::Bool:
|
||||
return PropertyValue(bool_v);
|
||||
return storage::PropertyValue(bool_v);
|
||||
case TypedValue::Type::Int:
|
||||
return PropertyValue(int_v);
|
||||
return storage::PropertyValue(int_v);
|
||||
case TypedValue::Type::Double:
|
||||
return PropertyValue(double_v);
|
||||
return storage::PropertyValue(double_v);
|
||||
case TypedValue::Type::String:
|
||||
return PropertyValue(std::string(string_v));
|
||||
return storage::PropertyValue(std::string(string_v));
|
||||
case TypedValue::Type::List:
|
||||
return PropertyValue(
|
||||
std::vector<PropertyValue>(list_v.begin(), list_v.end()));
|
||||
return storage::PropertyValue(
|
||||
std::vector<storage::PropertyValue>(list_v.begin(), list_v.end()));
|
||||
case TypedValue::Type::Map: {
|
||||
std::map<std::string, PropertyValue> map;
|
||||
std::map<std::string, storage::PropertyValue> map;
|
||||
for (const auto &kv : map_v) map.emplace(kv.first, kv.second);
|
||||
return PropertyValue(std::move(map));
|
||||
return storage::PropertyValue(std::move(map));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@ -475,33 +476,33 @@ TypedValue &TypedValue::operator=(TypedValue &&other) noexcept(false) {
|
||||
|
||||
void TypedValue::DestroyValue() {
|
||||
switch (type_) {
|
||||
// destructor for primitive types does nothing
|
||||
case Type::Null:
|
||||
case Type::Bool:
|
||||
case Type::Int:
|
||||
case Type::Double:
|
||||
break;
|
||||
// destructor for primitive types does nothing
|
||||
case Type::Null:
|
||||
case Type::Bool:
|
||||
case Type::Int:
|
||||
case Type::Double:
|
||||
break;
|
||||
|
||||
// we need to call destructors for non primitive types since we used
|
||||
// placement new
|
||||
case Type::String:
|
||||
string_v.~TString();
|
||||
break;
|
||||
case Type::List:
|
||||
list_v.~TVector();
|
||||
break;
|
||||
case Type::Map:
|
||||
map_v.~TMap();
|
||||
break;
|
||||
case Type::Vertex:
|
||||
vertex_v.~VertexAccessor();
|
||||
break;
|
||||
case Type::Edge:
|
||||
edge_v.~EdgeAccessor();
|
||||
break;
|
||||
case Type::Path:
|
||||
path_v.~Path();
|
||||
break;
|
||||
// we need to call destructors for non primitive types since we used
|
||||
// placement new
|
||||
case Type::String:
|
||||
string_v.~TString();
|
||||
break;
|
||||
case Type::List:
|
||||
list_v.~TVector();
|
||||
break;
|
||||
case Type::Map:
|
||||
map_v.~TMap();
|
||||
break;
|
||||
case Type::Vertex:
|
||||
vertex_v.~VertexAccessor();
|
||||
break;
|
||||
case Type::Edge:
|
||||
edge_v.~EdgeAccessor();
|
||||
break;
|
||||
case Type::Path:
|
||||
path_v.~Path();
|
||||
break;
|
||||
}
|
||||
|
||||
type_ = TypedValue::Type::Null;
|
||||
|
@ -140,8 +140,8 @@ class TypedValue {
|
||||
double_v = value;
|
||||
}
|
||||
|
||||
// conversion function to PropertyValue
|
||||
explicit operator PropertyValue() const;
|
||||
// conversion function to storage::PropertyValue
|
||||
explicit operator storage::PropertyValue() const;
|
||||
|
||||
// copy constructors for non-primitive types
|
||||
explicit TypedValue(const std::string &value, utils::MemoryResource *memory =
|
||||
@ -262,10 +262,11 @@ class TypedValue {
|
||||
}
|
||||
|
||||
/** Construct a copy using default utils::NewDeleteResource() */
|
||||
explicit TypedValue(const PropertyValue &value);
|
||||
explicit TypedValue(const storage::PropertyValue &value);
|
||||
|
||||
/** Construct a copy using the given utils::MemoryResource */
|
||||
TypedValue(const PropertyValue &value, utils::MemoryResource *memory);
|
||||
TypedValue(const storage::PropertyValue &value,
|
||||
utils::MemoryResource *memory);
|
||||
|
||||
// move constructors for non-primitive types
|
||||
|
||||
@ -408,13 +409,13 @@ class TypedValue {
|
||||
* Default utils::NewDeleteResource() is used for allocations. After the move,
|
||||
* other will be set to Null.
|
||||
*/
|
||||
explicit TypedValue(PropertyValue &&other);
|
||||
explicit TypedValue(storage::PropertyValue &&other);
|
||||
|
||||
/**
|
||||
* Construct with the value of other, but use the given utils::MemoryResource.
|
||||
* After the move, other will be set to Null.
|
||||
*/
|
||||
TypedValue(PropertyValue &&other, utils::MemoryResource *memory);
|
||||
TypedValue(storage::PropertyValue &&other, utils::MemoryResource *memory);
|
||||
|
||||
// copy assignment operators
|
||||
TypedValue &operator=(const char *);
|
||||
@ -490,7 +491,7 @@ class TypedValue {
|
||||
bool IsNumeric() const;
|
||||
|
||||
/** Convenience function for checking if this TypedValue can be converted into
|
||||
* PropertyValue */
|
||||
* storage::PropertyValue */
|
||||
bool IsPropertyValue() const;
|
||||
|
||||
utils::MemoryResource *GetMemoryResource() const { return memory_; }
|
||||
|
@ -99,7 +99,7 @@ static auto CreateIndexedVertices(int index_count, int vertex_count,
|
||||
for (int index = 0; index < index_count; ++index) {
|
||||
auto vertex = dba.CreateVertex();
|
||||
CHECK(vertex.AddLabel(label).HasValue());
|
||||
CHECK(vertex.SetProperty(prop, PropertyValue(index)).HasValue());
|
||||
CHECK(vertex.SetProperty(prop, storage::PropertyValue(index)).HasValue());
|
||||
}
|
||||
}
|
||||
CHECK(!dba.Commit().HasError());
|
||||
|
@ -143,7 +143,7 @@ class InteractiveDbAccessor {
|
||||
|
||||
int64_t VerticesCount() { return vertices_count_; }
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id) {
|
||||
int64_t VerticesCount(storage::LabelId label_id) {
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
if (label_vertex_count_.find(label) == label_vertex_count_.end()) {
|
||||
label_vertex_count_[label] = ReadVertexCount("label '" + label + "'");
|
||||
@ -151,8 +151,8 @@ class InteractiveDbAccessor {
|
||||
return label_vertex_count_.at(label);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id,
|
||||
storage::Property property_id) {
|
||||
int64_t VerticesCount(storage::LabelId label_id,
|
||||
storage::PropertyId property_id) {
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
@ -164,8 +164,9 @@ class InteractiveDbAccessor {
|
||||
return label_property_vertex_count_.at(key);
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label_id, storage::Property property_id,
|
||||
const PropertyValue &value) {
|
||||
int64_t VerticesCount(storage::LabelId label_id,
|
||||
storage::PropertyId property_id,
|
||||
const storage::PropertyValue &value) {
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto label_prop = std::make_pair(label, property);
|
||||
@ -184,9 +185,9 @@ class InteractiveDbAccessor {
|
||||
}
|
||||
|
||||
int64_t VerticesCount(
|
||||
storage::Label label_id, storage::Property property_id,
|
||||
const std::optional<utils::Bound<PropertyValue>> lower,
|
||||
const std::optional<utils::Bound<PropertyValue>> upper) {
|
||||
storage::LabelId label_id, storage::PropertyId property_id,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> lower,
|
||||
const std::optional<utils::Bound<storage::PropertyValue>> upper) {
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
std::stringstream range_string;
|
||||
@ -203,10 +204,10 @@ class InteractiveDbAccessor {
|
||||
"' in range " + range_string.str());
|
||||
}
|
||||
|
||||
bool LabelIndexExists(storage::Label label) { return true; }
|
||||
bool LabelIndexExists(storage::LabelId label) { return true; }
|
||||
|
||||
bool LabelPropertyIndexExists(storage::Label label_id,
|
||||
storage::Property property_id) {
|
||||
bool LabelPropertyIndexExists(storage::LabelId label_id,
|
||||
storage::PropertyId property_id) {
|
||||
auto label = dba_->LabelToName(label_id);
|
||||
auto property = dba_->PropertyToName(property_id);
|
||||
auto key = std::make_pair(label, property);
|
||||
|
@ -198,7 +198,7 @@ class Database {
|
||||
virtual std::unique_ptr<query::plan::LogicalOperator> MakeBfsOperator(
|
||||
query::Symbol source_sym, query::Symbol sink_sym, query::Symbol edge_sym,
|
||||
query::EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
const std::shared_ptr<query::plan::LogicalOperator> &input,
|
||||
bool existing_node, query::Expression *lower_bound,
|
||||
query::Expression *upper_bound,
|
||||
@ -344,7 +344,7 @@ void BfsTest(Database *db, int lower_bound, int upper_bound,
|
||||
// We block each entity in the graph and run BFS.
|
||||
input_op = YieldEntities(&dba, vertices, edges, blocked_sym, nullptr);
|
||||
filter_expr = IF(AND(NEQ(inner_node, blocked), NEQ(inner_edge, blocked)),
|
||||
LITERAL(true), LITERAL(PropertyValue()));
|
||||
LITERAL(true), LITERAL(storage::PropertyValue()));
|
||||
break;
|
||||
case FilterLambdaType::USE_CTX:
|
||||
// We only block vertex #5 and run BFS.
|
||||
@ -354,7 +354,7 @@ void BfsTest(Database *db, int lower_bound, int upper_bound,
|
||||
{query::TypedValue(vertices[5])}});
|
||||
filter_expr = NEQ(PROPERTY_LOOKUP(inner_node, PROPERTY_PAIR("id")),
|
||||
PARAMETER_LOOKUP(0));
|
||||
context.evaluation_context.parameters.Add(0, PropertyValue(5));
|
||||
context.evaluation_context.parameters.Add(0, storage::PropertyValue(5));
|
||||
break;
|
||||
case FilterLambdaType::ERROR:
|
||||
// Evaluate to 42 for vertex #5 which is on worker 1.
|
||||
@ -372,7 +372,7 @@ void BfsTest(Database *db, int lower_bound, int upper_bound,
|
||||
input_op = YieldVertices(&dba, vertices, sink_sym, input_op);
|
||||
}
|
||||
|
||||
std::vector<storage::EdgeType> storage_edge_types;
|
||||
std::vector<storage::EdgeTypeId> storage_edge_types;
|
||||
for (const auto &t : edge_types) {
|
||||
storage_edge_types.push_back(dba.NameToEdgeType(t));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ class SingleNodeDb : public Database {
|
||||
std::unique_ptr<LogicalOperator> MakeBfsOperator(
|
||||
Symbol source_sym, Symbol sink_sym, Symbol edge_sym,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
const std::shared_ptr<LogicalOperator> &input, bool existing_node,
|
||||
Expression *lower_bound, Expression *upper_bound,
|
||||
const ExpansionLambda &filter_lambda) override {
|
||||
@ -34,7 +34,7 @@ class SingleNodeDb : public Database {
|
||||
auto vertex = dba->InsertVertex();
|
||||
CHECK(vertex
|
||||
.SetProperty(dba->NameToProperty("id"),
|
||||
PropertyValue(static_cast<int64_t>(id)))
|
||||
storage::PropertyValue(static_cast<int64_t>(id)))
|
||||
.HasValue());
|
||||
vertex_addr.push_back(vertex);
|
||||
}
|
||||
@ -46,9 +46,11 @@ class SingleNodeDb : public Database {
|
||||
auto &from = vertex_addr[u];
|
||||
auto &to = vertex_addr[v];
|
||||
auto edge = dba->InsertEdge(&from, &to, dba->NameToEdgeType(type));
|
||||
CHECK(edge->SetProperty(dba->NameToProperty("from"), PropertyValue(u))
|
||||
CHECK(edge->SetProperty(dba->NameToProperty("from"),
|
||||
storage::PropertyValue(u))
|
||||
.HasValue());
|
||||
CHECK(edge->SetProperty(dba->NameToProperty("to"), PropertyValue(v))
|
||||
CHECK(edge->SetProperty(dba->NameToProperty("to"),
|
||||
storage::PropertyValue(v))
|
||||
.HasValue());
|
||||
edge_addr.push_back(*edge);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ TEST(BoltEncoder, VertexAndEdge) {
|
||||
ASSERT_TRUE(va1.AddLabel(l2).HasValue());
|
||||
auto p1 = dba.NameToProperty("prop1");
|
||||
auto p2 = dba.NameToProperty("prop2");
|
||||
PropertyValue pv1(12), pv2(200);
|
||||
storage::PropertyValue pv1(12), pv2(200);
|
||||
ASSERT_TRUE(va1.SetProperty(p1, pv1).HasValue());
|
||||
ASSERT_TRUE(va1.SetProperty(p2, pv2).HasValue());
|
||||
|
||||
@ -182,7 +182,7 @@ TEST(BoltEncoder, VertexAndEdge) {
|
||||
auto ea = dba.CreateEdge(&va1, &va2, et);
|
||||
auto p3 = dba.NameToProperty("prop3");
|
||||
auto p4 = dba.NameToProperty("prop4");
|
||||
PropertyValue pv3(42), pv4(1234);
|
||||
storage::PropertyValue pv3(42), pv4(1234);
|
||||
ASSERT_TRUE(ea->SetProperty(p3, pv3).HasValue());
|
||||
ASSERT_TRUE(ea->SetProperty(p4, pv4).HasValue());
|
||||
|
||||
|
@ -36,8 +36,9 @@ class InterpreterTest : public ::testing::Test {
|
||||
*
|
||||
* Return the query stream.
|
||||
*/
|
||||
auto Interpret(const std::string &query,
|
||||
const std::map<std::string, PropertyValue> ¶ms = {}) {
|
||||
auto Interpret(
|
||||
const std::string &query,
|
||||
const std::map<std::string, storage::PropertyValue> ¶ms = {}) {
|
||||
ResultStreamFaker stream(&db_);
|
||||
|
||||
auto [header, _] = interpreter_.Prepare(query, params);
|
||||
@ -109,8 +110,9 @@ TEST_F(InterpreterTest, AstCache) {
|
||||
// Run query with same ast multiple times with different parameters.
|
||||
TEST_F(InterpreterTest, Parameters) {
|
||||
{
|
||||
auto stream = Interpret("RETURN $2 + $`a b`", {{"2", PropertyValue(10)},
|
||||
{"a b", PropertyValue(15)}});
|
||||
auto stream =
|
||||
Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue(10)},
|
||||
{"a b", storage::PropertyValue(15)}});
|
||||
ASSERT_EQ(stream.GetHeader().size(), 1U);
|
||||
EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`");
|
||||
ASSERT_EQ(stream.GetResults().size(), 1U);
|
||||
@ -119,9 +121,10 @@ TEST_F(InterpreterTest, Parameters) {
|
||||
}
|
||||
{
|
||||
// Not needed parameter.
|
||||
auto stream = Interpret("RETURN $2 + $`a b`", {{"2", PropertyValue(10)},
|
||||
{"a b", PropertyValue(15)},
|
||||
{"c", PropertyValue(10)}});
|
||||
auto stream =
|
||||
Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue(10)},
|
||||
{"a b", storage::PropertyValue(15)},
|
||||
{"c", storage::PropertyValue(10)}});
|
||||
ASSERT_EQ(stream.GetHeader().size(), 1U);
|
||||
EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`");
|
||||
ASSERT_EQ(stream.GetResults().size(), 1U);
|
||||
@ -130,9 +133,9 @@ TEST_F(InterpreterTest, Parameters) {
|
||||
}
|
||||
{
|
||||
// Cached ast, different parameters.
|
||||
auto stream =
|
||||
Interpret("RETURN $2 + $`a b`",
|
||||
{{"2", PropertyValue("da")}, {"a b", PropertyValue("ne")}});
|
||||
auto stream = Interpret("RETURN $2 + $`a b`",
|
||||
{{"2", storage::PropertyValue("da")},
|
||||
{"a b", storage::PropertyValue("ne")}});
|
||||
ASSERT_EQ(stream.GetResults().size(), 1U);
|
||||
ASSERT_EQ(stream.GetResults()[0].size(), 1U);
|
||||
ASSERT_EQ(stream.GetResults()[0][0].ValueString(), "dane");
|
||||
@ -141,8 +144,9 @@ TEST_F(InterpreterTest, Parameters) {
|
||||
// Non-primitive literal.
|
||||
auto stream = Interpret(
|
||||
"RETURN $2",
|
||||
{{"2", PropertyValue(std::vector<PropertyValue>{
|
||||
PropertyValue(5), PropertyValue(2), PropertyValue(3)})}});
|
||||
{{"2", storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(5), storage::PropertyValue(2),
|
||||
storage::PropertyValue(3)})}});
|
||||
ASSERT_EQ(stream.GetResults().size(), 1U);
|
||||
ASSERT_EQ(stream.GetResults()[0].size(), 1U);
|
||||
auto result = query::test_common::ToIntList(
|
||||
@ -151,9 +155,10 @@ TEST_F(InterpreterTest, Parameters) {
|
||||
}
|
||||
{
|
||||
// Cached ast, unprovided parameter.
|
||||
ASSERT_THROW(Interpret("RETURN $2 + $`a b`", {{"2", PropertyValue("da")},
|
||||
{"ab", PropertyValue("ne")}}),
|
||||
query::UnprovidedParameterError);
|
||||
ASSERT_THROW(
|
||||
Interpret("RETURN $2 + $`a b`", {{"2", storage::PropertyValue("da")},
|
||||
{"ab", storage::PropertyValue("ne")}}),
|
||||
query::UnprovidedParameterError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,10 +182,11 @@ TEST_F(InterpreterTest, Bfs) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
auto add_node = [&](int level, bool reachable) {
|
||||
auto node = dba.InsertVertex();
|
||||
CHECK(node.SetProperty(dba.NameToProperty(kId), PropertyValue(id++))
|
||||
CHECK(node.SetProperty(dba.NameToProperty(kId),
|
||||
storage::PropertyValue(id++))
|
||||
.HasValue());
|
||||
CHECK(node.SetProperty(dba.NameToProperty(kReachable),
|
||||
PropertyValue(reachable))
|
||||
storage::PropertyValue(reachable))
|
||||
.HasValue());
|
||||
levels[level].push_back(node);
|
||||
return node;
|
||||
@ -189,7 +195,7 @@ TEST_F(InterpreterTest, Bfs) {
|
||||
auto add_edge = [&](auto &v1, auto &v2, bool reachable) {
|
||||
auto edge = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge"));
|
||||
CHECK(edge->SetProperty(dba.NameToProperty(kReachable),
|
||||
PropertyValue(reachable))
|
||||
storage::PropertyValue(reachable))
|
||||
.HasValue());
|
||||
};
|
||||
|
||||
@ -361,7 +367,7 @@ TEST_F(InterpreterTest, ExplainQueryWithParams) {
|
||||
EXPECT_EQ(interpreter_context_.plan_cache.size(), 0U);
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 0U);
|
||||
auto stream = Interpret("EXPLAIN MATCH (n) WHERE n.id = $id RETURN *;",
|
||||
{{"id", PropertyValue(42)}});
|
||||
{{"id", storage::PropertyValue(42)}});
|
||||
ASSERT_EQ(stream.GetHeader().size(), 1U);
|
||||
EXPECT_EQ(stream.GetHeader().front(), "QUERY PLAN");
|
||||
std::vector<std::string> expected_rows{" * Produce {n}", " * Filter",
|
||||
@ -378,7 +384,7 @@ TEST_F(InterpreterTest, ExplainQueryWithParams) {
|
||||
// We should have AST cache for EXPLAIN ... and for inner MATCH ...
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U);
|
||||
Interpret("MATCH (n) WHERE n.id = $id RETURN *;",
|
||||
{{"id", PropertyValue("something else")}});
|
||||
{{"id", storage::PropertyValue("something else")}});
|
||||
EXPECT_EQ(interpreter_context_.plan_cache.size(), 1U);
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U);
|
||||
}
|
||||
@ -411,7 +417,7 @@ TEST_F(InterpreterTest, ProfileQueryWithParams) {
|
||||
EXPECT_EQ(interpreter_context_.plan_cache.size(), 0U);
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 0U);
|
||||
auto stream = Interpret("PROFILE MATCH (n) WHERE n.id = $id RETURN *;",
|
||||
{{"id", PropertyValue(42)}});
|
||||
{{"id", storage::PropertyValue(42)}});
|
||||
std::vector<std::string> expected_header{"OPERATOR", "ACTUAL HITS",
|
||||
"RELATIVE TIME", "ABSOLUTE TIME"};
|
||||
EXPECT_EQ(stream.GetHeader(), expected_header);
|
||||
@ -429,7 +435,7 @@ TEST_F(InterpreterTest, ProfileQueryWithParams) {
|
||||
// We should have AST cache for PROFILE ... and for inner MATCH ...
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U);
|
||||
Interpret("MATCH (n) WHERE n.id = $id RETURN *;",
|
||||
{{"id", PropertyValue("something else")}});
|
||||
{{"id", storage::PropertyValue("something else")}});
|
||||
EXPECT_EQ(interpreter_context_.plan_cache.size(), 1U);
|
||||
EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class QueryCostEstimator : public ::testing::Test {
|
||||
template <typename TValue>
|
||||
Expression *Parameter(TValue value) {
|
||||
int token_position = parameters_.size();
|
||||
parameters_.Add(token_position, PropertyValue(value));
|
||||
parameters_.Add(token_position, storage::PropertyValue(value));
|
||||
return storage_.Create<ParameterLookup>(token_position);
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,13 @@ struct DatabaseState {
|
||||
struct Vertex {
|
||||
int64_t id;
|
||||
std::set<std::string> labels;
|
||||
std::map<std::string, PropertyValue> props;
|
||||
std::map<std::string, storage::PropertyValue> props;
|
||||
};
|
||||
|
||||
struct Edge {
|
||||
int64_t from, to;
|
||||
std::string edge_type;
|
||||
std::map<std::string, PropertyValue> props;
|
||||
std::map<std::string, storage::PropertyValue> props;
|
||||
};
|
||||
|
||||
struct LabelItem {
|
||||
@ -120,7 +120,7 @@ DatabaseState GetState(storage::Storage *db) {
|
||||
for (const auto &label : *maybe_labels) {
|
||||
labels.insert(dba.LabelToName(label));
|
||||
}
|
||||
std::map<std::string, PropertyValue> props;
|
||||
std::map<std::string, storage::PropertyValue> props;
|
||||
auto maybe_properties = vertex.Properties(storage::View::NEW);
|
||||
CHECK(maybe_properties.HasValue());
|
||||
for (const auto &kv : *maybe_properties) {
|
||||
@ -139,7 +139,7 @@ DatabaseState GetState(storage::Storage *db) {
|
||||
CHECK(maybe_edges.HasValue());
|
||||
for (const auto &edge : *maybe_edges) {
|
||||
const auto &edge_type_name = dba.EdgeTypeToName(edge.EdgeType());
|
||||
std::map<std::string, PropertyValue> props;
|
||||
std::map<std::string, storage::PropertyValue> props;
|
||||
auto maybe_properties = edge.Properties(storage::View::NEW);
|
||||
CHECK(maybe_properties.HasValue());
|
||||
for (const auto &kv : *maybe_properties) {
|
||||
@ -192,10 +192,10 @@ auto Execute(storage::Storage *db, const std::string &query) {
|
||||
return stream;
|
||||
}
|
||||
|
||||
VertexAccessor CreateVertex(storage::Storage::Accessor *dba,
|
||||
const std::vector<std::string> &labels,
|
||||
const std::map<std::string, PropertyValue> &props,
|
||||
bool add_property_id = true) {
|
||||
VertexAccessor CreateVertex(
|
||||
storage::Storage::Accessor *dba, const std::vector<std::string> &labels,
|
||||
const std::map<std::string, storage::PropertyValue> &props,
|
||||
bool add_property_id = true) {
|
||||
CHECK(dba);
|
||||
auto vertex = dba->CreateVertex();
|
||||
for (const auto &label_name : labels) {
|
||||
@ -208,16 +208,17 @@ VertexAccessor CreateVertex(storage::Storage::Accessor *dba,
|
||||
if (add_property_id) {
|
||||
CHECK(vertex
|
||||
.SetProperty(dba->NameToProperty(kPropertyId),
|
||||
PropertyValue(vertex.Gid().AsInt()))
|
||||
storage::PropertyValue(vertex.Gid().AsInt()))
|
||||
.HasValue());
|
||||
}
|
||||
return vertex;
|
||||
}
|
||||
|
||||
EdgeAccessor CreateEdge(storage::Storage::Accessor *dba, VertexAccessor *from,
|
||||
VertexAccessor *to, const std::string &edge_type_name,
|
||||
const std::map<std::string, PropertyValue> &props,
|
||||
bool add_property_id = true) {
|
||||
EdgeAccessor CreateEdge(
|
||||
storage::Storage::Accessor *dba, VertexAccessor *from, VertexAccessor *to,
|
||||
const std::string &edge_type_name,
|
||||
const std::map<std::string, storage::PropertyValue> &props,
|
||||
bool add_property_id = true) {
|
||||
CHECK(dba);
|
||||
auto edge = dba->CreateEdge(from, to, dba->NameToEdgeType(edge_type_name));
|
||||
CHECK(edge.HasValue());
|
||||
@ -227,7 +228,7 @@ EdgeAccessor CreateEdge(storage::Storage::Accessor *dba, VertexAccessor *from,
|
||||
}
|
||||
if (add_property_id) {
|
||||
CHECK(edge->SetProperty(dba->NameToProperty(kPropertyId),
|
||||
PropertyValue(edge->Gid().AsInt()))
|
||||
storage::PropertyValue(edge->Gid().AsInt()))
|
||||
.HasValue());
|
||||
}
|
||||
return *edge;
|
||||
@ -335,7 +336,7 @@ TEST(DumpTest, VertexWithSingleProperty) {
|
||||
storage::Storage db;
|
||||
{
|
||||
auto dba = db.Access();
|
||||
CreateVertex(&dba, {}, {{"prop", PropertyValue(42)}}, false);
|
||||
CreateVertex(&dba, {}, {{"prop", storage::PropertyValue(42)}}, false);
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
|
||||
@ -453,7 +454,8 @@ TEST(DumpTest, EdgeWithProperties) {
|
||||
auto dba = db.Access();
|
||||
auto u = CreateVertex(&dba, {}, {}, false);
|
||||
auto v = CreateVertex(&dba, {}, {}, false);
|
||||
CreateEdge(&dba, &u, &v, "EdgeType", {{"prop", PropertyValue(13)}}, false);
|
||||
CreateEdge(&dba, &u, &v, "EdgeType", {{"prop", storage::PropertyValue(13)}},
|
||||
false);
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
|
||||
@ -480,7 +482,8 @@ TEST(DumpTest, IndicesKeys) {
|
||||
storage::Storage db;
|
||||
{
|
||||
auto dba = db.Access();
|
||||
CreateVertex(&dba, {"Label1", "Label2"}, {{"p", PropertyValue(1)}}, false);
|
||||
CreateVertex(&dba, {"Label1", "Label2"}, {{"p", storage::PropertyValue(1)}},
|
||||
false);
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
ASSERT_TRUE(
|
||||
@ -508,7 +511,7 @@ TEST(DumpTest, ExistenceConstraints) {
|
||||
storage::Storage db;
|
||||
{
|
||||
auto dba = db.Access();
|
||||
CreateVertex(&dba, {"Label"}, {{"prop", PropertyValue(1)}}, false);
|
||||
CreateVertex(&dba, {"Label"}, {{"prop", storage::PropertyValue(1)}}, false);
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
{
|
||||
@ -539,11 +542,12 @@ TEST(DumpTest, CheckStateVertexWithMultipleProperties) {
|
||||
storage::Storage db;
|
||||
{
|
||||
auto dba = db.Access();
|
||||
std::map<std::string, PropertyValue> prop1 = {
|
||||
{"nested1", PropertyValue(1337)}, {"nested2", PropertyValue(3.14)}};
|
||||
CreateVertex(
|
||||
&dba, {"Label1", "Label2"},
|
||||
{{"prop1", PropertyValue(prop1)}, {"prop2", PropertyValue("$'\t'")}});
|
||||
std::map<std::string, storage::PropertyValue> prop1 = {
|
||||
{"nested1", storage::PropertyValue(1337)},
|
||||
{"nested2", storage::PropertyValue(3.14)}};
|
||||
CreateVertex(&dba, {"Label1", "Label2"},
|
||||
{{"prop1", storage::PropertyValue(prop1)},
|
||||
{"prop2", storage::PropertyValue("$'\t'")}});
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
|
||||
@ -572,22 +576,28 @@ TEST(DumpTest, CheckStateSimpleGraph) {
|
||||
storage::Storage db;
|
||||
{
|
||||
auto dba = db.Access();
|
||||
auto u = CreateVertex(&dba, {"Person"}, {{"name", PropertyValue("Ivan")}});
|
||||
auto v = CreateVertex(&dba, {"Person"}, {{"name", PropertyValue("Josko")}});
|
||||
auto w = CreateVertex(
|
||||
&dba, {"Person"},
|
||||
{{"name", PropertyValue("Bosko")}, {"id", PropertyValue(0)}});
|
||||
auto z = CreateVertex(
|
||||
&dba, {"Person"},
|
||||
{{"name", PropertyValue("Buha")}, {"id", PropertyValue(1)}});
|
||||
auto u = CreateVertex(&dba, {"Person"},
|
||||
{{"name", storage::PropertyValue("Ivan")}});
|
||||
auto v = CreateVertex(&dba, {"Person"},
|
||||
{{"name", storage::PropertyValue("Josko")}});
|
||||
auto w = CreateVertex(&dba, {"Person"},
|
||||
{{"name", storage::PropertyValue("Bosko")},
|
||||
{"id", storage::PropertyValue(0)}});
|
||||
auto z = CreateVertex(&dba, {"Person"},
|
||||
{{"name", storage::PropertyValue("Buha")},
|
||||
{"id", storage::PropertyValue(1)}});
|
||||
CreateEdge(&dba, &u, &v, "Knows", {});
|
||||
CreateEdge(&dba, &v, &w, "Knows", {{"how_long", PropertyValue(5)}});
|
||||
CreateEdge(&dba, &w, &u, "Knows", {{"how", PropertyValue("distant past")}});
|
||||
CreateEdge(&dba, &v, &w, "Knows",
|
||||
{{"how_long", storage::PropertyValue(5)}});
|
||||
CreateEdge(&dba, &w, &u, "Knows",
|
||||
{{"how", storage::PropertyValue("distant past")}});
|
||||
CreateEdge(&dba, &v, &u, "Knows", {});
|
||||
CreateEdge(&dba, &v, &u, "Likes", {});
|
||||
CreateEdge(&dba, &z, &u, "Knows", {});
|
||||
CreateEdge(&dba, &w, &z, "Knows", {{"how", PropertyValue("school")}});
|
||||
CreateEdge(&dba, &w, &z, "Likes", {{"how", PropertyValue("very much")}});
|
||||
CreateEdge(&dba, &w, &z, "Knows",
|
||||
{{"how", storage::PropertyValue("school")}});
|
||||
CreateEdge(&dba, &w, &z, "Likes",
|
||||
{{"how", storage::PropertyValue("very much")}});
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
{
|
||||
|
@ -121,20 +121,20 @@ TEST_F(ExpressionEvaluatorTest, AndOperatorNull) {
|
||||
{
|
||||
// Null doesn't short circuit
|
||||
auto *op = storage.Create<AndOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(5));
|
||||
EXPECT_THROW(Eval(op), QueryRuntimeException);
|
||||
}
|
||||
{
|
||||
auto *op = storage.Create<AndOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(true));
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
}
|
||||
{
|
||||
auto *op = storage.Create<AndOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(false));
|
||||
auto value = Eval(op);
|
||||
ASSERT_TRUE(value.IsBool());
|
||||
@ -295,7 +295,7 @@ TEST_F(ExpressionEvaluatorTest, InListOperator) {
|
||||
}
|
||||
{
|
||||
auto *list_literal = storage.Create<ListLiteral>(std::vector<Expression *>{
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(2),
|
||||
storage.Create<PrimitiveLiteral>("a")});
|
||||
// Element doesn't exist in list with null element.
|
||||
@ -308,21 +308,22 @@ TEST_F(ExpressionEvaluatorTest, InListOperator) {
|
||||
// Null list.
|
||||
auto *op = storage.Create<InListOperator>(
|
||||
storage.Create<PrimitiveLiteral>("x"),
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
}
|
||||
{
|
||||
// Null literal.
|
||||
auto *op = storage.Create<InListOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()), list_literal);
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
list_literal);
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
}
|
||||
{
|
||||
// Null literal, empty list.
|
||||
auto *op = storage.Create<InListOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<ListLiteral>(std::vector<Expression *>()));
|
||||
auto value = Eval(op);
|
||||
EXPECT_FALSE(value.ValueBool());
|
||||
@ -365,7 +366,7 @@ TEST_F(ExpressionEvaluatorTest, ListIndexing) {
|
||||
{
|
||||
// Indexing with one operator being null.
|
||||
auto *op = storage.Create<SubscriptOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(-2));
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
@ -407,7 +408,8 @@ TEST_F(ExpressionEvaluatorTest, MapIndexing) {
|
||||
{
|
||||
// Indexing with Null.
|
||||
auto *op = storage.Create<SubscriptOperator>(
|
||||
map_literal, storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
map_literal,
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
}
|
||||
@ -419,8 +421,8 @@ TEST_F(ExpressionEvaluatorTest, VertexAndEdgeIndexing) {
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto e11 = dba.InsertEdge(&v1, &v1, edge_type);
|
||||
ASSERT_TRUE(e11.HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(e11->SetProperty(prop, PropertyValue(43)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(e11->SetProperty(prop, storage::PropertyValue(43)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
auto *vertex_id = CreateIdentifierWithValue("v1", TypedValue(v1));
|
||||
@ -462,12 +464,12 @@ TEST_F(ExpressionEvaluatorTest, VertexAndEdgeIndexing) {
|
||||
{
|
||||
// Indexing with Null.
|
||||
auto *op1 = storage.Create<SubscriptOperator>(
|
||||
vertex_id, storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
vertex_id, storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto value1 = Eval(op1);
|
||||
EXPECT_TRUE(value1.IsNull());
|
||||
|
||||
auto *op2 = storage.Create<SubscriptOperator>(
|
||||
edge_id, storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
edge_id, storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto value2 = Eval(op2);
|
||||
EXPECT_TRUE(value2.IsNull());
|
||||
}
|
||||
@ -535,7 +537,8 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) {
|
||||
{
|
||||
// Bound of illegal type and null value bound.
|
||||
auto *op = storage.Create<ListSlicingOperator>(
|
||||
list_literal, storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
list_literal,
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>("mirko"));
|
||||
EXPECT_THROW(Eval(op), QueryRuntimeException);
|
||||
}
|
||||
@ -549,7 +552,7 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) {
|
||||
{
|
||||
// Null value list with undefined upper bound.
|
||||
auto *op = storage.Create<ListSlicingOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()),
|
||||
storage.Create<PrimitiveLiteral>(-2), nullptr);
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
@ -559,7 +562,7 @@ TEST_F(ExpressionEvaluatorTest, ListSlicingOperator) {
|
||||
// Null value index.
|
||||
auto *op = storage.Create<ListSlicingOperator>(
|
||||
list_literal, storage.Create<PrimitiveLiteral>(-2),
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto value = Eval(op);
|
||||
EXPECT_TRUE(value.IsNull());
|
||||
;
|
||||
@ -624,7 +627,7 @@ TEST_F(ExpressionEvaluatorTest, IsNullOperator) {
|
||||
auto val1 = Eval(op);
|
||||
ASSERT_EQ(val1.ValueBool(), false);
|
||||
op = storage.Create<IsNullOperator>(
|
||||
storage.Create<PrimitiveLiteral>(PropertyValue()));
|
||||
storage.Create<PrimitiveLiteral>(storage::PropertyValue()));
|
||||
auto val2 = Eval(op);
|
||||
ASSERT_EQ(val2.ValueBool(), true);
|
||||
}
|
||||
@ -693,7 +696,7 @@ TEST_F(ExpressionEvaluatorTest, ListLiteral) {
|
||||
}
|
||||
|
||||
TEST_F(ExpressionEvaluatorTest, ParameterLookup) {
|
||||
ctx.parameters.Add(0, PropertyValue(42));
|
||||
ctx.parameters.Add(0, storage::PropertyValue(42));
|
||||
auto *param_lookup = storage.Create<ParameterLookup>(0);
|
||||
auto value = Eval(param_lookup);
|
||||
ASSERT_TRUE(value.IsInt());
|
||||
@ -715,7 +718,7 @@ TEST_F(ExpressionEvaluatorTest, All) {
|
||||
|
||||
TEST_F(ExpressionEvaluatorTest, FunctionAllNullList) {
|
||||
AstStorage storage;
|
||||
auto *all = ALL("x", LITERAL(PropertyValue()), WHERE(LITERAL(true)));
|
||||
auto *all = ALL("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true)));
|
||||
const auto x_sym = symbol_table.CreateSymbol("x", true);
|
||||
all->identifier_->MapTo(x_sym);
|
||||
auto value = Eval(all);
|
||||
@ -758,7 +761,8 @@ TEST_F(ExpressionEvaluatorTest, FunctionSingle2) {
|
||||
|
||||
TEST_F(ExpressionEvaluatorTest, FunctionSingleNullList) {
|
||||
AstStorage storage;
|
||||
auto *single = SINGLE("x", LITERAL(PropertyValue()), WHERE(LITERAL(true)));
|
||||
auto *single =
|
||||
SINGLE("x", LITERAL(storage::PropertyValue()), WHERE(LITERAL(true)));
|
||||
const auto x_sym = symbol_table.CreateSymbol("x", true);
|
||||
single->identifier_->MapTo(x_sym);
|
||||
auto value = Eval(single);
|
||||
@ -785,9 +789,9 @@ TEST_F(ExpressionEvaluatorTest, FunctionReduce) {
|
||||
TEST_F(ExpressionEvaluatorTest, FunctionExtract) {
|
||||
AstStorage storage;
|
||||
auto *ident_x = IDENT("x");
|
||||
auto *extract =
|
||||
EXTRACT("x", LIST(LITERAL(1), LITERAL(2), LITERAL(PropertyValue())),
|
||||
ADD(ident_x, LITERAL(1)));
|
||||
auto *extract = EXTRACT(
|
||||
"x", LIST(LITERAL(1), LITERAL(2), LITERAL(storage::PropertyValue())),
|
||||
ADD(ident_x, LITERAL(1)));
|
||||
const auto x_sym = symbol_table.CreateSymbol("x", true);
|
||||
extract->identifier_->MapTo(x_sym);
|
||||
ident_x->MapTo(x_sym);
|
||||
@ -804,7 +808,7 @@ TEST_F(ExpressionEvaluatorTest, FunctionExtractNull) {
|
||||
AstStorage storage;
|
||||
auto *ident_x = IDENT("x");
|
||||
auto *extract =
|
||||
EXTRACT("x", LITERAL(PropertyValue()), ADD(ident_x, LITERAL(1)));
|
||||
EXTRACT("x", LITERAL(storage::PropertyValue()), ADD(ident_x, LITERAL(1)));
|
||||
const auto x_sym = symbol_table.CreateSymbol("x", true);
|
||||
extract->identifier_->MapTo(x_sym);
|
||||
ident_x->MapTo(x_sym);
|
||||
@ -897,16 +901,16 @@ TEST_F(ExpressionEvaluatorTest, RegexMatch) {
|
||||
|
||||
class ExpressionEvaluatorPropertyLookup : public ExpressionEvaluatorTest {
|
||||
protected:
|
||||
std::pair<std::string, storage::Property> prop_age =
|
||||
std::pair<std::string, storage::PropertyId> prop_age =
|
||||
std::make_pair("age", dba.NameToProperty("age"));
|
||||
std::pair<std::string, storage::Property> prop_height =
|
||||
std::pair<std::string, storage::PropertyId> prop_height =
|
||||
std::make_pair("height", dba.NameToProperty("height"));
|
||||
Identifier *identifier = storage.Create<Identifier>("element");
|
||||
Symbol symbol = symbol_table.CreateSymbol("element", true);
|
||||
|
||||
void SetUp() { identifier->MapTo(symbol); }
|
||||
|
||||
auto Value(std::pair<std::string, storage::Property> property) {
|
||||
auto Value(std::pair<std::string, storage::PropertyId> property) {
|
||||
auto *op = storage.Create<PropertyLookup>(
|
||||
identifier, storage.GetPropertyIx(property.first));
|
||||
return Eval(op);
|
||||
@ -915,7 +919,8 @@ class ExpressionEvaluatorPropertyLookup : public ExpressionEvaluatorTest {
|
||||
|
||||
TEST_F(ExpressionEvaluatorPropertyLookup, Vertex) {
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(prop_age.second, PropertyValue(10)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(prop_age.second, storage::PropertyValue(10)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
frame[symbol] = TypedValue(v1);
|
||||
EXPECT_EQ(Value(prop_age).ValueInt(), 10);
|
||||
@ -927,7 +932,8 @@ TEST_F(ExpressionEvaluatorPropertyLookup, Edge) {
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto e12 = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("edge_type"));
|
||||
ASSERT_TRUE(e12.HasValue());
|
||||
ASSERT_TRUE(e12->SetProperty(prop_age.second, PropertyValue(10)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
e12->SetProperty(prop_age.second, storage::PropertyValue(10)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
frame[symbol] = TypedValue(*e12);
|
||||
EXPECT_EQ(Value(prop_age).ValueInt(), 10);
|
||||
@ -1025,17 +1031,21 @@ TEST_F(FunctionTest, Properties) {
|
||||
ASSERT_THROW(EvaluateFunction("PROPERTIES"), QueryRuntimeException);
|
||||
ASSERT_TRUE(EvaluateFunction("PROPERTIES", TypedValue()).IsNull());
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), PropertyValue(5))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(dba.NameToProperty("age"), PropertyValue(10)).HasValue());
|
||||
v1.SetProperty(dba.NameToProperty("height"), storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(dba.NameToProperty("age"), storage::PropertyValue(10))
|
||||
.HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("type1"));
|
||||
ASSERT_TRUE(e.HasValue());
|
||||
ASSERT_TRUE(e->SetProperty(dba.NameToProperty("height"), PropertyValue(3))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
e->SetProperty(dba.NameToProperty("age"), PropertyValue(15)).HasValue());
|
||||
e->SetProperty(dba.NameToProperty("height"), storage::PropertyValue(3))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
e->SetProperty(dba.NameToProperty("age"), storage::PropertyValue(15))
|
||||
.HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
auto prop_values_to_int = [](TypedValue t) {
|
||||
@ -1284,17 +1294,21 @@ TEST_F(FunctionTest, Keys) {
|
||||
ASSERT_THROW(EvaluateFunction("KEYS"), QueryRuntimeException);
|
||||
ASSERT_TRUE(EvaluateFunction("KEYS", TypedValue()).IsNull());
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(dba.NameToProperty("height"), PropertyValue(5))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(dba.NameToProperty("age"), PropertyValue(10)).HasValue());
|
||||
v1.SetProperty(dba.NameToProperty("height"), storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(dba.NameToProperty("age"), storage::PropertyValue(10))
|
||||
.HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("type1"));
|
||||
ASSERT_TRUE(e.HasValue());
|
||||
ASSERT_TRUE(
|
||||
e->SetProperty(dba.NameToProperty("width"), PropertyValue(3)).HasValue());
|
||||
e->SetProperty(dba.NameToProperty("width"), storage::PropertyValue(3))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
e->SetProperty(dba.NameToProperty("age"), PropertyValue(15)).HasValue());
|
||||
e->SetProperty(dba.NameToProperty("age"), storage::PropertyValue(15))
|
||||
.HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
auto prop_keys_to_string = [](TypedValue t) {
|
||||
|
@ -31,9 +31,9 @@ TEST(QueryPlan, Accumulate) {
|
||||
auto prop = dba.NameToProperty("x");
|
||||
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(prop, PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(0)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v2.SetProperty(prop, PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop, storage::PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("T")).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -147,7 +147,7 @@ class QueryPlanAggregateOps : public ::testing::Test {
|
||||
storage::Storage db;
|
||||
storage::Storage::Accessor storage_dba{db.Access()};
|
||||
query::DbAccessor dba{&storage_dba};
|
||||
storage::Property prop = db.NameToProperty("prop");
|
||||
storage::PropertyId prop = db.NameToProperty("prop");
|
||||
|
||||
AstStorage storage;
|
||||
SymbolTable symbol_table;
|
||||
@ -156,12 +156,15 @@ class QueryPlanAggregateOps : public ::testing::Test {
|
||||
// setup is several nodes most of which have an int property set
|
||||
// we will take the sum, avg, min, max and count
|
||||
// we won't group by anything
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(prop, PropertyValue(5)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(prop, PropertyValue(7)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(prop, PropertyValue(12)).HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(prop, storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(prop, storage::PropertyValue(7))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(prop, storage::PropertyValue(12))
|
||||
.HasValue());
|
||||
// a missing property (null) gets ignored by all aggregations except
|
||||
// COUNT(*)
|
||||
dba.InsertVertex();
|
||||
@ -291,9 +294,9 @@ TEST(QueryPlan, AggregateGroupByValues) {
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
// a vector of PropertyValue to be set as property values on vertices
|
||||
// a vector of storage::PropertyValue to be set as property values on vertices
|
||||
// most of them should result in a distinct group (commented where not)
|
||||
std::vector<PropertyValue> group_by_vals;
|
||||
std::vector<storage::PropertyValue> group_by_vals;
|
||||
group_by_vals.emplace_back(4);
|
||||
group_by_vals.emplace_back(7);
|
||||
group_by_vals.emplace_back(7.3);
|
||||
@ -303,17 +306,18 @@ TEST(QueryPlan, AggregateGroupByValues) {
|
||||
group_by_vals.emplace_back("1");
|
||||
group_by_vals.emplace_back(true);
|
||||
group_by_vals.emplace_back(false);
|
||||
group_by_vals.emplace_back(std::vector<PropertyValue>{PropertyValue(1)});
|
||||
group_by_vals.emplace_back(
|
||||
std::vector<PropertyValue>{PropertyValue(1), PropertyValue(2)});
|
||||
group_by_vals.emplace_back(
|
||||
std::vector<PropertyValue>{PropertyValue(2), PropertyValue(1)});
|
||||
group_by_vals.emplace_back(PropertyValue());
|
||||
std::vector<storage::PropertyValue>{storage::PropertyValue(1)});
|
||||
group_by_vals.emplace_back(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(1), storage::PropertyValue(2)});
|
||||
group_by_vals.emplace_back(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(2), storage::PropertyValue(1)});
|
||||
group_by_vals.emplace_back(storage::PropertyValue());
|
||||
// should NOT result in another group because 7.0 == 7
|
||||
group_by_vals.emplace_back(7.0);
|
||||
// should NOT result in another group
|
||||
group_by_vals.emplace_back(
|
||||
std::vector<PropertyValue>{PropertyValue(1), PropertyValue(2.0)});
|
||||
group_by_vals.emplace_back(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(1), storage::PropertyValue(2.0)});
|
||||
|
||||
// generate a lot of vertices and set props on them
|
||||
auto prop = dba.NameToProperty("prop");
|
||||
@ -365,12 +369,13 @@ TEST(QueryPlan, AggregateMultipleGroupBy) {
|
||||
auto prop3 = dba.NameToProperty("prop3");
|
||||
for (int i = 0; i < 2 * 3 * 5; ++i) {
|
||||
auto v = dba.InsertVertex();
|
||||
ASSERT_TRUE(v.SetProperty(prop1, PropertyValue(static_cast<bool>(i % 2)))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop2, PropertyValue(i % 3)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v.SetProperty(prop3, PropertyValue("value" + std::to_string(i % 5)))
|
||||
v.SetProperty(prop1, storage::PropertyValue(static_cast<bool>(i % 2)))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop2, storage::PropertyValue(i % 3)).HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop3, storage::PropertyValue(
|
||||
"value" + std::to_string(i % 5)))
|
||||
.HasValue());
|
||||
}
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -454,7 +459,7 @@ TEST(QueryPlan, AggregateCountEdgeCases) {
|
||||
|
||||
// one vertex, property set
|
||||
for (auto va : dba.Vertices(storage::View::OLD))
|
||||
ASSERT_TRUE(va.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(va.SetProperty(prop, storage::PropertyValue(42)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_EQ(1, count());
|
||||
|
||||
@ -465,7 +470,7 @@ TEST(QueryPlan, AggregateCountEdgeCases) {
|
||||
|
||||
// two vertices, both with property set
|
||||
for (auto va : dba.Vertices(storage::View::OLD))
|
||||
ASSERT_TRUE(va.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(va.SetProperty(prop, storage::PropertyValue(42)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_EQ(2, count());
|
||||
}
|
||||
@ -480,9 +485,10 @@ TEST(QueryPlan, AggregateFirstValueTypes) {
|
||||
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto prop_string = dba.NameToProperty("string");
|
||||
ASSERT_TRUE(v1.SetProperty(prop_string, PropertyValue("johhny")).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(prop_string, storage::PropertyValue("johhny")).HasValue());
|
||||
auto prop_int = dba.NameToProperty("int");
|
||||
ASSERT_TRUE(v1.SetProperty(prop_int, PropertyValue(12)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop_int, storage::PropertyValue(12)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
AstStorage storage;
|
||||
@ -536,14 +542,19 @@ TEST(QueryPlan, AggregateTypes) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
auto p1 = dba.NameToProperty("p1"); // has only string props
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(p1, PropertyValue("string")).HasValue());
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(p1, PropertyValue("str2")).HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(p1, storage::PropertyValue("string"))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(p1, storage::PropertyValue("str2"))
|
||||
.HasValue());
|
||||
auto p2 = dba.NameToProperty("p2"); // combines int and bool
|
||||
ASSERT_TRUE(dba.InsertVertex().SetProperty(p2, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex().SetProperty(p2, PropertyValue(true)).HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(p2, storage::PropertyValue(42))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(p2, storage::PropertyValue(true))
|
||||
.HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
AstStorage storage;
|
||||
@ -597,11 +608,14 @@ TEST(QueryPlan, Unwind) {
|
||||
SymbolTable symbol_table;
|
||||
|
||||
// UNWIND [ [1, true, "x"], [], ["bla"] ] AS x UNWIND x as y RETURN x, y
|
||||
auto input_expr = storage.Create<PrimitiveLiteral>(std::vector<PropertyValue>{
|
||||
PropertyValue(std::vector<PropertyValue>{
|
||||
PropertyValue(1), PropertyValue(true), PropertyValue("x")}),
|
||||
PropertyValue(std::vector<PropertyValue>{}),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue("bla")})});
|
||||
auto input_expr =
|
||||
storage.Create<PrimitiveLiteral>(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(1), storage::PropertyValue(true),
|
||||
storage::PropertyValue("x")}),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{}),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue("bla")})});
|
||||
|
||||
auto x = symbol_table.CreateSymbol("x", true);
|
||||
auto unwind_0 = std::make_shared<plan::Unwind>(nullptr, input_expr, x);
|
||||
|
@ -118,25 +118,33 @@ TEST(QueryPlan, OrderBy) {
|
||||
|
||||
// contains a series of tests
|
||||
// each test defines the ordering a vector of values in the desired order
|
||||
auto Null = PropertyValue();
|
||||
std::vector<std::pair<Ordering, std::vector<PropertyValue>>> orderable{
|
||||
{Ordering::ASC,
|
||||
{PropertyValue(0), PropertyValue(0), PropertyValue(0.5),
|
||||
PropertyValue(1), PropertyValue(2), PropertyValue(12.6),
|
||||
PropertyValue(42), Null, Null}},
|
||||
{Ordering::ASC,
|
||||
{PropertyValue(false), PropertyValue(false), PropertyValue(true),
|
||||
PropertyValue(true), Null, Null}},
|
||||
{Ordering::ASC,
|
||||
{PropertyValue("A"), PropertyValue("B"), PropertyValue("a"),
|
||||
PropertyValue("a"), PropertyValue("aa"), PropertyValue("ab"),
|
||||
PropertyValue("aba"), Null, Null}},
|
||||
{Ordering::DESC,
|
||||
{Null, Null, PropertyValue(33), PropertyValue(33), PropertyValue(32.5),
|
||||
PropertyValue(32), PropertyValue(2.2), PropertyValue(2.1),
|
||||
PropertyValue(0)}},
|
||||
{Ordering::DESC, {Null, PropertyValue(true), PropertyValue(false)}},
|
||||
{Ordering::DESC, {Null, PropertyValue("zorro"), PropertyValue("borro")}}};
|
||||
auto Null = storage::PropertyValue();
|
||||
std::vector<std::pair<Ordering, std::vector<storage::PropertyValue>>>
|
||||
orderable{
|
||||
{Ordering::ASC,
|
||||
{storage::PropertyValue(0), storage::PropertyValue(0),
|
||||
storage::PropertyValue(0.5), storage::PropertyValue(1),
|
||||
storage::PropertyValue(2), storage::PropertyValue(12.6),
|
||||
storage::PropertyValue(42), Null, Null}},
|
||||
{Ordering::ASC,
|
||||
{storage::PropertyValue(false), storage::PropertyValue(false),
|
||||
storage::PropertyValue(true), storage::PropertyValue(true), Null,
|
||||
Null}},
|
||||
{Ordering::ASC,
|
||||
{storage::PropertyValue("A"), storage::PropertyValue("B"),
|
||||
storage::PropertyValue("a"), storage::PropertyValue("a"),
|
||||
storage::PropertyValue("aa"), storage::PropertyValue("ab"),
|
||||
storage::PropertyValue("aba"), Null, Null}},
|
||||
{Ordering::DESC,
|
||||
{Null, Null, storage::PropertyValue(33), storage::PropertyValue(33),
|
||||
storage::PropertyValue(32.5), storage::PropertyValue(32),
|
||||
storage::PropertyValue(2.2), storage::PropertyValue(2.1),
|
||||
storage::PropertyValue(0)}},
|
||||
{Ordering::DESC,
|
||||
{Null, storage::PropertyValue(true), storage::PropertyValue(false)}},
|
||||
{Ordering::DESC,
|
||||
{Null, storage::PropertyValue("zorro"),
|
||||
storage::PropertyValue("borro")}}};
|
||||
|
||||
for (const auto &order_value_pair : orderable) {
|
||||
std::vector<TypedValue> values;
|
||||
@ -164,7 +172,7 @@ TEST(QueryPlan, OrderBy) {
|
||||
// create the vertices
|
||||
for (const auto &value : shuffled)
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(prop, PropertyValue(value))
|
||||
.SetProperty(prop, storage::PropertyValue(value))
|
||||
.HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -205,8 +213,10 @@ TEST(QueryPlan, OrderByMultiple) {
|
||||
std::random_shuffle(prop_values.begin(), prop_values.end());
|
||||
for (const auto &pair : prop_values) {
|
||||
auto v = dba.InsertVertex();
|
||||
ASSERT_TRUE(v.SetProperty(p1, PropertyValue(pair.first)).HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(p2, PropertyValue(pair.second)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v.SetProperty(p1, storage::PropertyValue(pair.first)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v.SetProperty(p2, storage::PropertyValue(pair.second)).HasValue());
|
||||
}
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -251,19 +261,25 @@ TEST(QueryPlan, OrderByExceptions) {
|
||||
|
||||
// a vector of pairs of typed values that should result
|
||||
// in an exception when trying to order on them
|
||||
std::vector<std::pair<PropertyValue, PropertyValue>> exception_pairs{
|
||||
{PropertyValue(42), PropertyValue(true)},
|
||||
{PropertyValue(42), PropertyValue("bla")},
|
||||
{PropertyValue(42),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(42)})},
|
||||
{PropertyValue(true), PropertyValue("bla")},
|
||||
{PropertyValue(true),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(true)})},
|
||||
{PropertyValue("bla"),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue("bla")})},
|
||||
// illegal comparisons of same-type values
|
||||
{PropertyValue(std::vector<PropertyValue>{PropertyValue(42)}),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(42)})}};
|
||||
std::vector<std::pair<storage::PropertyValue, storage::PropertyValue>>
|
||||
exception_pairs{
|
||||
{storage::PropertyValue(42), storage::PropertyValue(true)},
|
||||
{storage::PropertyValue(42), storage::PropertyValue("bla")},
|
||||
{storage::PropertyValue(42),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(42)})},
|
||||
{storage::PropertyValue(true), storage::PropertyValue("bla")},
|
||||
{storage::PropertyValue(true),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(true)})},
|
||||
{storage::PropertyValue("bla"),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue("bla")})},
|
||||
// illegal comparisons of same-type values
|
||||
{storage::PropertyValue(
|
||||
std::vector<storage::PropertyValue>{storage::PropertyValue(42)}),
|
||||
storage::PropertyValue(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(42)})}};
|
||||
|
||||
for (const auto &pair : exception_pairs) {
|
||||
// empty database
|
||||
@ -279,7 +295,7 @@ TEST(QueryPlan, OrderByExceptions) {
|
||||
ASSERT_EQ(2, CountIterable(dba.Vertices(storage::View::OLD)));
|
||||
for (const auto &va : dba.Vertices(storage::View::OLD))
|
||||
ASSERT_NE(va.GetProperty(storage::View::OLD, prop).GetValue().type(),
|
||||
PropertyValue::Type::Null);
|
||||
storage::PropertyValue::Type::Null);
|
||||
|
||||
// order by and expect an exception
|
||||
auto n = MakeScanAll(storage, symbol_table, "n");
|
||||
|
@ -250,8 +250,8 @@ class ExpectScanAllByLabelPropertyValue
|
||||
: public OpChecker<ScanAllByLabelPropertyValue> {
|
||||
public:
|
||||
ExpectScanAllByLabelPropertyValue(
|
||||
storage::Label label,
|
||||
const std::pair<std::string, storage::Property> &prop_pair,
|
||||
storage::LabelId label,
|
||||
const std::pair<std::string, storage::PropertyId> &prop_pair,
|
||||
query::Expression *expression)
|
||||
: label_(label), property_(prop_pair.second), expression_(expression) {}
|
||||
|
||||
@ -265,8 +265,8 @@ class ExpectScanAllByLabelPropertyValue
|
||||
}
|
||||
|
||||
private:
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
storage::LabelId label_;
|
||||
storage::PropertyId property_;
|
||||
query::Expression *expression_;
|
||||
};
|
||||
|
||||
@ -274,7 +274,7 @@ class ExpectScanAllByLabelPropertyRange
|
||||
: public OpChecker<ScanAllByLabelPropertyRange> {
|
||||
public:
|
||||
ExpectScanAllByLabelPropertyRange(
|
||||
storage::Label label, storage::Property property,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
std::optional<ScanAllByLabelPropertyRange::Bound> lower_bound,
|
||||
std::optional<ScanAllByLabelPropertyRange::Bound> upper_bound)
|
||||
: label_(label),
|
||||
@ -303,8 +303,8 @@ class ExpectScanAllByLabelPropertyRange
|
||||
}
|
||||
|
||||
private:
|
||||
storage::Label label_;
|
||||
storage::Property property_;
|
||||
storage::LabelId label_;
|
||||
storage::PropertyId property_;
|
||||
std::optional<ScanAllByLabelPropertyRange::Bound> lower_bound_;
|
||||
std::optional<ScanAllByLabelPropertyRange::Bound> upper_bound_;
|
||||
};
|
||||
@ -383,14 +383,14 @@ TPlanner MakePlanner(TDbAccessor *dba, AstStorage &storage,
|
||||
|
||||
class FakeDbAccessor {
|
||||
public:
|
||||
int64_t VerticesCount(storage::Label label) const {
|
||||
int64_t VerticesCount(storage::LabelId label) const {
|
||||
auto found = label_index_.find(label);
|
||||
if (found != label_index_.end()) return found->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t VerticesCount(storage::Label label,
|
||||
storage::Property property) const {
|
||||
int64_t VerticesCount(storage::LabelId label,
|
||||
storage::PropertyId property) const {
|
||||
for (auto &index : label_property_index_) {
|
||||
if (std::get<0>(index) == label && std::get<1>(index) == property) {
|
||||
return std::get<2>(index);
|
||||
@ -399,12 +399,12 @@ class FakeDbAccessor {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool LabelIndexExists(storage::Label label) const {
|
||||
bool LabelIndexExists(storage::LabelId label) const {
|
||||
return label_index_.find(label) != label_index_.end();
|
||||
}
|
||||
|
||||
bool LabelPropertyIndexExists(storage::Label label,
|
||||
storage::Property property) const {
|
||||
bool LabelPropertyIndexExists(storage::LabelId label,
|
||||
storage::PropertyId property) const {
|
||||
for (auto &index : label_property_index_) {
|
||||
if (std::get<0>(index) == label && std::get<1>(index) == property) {
|
||||
return true;
|
||||
@ -413,11 +413,11 @@ class FakeDbAccessor {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetIndexCount(storage::Label label, int64_t count) {
|
||||
void SetIndexCount(storage::LabelId label, int64_t count) {
|
||||
label_index_[label] = count;
|
||||
}
|
||||
|
||||
void SetIndexCount(storage::Label label, storage::Property property,
|
||||
void SetIndexCount(storage::LabelId label, storage::PropertyId property,
|
||||
int64_t count) {
|
||||
for (auto &index : label_property_index_) {
|
||||
if (std::get<0>(index) == label && std::get<1>(index) == property) {
|
||||
@ -428,53 +428,53 @@ class FakeDbAccessor {
|
||||
label_property_index_.emplace_back(label, property, count);
|
||||
}
|
||||
|
||||
storage::Label NameToLabel(const std::string &name) {
|
||||
storage::LabelId NameToLabel(const std::string &name) {
|
||||
auto found = labels_.find(name);
|
||||
if (found != labels_.end()) return found->second;
|
||||
return labels_.emplace(name, storage::Label::FromUint(labels_.size()))
|
||||
return labels_.emplace(name, storage::LabelId::FromUint(labels_.size()))
|
||||
.first->second;
|
||||
}
|
||||
|
||||
storage::Label Label(const std::string &name) { return NameToLabel(name); }
|
||||
storage::LabelId Label(const std::string &name) { return NameToLabel(name); }
|
||||
|
||||
storage::EdgeType NameToEdgeType(const std::string &name) {
|
||||
storage::EdgeTypeId NameToEdgeType(const std::string &name) {
|
||||
auto found = edge_types_.find(name);
|
||||
if (found != edge_types_.end()) return found->second;
|
||||
return edge_types_
|
||||
.emplace(name, storage::EdgeType::FromUint(edge_types_.size()))
|
||||
.emplace(name, storage::EdgeTypeId::FromUint(edge_types_.size()))
|
||||
.first->second;
|
||||
}
|
||||
|
||||
storage::Property NameToProperty(const std::string &name) {
|
||||
storage::PropertyId NameToProperty(const std::string &name) {
|
||||
auto found = properties_.find(name);
|
||||
if (found != properties_.end()) return found->second;
|
||||
return properties_
|
||||
.emplace(name, storage::Property::FromUint(properties_.size()))
|
||||
.emplace(name, storage::PropertyId::FromUint(properties_.size()))
|
||||
.first->second;
|
||||
}
|
||||
|
||||
storage::Property Property(const std::string &name) {
|
||||
storage::PropertyId Property(const std::string &name) {
|
||||
return NameToProperty(name);
|
||||
}
|
||||
|
||||
std::string PropertyToName(storage::Property property) const {
|
||||
std::string PropertyToName(storage::PropertyId property) const {
|
||||
for (const auto &kv : properties_) {
|
||||
if (kv.second == property) return kv.first;
|
||||
}
|
||||
LOG(FATAL) << "Unable to find property name";
|
||||
}
|
||||
|
||||
std::string PropertyName(storage::Property property) const {
|
||||
std::string PropertyName(storage::PropertyId property) const {
|
||||
return PropertyToName(property);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, storage::Label> labels_;
|
||||
std::unordered_map<std::string, storage::EdgeType> edge_types_;
|
||||
std::unordered_map<std::string, storage::Property> properties_;
|
||||
std::unordered_map<std::string, storage::LabelId> labels_;
|
||||
std::unordered_map<std::string, storage::EdgeTypeId> edge_types_;
|
||||
std::unordered_map<std::string, storage::PropertyId> properties_;
|
||||
|
||||
std::unordered_map<storage::Label, int64_t> label_index_;
|
||||
std::vector<std::tuple<storage::Label, storage::Property, int64_t>>
|
||||
std::unordered_map<storage::LabelId, int64_t> label_index_;
|
||||
std::vector<std::tuple<storage::LabelId, storage::PropertyId, int64_t>>
|
||||
label_property_index_;
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ ScanAllTuple MakeScanAll(AstStorage &storage, SymbolTable &symbol_table,
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabel(
|
||||
AstStorage &storage, SymbolTable &symbol_table,
|
||||
const std::string &identifier, storage::Label label,
|
||||
const std::string &identifier, storage::LabelId label,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
storage::View view = storage::View::OLD) {
|
||||
auto node = NODE(identifier);
|
||||
@ -120,7 +120,7 @@ ScanAllTuple MakeScanAllByLabel(
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabelPropertyRange(
|
||||
AstStorage &storage, SymbolTable &symbol_table, std::string identifier,
|
||||
storage::Label label, storage::Property property,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::string &property_name, std::optional<Bound> lower_bound,
|
||||
std::optional<Bound> upper_bound,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
@ -142,7 +142,7 @@ ScanAllTuple MakeScanAllByLabelPropertyRange(
|
||||
*/
|
||||
ScanAllTuple MakeScanAllByLabelPropertyValue(
|
||||
AstStorage &storage, SymbolTable &symbol_table, std::string identifier,
|
||||
storage::Label label, storage::Property property,
|
||||
storage::LabelId label, storage::PropertyId property,
|
||||
const std::string &property_name, Expression *value,
|
||||
std::shared_ptr<LogicalOperator> input = {nullptr},
|
||||
storage::View view = storage::View::OLD) {
|
||||
@ -166,7 +166,7 @@ ExpandTuple MakeExpand(AstStorage &storage, SymbolTable &symbol_table,
|
||||
std::shared_ptr<LogicalOperator> input,
|
||||
Symbol input_symbol, const std::string &edge_identifier,
|
||||
EdgeAtom::Direction direction,
|
||||
const std::vector<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
const std::string &node_identifier, bool existing_node,
|
||||
storage::View view) {
|
||||
auto edge = EDGE(edge_identifier, direction);
|
||||
|
@ -20,7 +20,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) {
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
storage::Label label = dba.NameToLabel("Person");
|
||||
storage::LabelId label = dba.NameToLabel("Person");
|
||||
auto property = PROPERTY_PAIR("prop");
|
||||
|
||||
AstStorage storage;
|
||||
@ -64,7 +64,7 @@ TEST(QueryPlan, CreateReturn) {
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
storage::Label label = dba.NameToLabel("Person");
|
||||
storage::LabelId label = dba.NameToLabel("Person");
|
||||
auto property = PROPERTY_PAIR("property");
|
||||
|
||||
AstStorage storage;
|
||||
@ -105,10 +105,10 @@ TEST(QueryPlan, CreateExpand) {
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
storage::Label label_node_1 = dba.NameToLabel("Node1");
|
||||
storage::Label label_node_2 = dba.NameToLabel("Node2");
|
||||
storage::LabelId label_node_1 = dba.NameToLabel("Node1");
|
||||
storage::LabelId label_node_2 = dba.NameToLabel("Node2");
|
||||
auto property = PROPERTY_PAIR("property");
|
||||
storage::EdgeType edge_type = dba.NameToEdgeType("edge_type");
|
||||
storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type");
|
||||
|
||||
SymbolTable symbol_table;
|
||||
AstStorage storage;
|
||||
@ -156,7 +156,7 @@ TEST(QueryPlan, CreateExpand) {
|
||||
CHECK(maybe_labels.HasValue());
|
||||
const auto &labels = *maybe_labels;
|
||||
EXPECT_EQ(labels.size(), 1);
|
||||
storage::Label label = labels[0];
|
||||
storage::LabelId label = labels[0];
|
||||
if (label == label_node_1) {
|
||||
// node created by first op
|
||||
EXPECT_EQ(
|
||||
@ -225,10 +225,10 @@ TEST(QueryPlan, MatchCreateExpand) {
|
||||
dba.InsertVertex();
|
||||
dba.AdvanceCommand();
|
||||
|
||||
// storage::Label label_node_1 = dba.NameToLabel("Node1");
|
||||
// storage::Label label_node_2 = dba.NameToLabel("Node2");
|
||||
// storage::Property property = dba.NameToLabel("prop");
|
||||
storage::EdgeType edge_type = dba.NameToEdgeType("edge_type");
|
||||
// storage::LabelId label_node_1 = dba.NameToLabel("Node1");
|
||||
// storage::LabelId label_node_2 = dba.NameToLabel("Node2");
|
||||
// storage::PropertyId property = dba.NameToLabel("prop");
|
||||
storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type");
|
||||
|
||||
SymbolTable symbol_table;
|
||||
AstStorage storage;
|
||||
@ -402,7 +402,8 @@ TEST(QueryPlan, DeleteReturn) {
|
||||
auto prop = PROPERTY_PAIR("property");
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
auto va = dba.InsertVertex();
|
||||
ASSERT_TRUE(va.SetProperty(prop.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
va.SetProperty(prop.second, storage::PropertyValue(42)).HasValue());
|
||||
}
|
||||
|
||||
dba.AdvanceCommand();
|
||||
@ -529,15 +530,15 @@ TEST(QueryPlan, SetProperty) {
|
||||
ASSERT_TRUE(maybe_edges.HasValue());
|
||||
for (auto edge : *maybe_edges) {
|
||||
ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop1)->ValueInt(), 42);
|
||||
auto from = edge.From();
|
||||
auto to = edge.To();
|
||||
ASSERT_EQ(from.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(from.GetProperty(storage::View::OLD, prop1)->ValueInt(), 42);
|
||||
ASSERT_EQ(to.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Null);
|
||||
storage::PropertyValue::Type::Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,9 +556,9 @@ TEST(QueryPlan, SetProperties) {
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto e = dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("R"));
|
||||
ASSERT_TRUE(v1.SetProperty(prop_a, PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(e->SetProperty(prop_b, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop_c, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop_a, storage::PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(e->SetProperty(prop_b, storage::PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop_c, storage::PropertyValue(2)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
AstStorage storage;
|
||||
@ -592,29 +593,29 @@ TEST(QueryPlan, SetProperties) {
|
||||
EXPECT_EQ(from.Properties(storage::View::OLD)->size(), update ? 2 : 1);
|
||||
if (update) {
|
||||
ASSERT_EQ(from.GetProperty(storage::View::OLD, prop_a)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(from.GetProperty(storage::View::OLD, prop_a)->ValueInt(),
|
||||
0);
|
||||
}
|
||||
ASSERT_EQ(from.GetProperty(storage::View::OLD, prop_b)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(from.GetProperty(storage::View::OLD, prop_b)->ValueInt(), 1);
|
||||
|
||||
EXPECT_EQ(edge.Properties(storage::View::OLD)->size(), update ? 2 : 1);
|
||||
if (update) {
|
||||
ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop_b)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop_b)->ValueInt(),
|
||||
1);
|
||||
}
|
||||
ASSERT_EQ(edge.GetProperty(storage::View::OLD, prop_c)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop_c)->ValueInt(), 2);
|
||||
|
||||
auto to = edge.To();
|
||||
EXPECT_EQ(to.Properties(storage::View::OLD)->size(), 1);
|
||||
ASSERT_EQ(to.GetProperty(storage::View::OLD, prop_c)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(to.GetProperty(storage::View::OLD, prop_c)->ValueInt(), 2);
|
||||
}
|
||||
}
|
||||
@ -641,7 +642,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<storage::Label>{label2, label3});
|
||||
n.op_, n.sym_, std::vector<storage::LabelId>{label2, label3});
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_EQ(2, PullAll(*label_set, &context));
|
||||
|
||||
@ -669,15 +670,15 @@ TEST(QueryPlan, RemoveProperty) {
|
||||
{
|
||||
auto e = dba.InsertEdge(&v1, &v3, edge_type);
|
||||
ASSERT_TRUE(e.HasValue());
|
||||
ASSERT_TRUE(e->SetProperty(prop1, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(e->SetProperty(prop1, storage::PropertyValue(42)).HasValue());
|
||||
}
|
||||
ASSERT_TRUE(dba.InsertEdge(&v2, &v4, edge_type).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop1, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v3.SetProperty(prop1, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v4.SetProperty(prop1, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop1, storage::PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v3.SetProperty(prop1, storage::PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v4.SetProperty(prop1, storage::PropertyValue(42)).HasValue());
|
||||
auto prop2 = dba.NameToProperty("prop2");
|
||||
ASSERT_TRUE(v1.SetProperty(prop2, PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop2, PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop2, storage::PropertyValue(0)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop2, storage::PropertyValue(0)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
AstStorage storage;
|
||||
@ -704,15 +705,15 @@ TEST(QueryPlan, RemoveProperty) {
|
||||
ASSERT_TRUE(maybe_edges.HasValue());
|
||||
for (auto edge : *maybe_edges) {
|
||||
EXPECT_EQ(edge.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Null);
|
||||
storage::PropertyValue::Type::Null);
|
||||
auto from = edge.From();
|
||||
auto to = edge.To();
|
||||
EXPECT_EQ(from.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Null);
|
||||
storage::PropertyValue::Type::Null);
|
||||
EXPECT_EQ(from.GetProperty(storage::View::OLD, prop2)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
EXPECT_EQ(to.GetProperty(storage::View::OLD, prop1)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -739,7 +740,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<storage::Label>{label1, label2});
|
||||
n.op_, n.sym_, std::vector<storage::LabelId>{label1, label2});
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_EQ(2, PullAll(*label_remove, &context));
|
||||
|
||||
@ -757,7 +758,8 @@ TEST(QueryPlan, NodeFilterSet) {
|
||||
// Create a graph such that (v1 {prop: 42}) is connected to v2 and v3.
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto prop = PROPERTY_PAIR("property");
|
||||
ASSERT_TRUE(v1.SetProperty(prop.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(prop.second, storage::PropertyValue(42)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto v3 = dba.InsertVertex();
|
||||
auto edge_type = dba.NameToEdgeType("Edge");
|
||||
@ -801,7 +803,8 @@ TEST(QueryPlan, FilterRemove) {
|
||||
// Create a graph such that (v1 {prop: 42}) is connected to v2 and v3.
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto prop = PROPERTY_PAIR("property");
|
||||
ASSERT_TRUE(v1.SetProperty(prop.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(prop.second, storage::PropertyValue(42)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto v3 = dba.InsertVertex();
|
||||
auto edge_type = dba.NameToEdgeType("Edge");
|
||||
@ -829,7 +832,7 @@ TEST(QueryPlan, FilterRemove) {
|
||||
EXPECT_EQ(2, PullAll(*rem, &context));
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->type(),
|
||||
PropertyValue::Type::Null);
|
||||
storage::PropertyValue::Type::Null);
|
||||
}
|
||||
|
||||
TEST(QueryPlan, SetRemove) {
|
||||
@ -847,9 +850,10 @@ 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<storage::Label>{label1, label2});
|
||||
scan_all.op_, scan_all.sym_,
|
||||
std::vector<storage::LabelId>{label1, label2});
|
||||
auto rem = std::make_shared<plan::RemoveLabels>(
|
||||
set, scan_all.sym_, std::vector<storage::Label>{label1, label2});
|
||||
set, scan_all.sym_, std::vector<storage::LabelId>{label1, label2});
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_EQ(1, PullAll(*rem, &context));
|
||||
dba.AdvanceCommand();
|
||||
@ -898,13 +902,13 @@ TEST(QueryPlan, Merge) {
|
||||
dba.AdvanceCommand();
|
||||
|
||||
ASSERT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(v1.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 1);
|
||||
ASSERT_EQ(v2.GetProperty(storage::View::OLD, prop.second)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(v2.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 1);
|
||||
ASSERT_EQ(v3.GetProperty(storage::View::OLD, prop.second)->type(),
|
||||
PropertyValue::Type::Int);
|
||||
storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(v3.GetProperty(storage::View::OLD, prop.second)->ValueInt(), 2);
|
||||
}
|
||||
|
||||
@ -977,7 +981,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<storage::Label>{label});
|
||||
optional, n.sym_, std::vector<storage::LabelId>{label});
|
||||
EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD)));
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_EQ(1, PullAll(*set_op, &context));
|
||||
@ -1012,7 +1016,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<storage::Label>{label});
|
||||
optional, n.sym_, std::vector<storage::LabelId>{label});
|
||||
EXPECT_EQ(0, CountIterable(dba.Vertices(storage::View::OLD)));
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_EQ(1, PullAll(*remove_op, &context));
|
||||
@ -1076,8 +1080,9 @@ TEST(QueryPlan, DeleteSetPropertiesFrom) {
|
||||
// Add a single vertex.
|
||||
{
|
||||
auto v = dba.InsertVertex();
|
||||
ASSERT_TRUE(v.SetProperty(dba.NameToProperty("property"), PropertyValue(1))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
v.SetProperty(dba.NameToProperty("property"), storage::PropertyValue(1))
|
||||
.HasValue());
|
||||
}
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_EQ(1, CountIterable(dba.Vertices(storage::View::OLD)));
|
||||
@ -1113,7 +1118,7 @@ TEST(QueryPlan, DeleteRemoveLabels) {
|
||||
auto n_get = storage.Create<Identifier>("n")->MapTo(n.sym_);
|
||||
auto delete_op = std::make_shared<plan::Delete>(
|
||||
n.op_, std::vector<Expression *>{n_get}, false);
|
||||
std::vector<storage::Label> labels{dba.NameToLabel("label")};
|
||||
std::vector<storage::LabelId> labels{dba.NameToLabel("label")};
|
||||
auto rem_op = std::make_shared<plan::RemoveLabels>(delete_op, n.sym_, labels);
|
||||
auto context = MakeContext(storage, symbol_table, &dba);
|
||||
EXPECT_THROW(PullAll(*rem_op, &context), QueryRuntimeException);
|
||||
|
@ -148,7 +148,7 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
// add a few nodes to the database
|
||||
storage::Label label = dba.NameToLabel("Label");
|
||||
storage::LabelId label = dba.NameToLabel("Label");
|
||||
auto property = PROPERTY_PAIR("Property");
|
||||
auto v1 = dba.InsertVertex();
|
||||
auto v2 = dba.InsertVertex();
|
||||
@ -163,10 +163,14 @@ TEST(QueryPlan, NodeFilterLabelsAndProperties) {
|
||||
ASSERT_TRUE(v2.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(v3.AddLabel(label).HasValue());
|
||||
// v1 and v4 will have the right properties
|
||||
ASSERT_TRUE(v1.SetProperty(property.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(property.second, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v4.SetProperty(property.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(v5.SetProperty(property.second, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v1.SetProperty(property.second, storage::PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v2.SetProperty(property.second, storage::PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v4.SetProperty(property.second, storage::PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v5.SetProperty(property.second, storage::PropertyValue(1)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
AstStorage storage;
|
||||
@ -205,9 +209,9 @@ TEST(QueryPlan, NodeFilterMultipleLabels) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
|
||||
// add a few nodes to the database
|
||||
storage::Label label1 = dba.NameToLabel("label1");
|
||||
storage::Label label2 = dba.NameToLabel("label2");
|
||||
storage::Label label3 = dba.NameToLabel("label3");
|
||||
storage::LabelId label1 = dba.NameToLabel("label1");
|
||||
storage::LabelId label2 = dba.NameToLabel("label2");
|
||||
storage::LabelId label3 = dba.NameToLabel("label3");
|
||||
// the test will look for nodes that have label1 and label2
|
||||
dba.InsertVertex(); // NOT accepted
|
||||
ASSERT_TRUE(dba.InsertVertex().AddLabel(label1).HasValue()); // NOT accepted
|
||||
@ -481,9 +485,9 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
storage::Storage::Accessor storage_dba{db.Access()};
|
||||
query::DbAccessor dba{&storage_dba};
|
||||
// labels for layers in the double chain
|
||||
std::vector<storage::Label> labels;
|
||||
std::vector<storage::LabelId> labels;
|
||||
// for all the edges
|
||||
storage::EdgeType edge_type = dba.NameToEdgeType("edge_type");
|
||||
storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type");
|
||||
|
||||
AstStorage storage;
|
||||
SymbolTable symbol_table;
|
||||
@ -509,7 +513,7 @@ class QueryPlanExpandVariable : public testing::Test {
|
||||
auto edge = dba.InsertEdge(&v_from, &v_to, edge_type);
|
||||
ASSERT_TRUE(
|
||||
edge->SetProperty(dba.NameToProperty("p"),
|
||||
PropertyValue(fmt::format(
|
||||
storage::PropertyValue(fmt::format(
|
||||
"V{}{}->V{}{}", from_layer_ind, v_from_ind,
|
||||
from_layer_ind + 1, v_to_ind)))
|
||||
.HasValue());
|
||||
@ -538,7 +542,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<storage::EdgeType> &edge_types,
|
||||
const std::vector<storage::EdgeTypeId> &edge_types,
|
||||
std::optional<size_t> lower, std::optional<size_t> upper, Symbol edge_sym,
|
||||
const std::string &node_to, storage::View view, bool is_reverse = false) {
|
||||
auto n_from = MakeScanAll(storage, symbol_table, node_from, input_op);
|
||||
@ -821,8 +825,8 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test {
|
||||
storage::Storage db;
|
||||
storage::Storage::Accessor storage_dba{db.Access()};
|
||||
query::DbAccessor dba{&storage_dba};
|
||||
std::pair<std::string, storage::Property> prop = PROPERTY_PAIR("property");
|
||||
storage::EdgeType edge_type = dba.NameToEdgeType("edge_type");
|
||||
std::pair<std::string, storage::PropertyId> prop = PROPERTY_PAIR("property");
|
||||
storage::EdgeTypeId edge_type = dba.NameToEdgeType("edge_type");
|
||||
|
||||
// make 5 vertices because we'll need to compare against them exactly
|
||||
// v[0] has `prop` with the value 0
|
||||
@ -846,14 +850,15 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test {
|
||||
void SetUp() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
v.push_back(dba.InsertVertex());
|
||||
ASSERT_TRUE(
|
||||
v.back().SetProperty(prop.second, PropertyValue(i)).HasValue());
|
||||
ASSERT_TRUE(v.back()
|
||||
.SetProperty(prop.second, storage::PropertyValue(i))
|
||||
.HasValue());
|
||||
}
|
||||
|
||||
auto add_edge = [&](int from, int to, double weight) {
|
||||
auto edge = dba.InsertEdge(&v[from], &v[to], edge_type);
|
||||
ASSERT_TRUE(
|
||||
edge->SetProperty(prop.second, PropertyValue(weight)).HasValue());
|
||||
ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue(weight))
|
||||
.HasValue());
|
||||
e.emplace(std::make_pair(from, to), *edge);
|
||||
};
|
||||
|
||||
@ -896,7 +901,7 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test {
|
||||
auto filter_lambda = last_op = std::make_shared<ExpandVariable>(
|
||||
last_op, n.sym_, node_sym, edge_list_sym,
|
||||
EdgeAtom::Type::WEIGHTED_SHORTEST_PATH, direction,
|
||||
std::vector<storage::EdgeType>{}, false, nullptr,
|
||||
std::vector<storage::EdgeTypeId>{}, false, nullptr,
|
||||
max_depth ? LITERAL(max_depth.value()) : nullptr,
|
||||
existing_node_input != nullptr,
|
||||
ExpansionLambda{filter_edge, filter_node, where},
|
||||
@ -1099,11 +1104,12 @@ TEST_F(QueryPlanExpandWeightedShortestPath, UpperBound) {
|
||||
}
|
||||
{
|
||||
auto new_vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(
|
||||
new_vertex.SetProperty(prop.second, PropertyValue(5)).HasValue());
|
||||
ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type);
|
||||
ASSERT_TRUE(edge.HasValue());
|
||||
ASSERT_TRUE(edge->SetProperty(prop.second, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
edge->SetProperty(prop.second, storage::PropertyValue(2)).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
auto results = ExpandWShortest(EdgeAtom::Direction::BOTH, 3, LITERAL(true));
|
||||
@ -1124,11 +1130,13 @@ TEST_F(QueryPlanExpandWeightedShortestPath, UpperBound) {
|
||||
|
||||
TEST_F(QueryPlanExpandWeightedShortestPath, NonNumericWeight) {
|
||||
auto new_vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(new_vertex.SetProperty(prop.second, PropertyValue(5)).HasValue());
|
||||
ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type);
|
||||
ASSERT_TRUE(edge.HasValue());
|
||||
ASSERT_TRUE(
|
||||
edge->SetProperty(prop.second, PropertyValue("not a number")).HasValue());
|
||||
edge->SetProperty(prop.second, storage::PropertyValue("not a number"))
|
||||
.HasValue());
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_THROW(ExpandWShortest(EdgeAtom::Direction::BOTH, 1000, LITERAL(true)),
|
||||
QueryRuntimeException);
|
||||
@ -1136,10 +1144,11 @@ TEST_F(QueryPlanExpandWeightedShortestPath, NonNumericWeight) {
|
||||
|
||||
TEST_F(QueryPlanExpandWeightedShortestPath, NegativeWeight) {
|
||||
auto new_vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(new_vertex.SetProperty(prop.second, PropertyValue(5)).HasValue());
|
||||
ASSERT_TRUE(new_vertex.SetProperty(prop.second, storage::PropertyValue(5))
|
||||
.HasValue());
|
||||
auto edge = dba.InsertEdge(&v[4], &new_vertex, edge_type);
|
||||
ASSERT_TRUE(edge.HasValue());
|
||||
ASSERT_TRUE(edge->SetProperty(prop.second, PropertyValue(-10))
|
||||
ASSERT_TRUE(edge->SetProperty(prop.second, storage::PropertyValue(-10))
|
||||
.HasValue()); // negative weight
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_THROW(ExpandWShortest(EdgeAtom::Direction::BOTH, 1000, LITERAL(true)),
|
||||
@ -1163,12 +1172,12 @@ TEST(QueryPlan, ExpandOptional) {
|
||||
auto prop = dba.NameToProperty("p");
|
||||
auto edge_type = dba.NameToEdgeType("T");
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(prop, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(prop, storage::PropertyValue(1)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v2.SetProperty(prop, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(prop, storage::PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(dba.InsertEdge(&v1, &v2, edge_type).HasValue());
|
||||
auto v3 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v3.SetProperty(prop, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v3.SetProperty(prop, storage::PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(dba.InsertEdge(&v1, &v3, edge_type).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -1196,7 +1205,7 @@ TEST(QueryPlan, ExpandOptional) {
|
||||
ASSERT_EQ(row[0].type(), TypedValue::Type::Vertex);
|
||||
auto &va = row[0].ValueVertex();
|
||||
auto va_p = *va.GetProperty(storage::View::OLD, prop);
|
||||
ASSERT_EQ(va_p.type(), PropertyValue::Type::Int);
|
||||
ASSERT_EQ(va_p.type(), storage::PropertyValue::Type::Int);
|
||||
if (va_p.ValueInt() == 1) {
|
||||
v1_is_n_count++;
|
||||
EXPECT_EQ(row[1].type(), TypedValue::Type::Edge);
|
||||
@ -1298,7 +1307,7 @@ TEST(QueryPlan, OptionalMatchThenExpandToMissingNode) {
|
||||
node->identifier_->MapTo(with_n_sym);
|
||||
auto expand = std::make_shared<plan::Expand>(
|
||||
m.op_, m.sym_, with_n_sym, edge_sym, edge_direction,
|
||||
std::vector<storage::EdgeType>{}, true, storage::View::OLD);
|
||||
std::vector<storage::EdgeTypeId>{}, true, storage::View::OLD);
|
||||
// RETURN m
|
||||
auto m_ne = NEXPR("m", IDENT("m")->MapTo(m.sym_))
|
||||
->MapTo(symbol_table.CreateSymbol("m", true));
|
||||
@ -1331,9 +1340,10 @@ TEST(QueryPlan, ExpandExistingNode) {
|
||||
EdgeAtom::Direction::OUT, {}, "n", with_existing,
|
||||
storage::View::OLD);
|
||||
if (with_existing)
|
||||
r_n.op_ = std::make_shared<Expand>(
|
||||
n.op_, n.sym_, n.sym_, r_n.edge_sym_, r_n.edge_->direction_,
|
||||
std::vector<storage::EdgeType>{}, with_existing, storage::View::OLD);
|
||||
r_n.op_ = std::make_shared<Expand>(n.op_, n.sym_, n.sym_, r_n.edge_sym_,
|
||||
r_n.edge_->direction_,
|
||||
std::vector<storage::EdgeTypeId>{},
|
||||
with_existing, storage::View::OLD);
|
||||
|
||||
// make a named expression and a produce
|
||||
auto output =
|
||||
@ -1380,7 +1390,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<storage::EdgeType> edge_types;
|
||||
std::vector<storage::EdgeTypeId> edge_types;
|
||||
for (int j = 0; j < 2; ++j)
|
||||
edge_types.push_back(dba.NameToEdgeType("et" + std::to_string(j)));
|
||||
std::vector<query::VertexAccessor> vertices;
|
||||
@ -1393,12 +1403,12 @@ TEST(QueryPlan, EdgeFilter) {
|
||||
switch (i % 3) {
|
||||
case 0:
|
||||
ASSERT_TRUE(edges.back()
|
||||
.SetProperty(prop.second, PropertyValue(42))
|
||||
.SetProperty(prop.second, storage::PropertyValue(42))
|
||||
.HasValue());
|
||||
break;
|
||||
case 1:
|
||||
ASSERT_TRUE(edges.back()
|
||||
.SetProperty(prop.second, PropertyValue(100))
|
||||
.SetProperty(prop.second, storage::PropertyValue(100))
|
||||
.HasValue());
|
||||
break;
|
||||
default:
|
||||
@ -1438,7 +1448,8 @@ TEST(QueryPlan, EdgeFilter) {
|
||||
EXPECT_EQ(1, test_filter());
|
||||
// test that edge filtering always filters on old state
|
||||
for (auto &edge : edges)
|
||||
ASSERT_TRUE(edge.SetProperty(prop.second, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
edge.SetProperty(prop.second, storage::PropertyValue(42)).HasValue());
|
||||
EXPECT_EQ(1, test_filter());
|
||||
dba.AdvanceCommand();
|
||||
EXPECT_EQ(3, test_filter());
|
||||
@ -1486,9 +1497,10 @@ TEST(QueryPlan, Filter) {
|
||||
// add a 6 nodes with property 'prop', 2 have true as value
|
||||
auto property = PROPERTY_PAIR("property");
|
||||
for (int i = 0; i < 6; ++i)
|
||||
ASSERT_TRUE(dba.InsertVertex()
|
||||
.SetProperty(property.second, PropertyValue(i % 3 == 0))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(
|
||||
dba.InsertVertex()
|
||||
.SetProperty(property.second, storage::PropertyValue(i % 3 == 0))
|
||||
.HasValue());
|
||||
dba.InsertVertex(); // prop not set, gives NULL
|
||||
dba.AdvanceCommand();
|
||||
|
||||
@ -1633,21 +1645,24 @@ TEST(QueryPlan, ScanAllByLabelProperty) {
|
||||
auto label = db.NameToLabel("label");
|
||||
auto prop = db.NameToProperty("prop");
|
||||
// vertex property values that will be stored into the DB
|
||||
std::vector<PropertyValue> values{
|
||||
PropertyValue(true),
|
||||
PropertyValue(false),
|
||||
PropertyValue("a"),
|
||||
PropertyValue("b"),
|
||||
PropertyValue("c"),
|
||||
PropertyValue(0),
|
||||
PropertyValue(1),
|
||||
PropertyValue(2),
|
||||
PropertyValue(0.5),
|
||||
PropertyValue(1.5),
|
||||
PropertyValue(2.5),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(0)}),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(1)}),
|
||||
PropertyValue(std::vector<PropertyValue>{PropertyValue(2)})};
|
||||
std::vector<storage::PropertyValue> values{
|
||||
storage::PropertyValue(true),
|
||||
storage::PropertyValue(false),
|
||||
storage::PropertyValue("a"),
|
||||
storage::PropertyValue("b"),
|
||||
storage::PropertyValue("c"),
|
||||
storage::PropertyValue(0),
|
||||
storage::PropertyValue(1),
|
||||
storage::PropertyValue(2),
|
||||
storage::PropertyValue(0.5),
|
||||
storage::PropertyValue(1.5),
|
||||
storage::PropertyValue(2.5),
|
||||
storage::PropertyValue(
|
||||
std::vector<storage::PropertyValue>{storage::PropertyValue(0)}),
|
||||
storage::PropertyValue(
|
||||
std::vector<storage::PropertyValue>{storage::PropertyValue(1)}),
|
||||
storage::PropertyValue(
|
||||
std::vector<storage::PropertyValue>{storage::PropertyValue(2)})};
|
||||
{
|
||||
auto storage_dba = db.Access();
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
@ -1701,23 +1716,25 @@ TEST(QueryPlan, ScanAllByLabelProperty) {
|
||||
check(TypedValue(1.5), Bound::Type::EXCLUSIVE, TypedValue(2.5),
|
||||
Bound::Type::INCLUSIVE, {TypedValue(2), TypedValue(2.5)});
|
||||
|
||||
auto are_comparable = [](PropertyValue::Type a, PropertyValue::Type b) {
|
||||
auto is_numeric = [](const PropertyValue::Type t) {
|
||||
return t == PropertyValue::Type::Int || t == PropertyValue::Type::Double;
|
||||
auto are_comparable = [](storage::PropertyValue::Type a,
|
||||
storage::PropertyValue::Type b) {
|
||||
auto is_numeric = [](const storage::PropertyValue::Type t) {
|
||||
return t == storage::PropertyValue::Type::Int ||
|
||||
t == storage::PropertyValue::Type::Double;
|
||||
};
|
||||
|
||||
return a == b || (is_numeric(a) && is_numeric(b));
|
||||
};
|
||||
|
||||
auto is_orderable = [](const PropertyValue &t) {
|
||||
auto is_orderable = [](const storage::PropertyValue &t) {
|
||||
return t.IsNull() || t.IsInt() || t.IsDouble() || t.IsString();
|
||||
};
|
||||
|
||||
// when a range contains different types, nothing should get returned
|
||||
for (const auto &value_a : values) {
|
||||
for (const auto &value_b : values) {
|
||||
if (are_comparable(static_cast<PropertyValue>(value_a).type(),
|
||||
static_cast<PropertyValue>(value_b).type()))
|
||||
if (are_comparable(static_cast<storage::PropertyValue>(value_a).type(),
|
||||
static_cast<storage::PropertyValue>(value_b).type()))
|
||||
continue;
|
||||
if (is_orderable(value_a) && is_orderable(value_b)) {
|
||||
check(TypedValue(value_a), Bound::Type::INCLUSIVE, TypedValue(value_b),
|
||||
@ -1756,11 +1773,13 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
auto number_vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(number_vertex.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(number_vertex.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
number_vertex.SetProperty(prop, storage::PropertyValue(42)).HasValue());
|
||||
auto string_vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(string_vertex.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(
|
||||
string_vertex.SetProperty(prop, PropertyValue("string")).HasValue());
|
||||
string_vertex.SetProperty(prop, storage::PropertyValue("string"))
|
||||
.HasValue());
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
db.CreateIndex(label, prop);
|
||||
@ -1798,7 +1817,8 @@ TEST(QueryPlan, ScanAllByLabelPropertyValueError) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
auto vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(vertex.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(vertex.SetProperty(prop, PropertyValue(i)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
vertex.SetProperty(prop, storage::PropertyValue(i)).HasValue());
|
||||
}
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
@ -1829,7 +1849,8 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeError) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
auto vertex = dba.InsertVertex();
|
||||
ASSERT_TRUE(vertex.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(vertex.SetProperty(prop, PropertyValue(i)).HasValue());
|
||||
ASSERT_TRUE(
|
||||
vertex.SetProperty(prop, storage::PropertyValue(i)).HasValue());
|
||||
}
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
@ -1885,8 +1906,8 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualNull) {
|
||||
ASSERT_TRUE(vertex.AddLabel(label).HasValue());
|
||||
auto vertex_with_prop = dba.InsertVertex();
|
||||
ASSERT_TRUE(vertex_with_prop.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(
|
||||
vertex_with_prop.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(vertex_with_prop.SetProperty(prop, storage::PropertyValue(42))
|
||||
.HasValue());
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
db.CreateIndex(label, prop);
|
||||
@ -1922,8 +1943,8 @@ TEST(QueryPlan, ScanAllByLabelPropertyRangeNull) {
|
||||
ASSERT_TRUE(vertex.AddLabel(label).HasValue());
|
||||
auto vertex_with_prop = dba.InsertVertex();
|
||||
ASSERT_TRUE(vertex_with_prop.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(
|
||||
vertex_with_prop.SetProperty(prop, PropertyValue(42)).HasValue());
|
||||
ASSERT_TRUE(vertex_with_prop.SetProperty(prop, storage::PropertyValue(42))
|
||||
.HasValue());
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
db.CreateIndex(label, prop);
|
||||
@ -1956,7 +1977,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyNoValueInIndexContinuation) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
auto v = dba.InsertVertex();
|
||||
ASSERT_TRUE(v.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop, storage::PropertyValue(2)).HasValue());
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
db.CreateIndex(label, prop);
|
||||
@ -1997,10 +2018,10 @@ TEST(QueryPlan, ScanAllEqualsScanAllByLabelProperty) {
|
||||
query::DbAccessor dba(&storage_dba);
|
||||
auto v = dba.InsertVertex();
|
||||
ASSERT_TRUE(v.AddLabel(label).HasValue());
|
||||
ASSERT_TRUE(
|
||||
v.SetProperty(prop, PropertyValue(i < vertex_prop_count ? prop_value1
|
||||
: prop_value2))
|
||||
.HasValue());
|
||||
ASSERT_TRUE(v.SetProperty(prop, storage::PropertyValue(i < vertex_prop_count
|
||||
? prop_value1
|
||||
: prop_value2))
|
||||
.HasValue());
|
||||
ASSERT_FALSE(dba.Commit().HasError());
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ TEST(QueryPlan, CreateNodeWithAttributes) {
|
||||
storage::Storage db;
|
||||
auto dba = db.Access();
|
||||
|
||||
auto label = storage::Label::FromInt(42);
|
||||
auto property = storage::Property::FromInt(1);
|
||||
auto label = storage::LabelId::FromInt(42);
|
||||
auto property = storage::PropertyId::FromInt(1);
|
||||
|
||||
query::AstStorage ast;
|
||||
query::SymbolTable symbol_table;
|
||||
|
@ -39,14 +39,17 @@ TEST_F(ExpressionPrettyPrinterTest, Literals) {
|
||||
EXPECT_EQ(ToString(LITERAL(false)), "false");
|
||||
|
||||
// [1 null "hello"]
|
||||
std::vector<PropertyValue> values{PropertyValue(1), PropertyValue(),
|
||||
PropertyValue("hello")};
|
||||
EXPECT_EQ(ToString(LITERAL(PropertyValue(values))), "[1, null, \"hello\"]");
|
||||
std::vector<storage::PropertyValue> values{storage::PropertyValue(1),
|
||||
storage::PropertyValue(),
|
||||
storage::PropertyValue("hello")};
|
||||
EXPECT_EQ(ToString(LITERAL(storage::PropertyValue(values))),
|
||||
"[1, null, \"hello\"]");
|
||||
|
||||
// {hello: 1, there: 2}
|
||||
std::map<std::string, PropertyValue> map{{"hello", PropertyValue(1)},
|
||||
{"there", PropertyValue(2)}};
|
||||
EXPECT_EQ(ToString(LITERAL(PropertyValue(map))),
|
||||
std::map<std::string, storage::PropertyValue> map{
|
||||
{"hello", storage::PropertyValue(1)},
|
||||
{"there", storage::PropertyValue(2)}};
|
||||
EXPECT_EQ(ToString(LITERAL(storage::PropertyValue(map))),
|
||||
"{\"hello\": 1, \"there\": 2}");
|
||||
}
|
||||
|
||||
@ -61,7 +64,7 @@ TEST_F(ExpressionPrettyPrinterTest, Identifiers) {
|
||||
TEST_F(ExpressionPrettyPrinterTest, Reducing) {
|
||||
// all(x in list where x.prop = 42)
|
||||
auto prop = dba.NameToProperty("prop");
|
||||
EXPECT_EQ(ToString(ALL("x", LITERAL(std::vector<PropertyValue>{}),
|
||||
EXPECT_EQ(ToString(ALL("x", LITERAL(std::vector<storage::PropertyValue>{}),
|
||||
WHERE(EQ(PROPERTY_LOOKUP("x", prop), LITERAL(42))))),
|
||||
"(All (Identifier \"x\") [] (== (PropertyLookup "
|
||||
"(Identifier \"x\") \"prop\") 42))");
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "query/frontend/semantic/required_privileges.hpp"
|
||||
#include "storage/common/types/types.hpp"
|
||||
#include "storage/v2/id_types.hpp"
|
||||
|
||||
#include "query_common.hpp"
|
||||
|
||||
|
@ -264,11 +264,11 @@ TEST(TestVariableStartPlanner, MatchVariableExpandReferenceNode) {
|
||||
auto id = dba.NameToProperty("id");
|
||||
// Graph (v1 {id:1}) -[:r1]-> (v2 {id: 2}) -[:r2]-> (v3 {id: 3})
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(id, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v2.SetProperty(id, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(id, storage::PropertyValue(2)).HasValue());
|
||||
auto v3 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v3.SetProperty(id, PropertyValue(3)).HasValue());
|
||||
ASSERT_TRUE(v3.SetProperty(id, storage::PropertyValue(3)).HasValue());
|
||||
auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1"));
|
||||
auto r2 = *dba.InsertEdge(&v2, &v3, dba.NameToEdgeType("r2"));
|
||||
dba.AdvanceCommand();
|
||||
@ -295,7 +295,7 @@ TEST(TestVariableStartPlanner, MatchVariableExpandBoth) {
|
||||
auto id = dba.NameToProperty("id");
|
||||
// Graph (v1 {id:1}) -[:r1]-> (v2) -[:r2]-> (v3)
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(id, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
auto v3 = dba.InsertVertex();
|
||||
auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1"));
|
||||
@ -325,11 +325,11 @@ TEST(TestVariableStartPlanner, MatchBfs) {
|
||||
auto id = dba.NameToProperty("id");
|
||||
// Graph (v1 {id:1}) -[:r1]-> (v2 {id: 2}) -[:r2]-> (v3 {id: 3})
|
||||
auto v1 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v1.SetProperty(id, PropertyValue(1)).HasValue());
|
||||
ASSERT_TRUE(v1.SetProperty(id, storage::PropertyValue(1)).HasValue());
|
||||
auto v2 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v2.SetProperty(id, PropertyValue(2)).HasValue());
|
||||
ASSERT_TRUE(v2.SetProperty(id, storage::PropertyValue(2)).HasValue());
|
||||
auto v3 = dba.InsertVertex();
|
||||
ASSERT_TRUE(v3.SetProperty(id, PropertyValue(3)).HasValue());
|
||||
ASSERT_TRUE(v3.SetProperty(id, storage::PropertyValue(3)).HasValue());
|
||||
auto r1 = *dba.InsertEdge(&v1, &v2, dba.NameToEdgeType("r1"));
|
||||
ASSERT_TRUE(dba.InsertEdge(&v2, &v3, dba.NameToEdgeType("r2")).HasValue());
|
||||
dba.AdvanceCommand();
|
||||
|
@ -5,20 +5,21 @@
|
||||
#include "slk_common.hpp"
|
||||
|
||||
TEST(SlkAdvanced, PropertyValueList) {
|
||||
std::vector<PropertyValue> original{PropertyValue("hello world!"),
|
||||
PropertyValue(5), PropertyValue(1.123423),
|
||||
PropertyValue(true), PropertyValue()};
|
||||
ASSERT_EQ(original[0].type(), PropertyValue::Type::String);
|
||||
ASSERT_EQ(original[1].type(), PropertyValue::Type::Int);
|
||||
ASSERT_EQ(original[2].type(), PropertyValue::Type::Double);
|
||||
ASSERT_EQ(original[3].type(), PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(original[4].type(), PropertyValue::Type::Null);
|
||||
std::vector<storage::PropertyValue> original{
|
||||
storage::PropertyValue("hello world!"), storage::PropertyValue(5),
|
||||
storage::PropertyValue(1.123423), storage::PropertyValue(true),
|
||||
storage::PropertyValue()};
|
||||
ASSERT_EQ(original[0].type(), storage::PropertyValue::Type::String);
|
||||
ASSERT_EQ(original[1].type(), storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(original[2].type(), storage::PropertyValue::Type::Double);
|
||||
ASSERT_EQ(original[3].type(), storage::PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(original[4].type(), storage::PropertyValue::Type::Null);
|
||||
|
||||
slk::Loopback loopback;
|
||||
auto builder = loopback.GetBuilder();
|
||||
slk::Save(original, builder);
|
||||
|
||||
std::vector<PropertyValue> decoded;
|
||||
std::vector<storage::PropertyValue> decoded;
|
||||
auto reader = loopback.GetReader();
|
||||
slk::Load(&decoded, reader);
|
||||
|
||||
@ -26,23 +27,23 @@ TEST(SlkAdvanced, PropertyValueList) {
|
||||
}
|
||||
|
||||
TEST(SlkAdvanced, PropertyValueMap) {
|
||||
std::map<std::string, PropertyValue> original{
|
||||
{"hello", PropertyValue("world")},
|
||||
{"number", PropertyValue(5)},
|
||||
{"real", PropertyValue(1.123423)},
|
||||
{"truth", PropertyValue(true)},
|
||||
{"nothing", PropertyValue()}};
|
||||
ASSERT_EQ(original["hello"].type(), PropertyValue::Type::String);
|
||||
ASSERT_EQ(original["number"].type(), PropertyValue::Type::Int);
|
||||
ASSERT_EQ(original["real"].type(), PropertyValue::Type::Double);
|
||||
ASSERT_EQ(original["truth"].type(), PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(original["nothing"].type(), PropertyValue::Type::Null);
|
||||
std::map<std::string, storage::PropertyValue> original{
|
||||
{"hello", storage::PropertyValue("world")},
|
||||
{"number", storage::PropertyValue(5)},
|
||||
{"real", storage::PropertyValue(1.123423)},
|
||||
{"truth", storage::PropertyValue(true)},
|
||||
{"nothing", storage::PropertyValue()}};
|
||||
ASSERT_EQ(original["hello"].type(), storage::PropertyValue::Type::String);
|
||||
ASSERT_EQ(original["number"].type(), storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(original["real"].type(), storage::PropertyValue::Type::Double);
|
||||
ASSERT_EQ(original["truth"].type(), storage::PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(original["nothing"].type(), storage::PropertyValue::Type::Null);
|
||||
|
||||
slk::Loopback loopback;
|
||||
auto builder = loopback.GetBuilder();
|
||||
slk::Save(original, builder);
|
||||
|
||||
std::map<std::string, PropertyValue> decoded;
|
||||
std::map<std::string, storage::PropertyValue> decoded;
|
||||
auto reader = loopback.GetReader();
|
||||
slk::Load(&decoded, reader);
|
||||
|
||||
@ -50,35 +51,37 @@ TEST(SlkAdvanced, PropertyValueMap) {
|
||||
}
|
||||
|
||||
TEST(SlkAdvanced, PropertyValueComplex) {
|
||||
std::vector<PropertyValue> vec_v{PropertyValue("hello world!"),
|
||||
PropertyValue(5), PropertyValue(1.123423),
|
||||
PropertyValue(true), PropertyValue()};
|
||||
ASSERT_EQ(vec_v[0].type(), PropertyValue::Type::String);
|
||||
ASSERT_EQ(vec_v[1].type(), PropertyValue::Type::Int);
|
||||
ASSERT_EQ(vec_v[2].type(), PropertyValue::Type::Double);
|
||||
ASSERT_EQ(vec_v[3].type(), PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(vec_v[4].type(), PropertyValue::Type::Null);
|
||||
std::vector<storage::PropertyValue> vec_v{
|
||||
storage::PropertyValue("hello world!"), storage::PropertyValue(5),
|
||||
storage::PropertyValue(1.123423), storage::PropertyValue(true),
|
||||
storage::PropertyValue()};
|
||||
ASSERT_EQ(vec_v[0].type(), storage::PropertyValue::Type::String);
|
||||
ASSERT_EQ(vec_v[1].type(), storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(vec_v[2].type(), storage::PropertyValue::Type::Double);
|
||||
ASSERT_EQ(vec_v[3].type(), storage::PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(vec_v[4].type(), storage::PropertyValue::Type::Null);
|
||||
|
||||
std::map<std::string, PropertyValue> map_v{{"hello", PropertyValue("world")},
|
||||
{"number", PropertyValue(5)},
|
||||
{"real", PropertyValue(1.123423)},
|
||||
{"truth", PropertyValue(true)},
|
||||
{"nothing", PropertyValue()}};
|
||||
ASSERT_EQ(map_v["hello"].type(), PropertyValue::Type::String);
|
||||
ASSERT_EQ(map_v["number"].type(), PropertyValue::Type::Int);
|
||||
ASSERT_EQ(map_v["real"].type(), PropertyValue::Type::Double);
|
||||
ASSERT_EQ(map_v["truth"].type(), PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(map_v["nothing"].type(), PropertyValue::Type::Null);
|
||||
std::map<std::string, storage::PropertyValue> map_v{
|
||||
{"hello", storage::PropertyValue("world")},
|
||||
{"number", storage::PropertyValue(5)},
|
||||
{"real", storage::PropertyValue(1.123423)},
|
||||
{"truth", storage::PropertyValue(true)},
|
||||
{"nothing", storage::PropertyValue()}};
|
||||
ASSERT_EQ(map_v["hello"].type(), storage::PropertyValue::Type::String);
|
||||
ASSERT_EQ(map_v["number"].type(), storage::PropertyValue::Type::Int);
|
||||
ASSERT_EQ(map_v["real"].type(), storage::PropertyValue::Type::Double);
|
||||
ASSERT_EQ(map_v["truth"].type(), storage::PropertyValue::Type::Bool);
|
||||
ASSERT_EQ(map_v["nothing"].type(), storage::PropertyValue::Type::Null);
|
||||
|
||||
PropertyValue original(
|
||||
std::vector<PropertyValue>{PropertyValue(vec_v), PropertyValue(map_v)});
|
||||
ASSERT_EQ(original.type(), PropertyValue::Type::List);
|
||||
storage::PropertyValue original(std::vector<storage::PropertyValue>{
|
||||
storage::PropertyValue(vec_v), storage::PropertyValue(map_v)});
|
||||
ASSERT_EQ(original.type(), storage::PropertyValue::Type::List);
|
||||
|
||||
slk::Loopback loopback;
|
||||
auto builder = loopback.GetBuilder();
|
||||
slk::Save(original, builder);
|
||||
|
||||
PropertyValue decoded;
|
||||
storage::PropertyValue decoded;
|
||||
auto reader = loopback.GetReader();
|
||||
slk::Load(&decoded, reader);
|
||||
|
||||
|
@ -25,7 +25,7 @@ void EXPECT_PROP_EQ(const TypedValue &a, const TypedValue &b) {
|
||||
EXPECT_PROP_TRUE(a == b);
|
||||
}
|
||||
|
||||
void EXPECT_PROP_EQ(const PropertyValue &a, const TypedValue &b) {
|
||||
void EXPECT_PROP_EQ(const storage::PropertyValue &a, const TypedValue &b) {
|
||||
EXPECT_PROP_EQ(TypedValue(a), b);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user