diff --git a/src/audit/log.cpp b/src/audit/log.cpp index 269c5aeff..902dc9196 100644 --- a/src/audit/log.cpp +++ b/src/audit/log.cpp @@ -17,28 +17,27 @@ inline nlohmann::json PropertyValueToJson(const PropertyValue &pv) { case PropertyValue::Type::Null: break; case PropertyValue::Type::Bool: - ret = pv.Value(); + ret = pv.ValueBool(); break; case PropertyValue::Type::Int: - ret = pv.Value(); + ret = pv.ValueInt(); break; case PropertyValue::Type::Double: - ret = pv.Value(); + ret = pv.ValueDouble(); break; case PropertyValue::Type::String: - ret = pv.Value(); + ret = pv.ValueString(); break; case PropertyValue::Type::List: { ret = nlohmann::json::array(); - for (const auto &item : pv.Value>()) { + for (const auto &item : pv.ValueList()) { ret.push_back(PropertyValueToJson(item)); } break; } case PropertyValue::Type::Map: { ret = nlohmann::json::object(); - for (const auto &item : - pv.Value>()) { + for (const auto &item : pv.ValueMap()) { ret.push_back(nlohmann::json::object_t::value_type( item.first, PropertyValueToJson(item.second))); } diff --git a/src/database/single_node/dump.cpp b/src/database/single_node/dump.cpp index 6667adccb..50e049bbf 100644 --- a/src/database/single_node/dump.cpp +++ b/src/database/single_node/dump.cpp @@ -42,20 +42,20 @@ void DumpPropertyValue(std::ostream *os, const PropertyValue &value) { *os << "Null"; return; case PropertyValue::Type::Bool: - *os << (value.Value() ? "true" : "false"); + *os << (value.ValueBool() ? "true" : "false"); return; case PropertyValue::Type::String: - *os << ::utils::Escape(value.Value()); + *os << ::utils::Escape(value.ValueString()); return; case PropertyValue::Type::Int: - *os << value.Value(); + *os << value.ValueInt(); return; case PropertyValue::Type::Double: - DumpPreciseDouble(os, value.Value()); + DumpPreciseDouble(os, value.ValueDouble()); return; case PropertyValue::Type::List: { *os << "["; - const auto &list = value.Value>(); + const auto &list = value.ValueList(); utils::PrintIterable(*os, list, ", ", [](auto &os, const auto &item) { DumpPropertyValue(&os, item); }); @@ -64,7 +64,7 @@ void DumpPropertyValue(std::ostream *os, const PropertyValue &value) { } case PropertyValue::Type::Map: { *os << "{"; - const auto &map = value.Value>(); + const auto &map = value.ValueMap(); utils::PrintIterable(*os, map, ", ", [](auto &os, const auto &kv) { os << kv.first << ": "; DumpPropertyValue(&os, kv.second); diff --git a/src/glue/communication.cpp b/src/glue/communication.cpp index bf25256e0..8bc97c004 100644 --- a/src/glue/communication.cpp +++ b/src/glue/communication.cpp @@ -160,16 +160,16 @@ Value ToBoltValue(const PropertyValue &value) { case PropertyValue::Type::Null: return Value(); case PropertyValue::Type::Bool: - return Value(value.Value()); + return Value(value.ValueBool()); case PropertyValue::Type::Int: - return Value(value.Value()); + return Value(value.ValueInt()); break; case PropertyValue::Type::Double: - return Value(value.Value()); + return Value(value.ValueDouble()); case PropertyValue::Type::String: - return Value(value.Value()); + return Value(value.ValueString()); case PropertyValue::Type::List: { - const auto &values = value.Value>(); + const auto &values = value.ValueList(); std::vector vec; vec.reserve(values.size()); for (const auto &v : values) { @@ -178,7 +178,7 @@ Value ToBoltValue(const PropertyValue &value) { return Value(vec); } case PropertyValue::Type::Map: { - const auto &map = value.Value>(); + const auto &map = value.ValueMap(); std::map dv_map; for (const auto &kv : map) { dv_map.emplace(kv.first, ToBoltValue(kv.second)); diff --git a/src/query/common.cpp b/src/query/common.cpp index 05bf5492d..05bda52d9 100644 --- a/src/query/common.cpp +++ b/src/query/common.cpp @@ -54,17 +54,17 @@ bool TypedValueCompare(const TypedValue &a, const TypedValue &b) { switch (a.type()) { case TypedValue::Type::Bool: - return !a.Value() && b.Value(); + return !a.ValueBool() && b.ValueBool(); case TypedValue::Type::Int: if (b.type() == TypedValue::Type::Double) - return a.Value() < b.Value(); + return a.ValueInt() < b.ValueDouble(); else - return a.Value() < b.Value(); + return a.ValueInt() < b.ValueInt(); case TypedValue::Type::Double: if (b.type() == TypedValue::Type::Int) - return a.Value() < b.Value(); + return a.ValueDouble() < b.ValueInt(); else - return a.Value() < b.Value(); + return a.ValueDouble() < b.ValueDouble(); case TypedValue::Type::String: return a.ValueString() < b.ValueString(); case TypedValue::Type::List: diff --git a/src/query/frontend/ast/pretty_print.cpp b/src/query/frontend/ast/pretty_print.cpp index a355eb261..43c6d8b7b 100644 --- a/src/query/frontend/ast/pretty_print.cpp +++ b/src/query/frontend/ast/pretty_print.cpp @@ -124,27 +124,27 @@ void PrintObject(std::ostream *out, const PropertyValue &value) { break; case PropertyValue::Type::String: - PrintObject(out, value.Value()); + PrintObject(out, value.ValueString()); break; case PropertyValue::Type::Bool: - *out << (value.Value() ? "true" : "false"); + *out << (value.ValueBool() ? "true" : "false"); break; case PropertyValue::Type::Int: - PrintObject(out, value.Value()); + PrintObject(out, value.ValueInt()); break; case PropertyValue::Type::Double: - PrintObject(out, value.Value()); + PrintObject(out, value.ValueDouble()); break; case PropertyValue::Type::List: - PrintObject(out, value.Value>()); + PrintObject(out, value.ValueList()); break; case PropertyValue::Type::Map: - PrintObject(out, value.Value>()); + PrintObject(out, value.ValueMap()); break; } } diff --git a/src/query/interpret/awesome_memgraph_functions.cpp b/src/query/interpret/awesome_memgraph_functions.cpp index 04343973b..1714789ac 100644 --- a/src/query/interpret/awesome_memgraph_functions.cpp +++ b/src/query/interpret/awesome_memgraph_functions.cpp @@ -378,9 +378,9 @@ TypedValue Properties(TypedValue *args, int64_t nargs, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Vertex: - return get_properties(args[0].Value()); + return get_properties(args[0].ValueVertex()); case TypedValue::Type::Edge: - return get_properties(args[0].Value()); + return get_properties(args[0].ValueEdge()); default: throw QueryRuntimeException( "'properties' argument must be a node or an edge."); @@ -456,7 +456,7 @@ TypedValue ToBoolean(TypedValue *args, int64_t nargs, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Bool: - return TypedValue(args[0].Value(), ctx.memory); + return TypedValue(args[0].ValueBool(), ctx.memory); case TypedValue::Type::Int: return TypedValue(args[0].ValueInt() != 0L, ctx.memory); case TypedValue::Type::String: { @@ -480,7 +480,7 @@ TypedValue ToFloat(TypedValue *args, int64_t nargs, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Int: - return TypedValue(static_cast(args[0].Value()), + return TypedValue(static_cast(args[0].ValueInt()), ctx.memory); case TypedValue::Type::Double: return TypedValue(args[0], ctx.memory); @@ -509,7 +509,7 @@ TypedValue ToInteger(TypedValue *args, int64_t nargs, case TypedValue::Type::Int: return TypedValue(args[0], ctx.memory); case TypedValue::Type::Double: - return TypedValue(static_cast(args[0].Value()), + return TypedValue(static_cast(args[0].ValueDouble()), ctx.memory); case TypedValue::Type::String: try { @@ -549,9 +549,9 @@ TypedValue Keys(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Vertex: - return get_keys(args[0].Value()); + return get_keys(args[0].ValueVertex()); case TypedValue::Type::Edge: - return get_keys(args[0].Value()); + return get_keys(args[0].ValueEdge()); default: throw QueryRuntimeException("'keys' argument must be a node or an edge."); } @@ -597,9 +597,9 @@ TypedValue Range(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, Optional>>("range", args, nargs); for (int64_t i = 0; i < nargs; ++i) if (args[i].IsNull()) return TypedValue(ctx.memory); - auto lbound = args[0].Value(); - auto rbound = args[1].Value(); - int64_t step = nargs == 3 ? args[2].Value() : 1; + auto lbound = args[0].ValueInt(); + auto rbound = args[1].ValueInt(); + int64_t step = nargs == 3 ? args[2].ValueInt() : 1; TypedValue::TVector list(ctx.memory); if (lbound <= rbound && step > 0) { for (auto i = lbound; i <= rbound; i += step) { @@ -650,9 +650,9 @@ TypedValue Abs(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Int: - return TypedValue(std::abs(args[0].Value()), ctx.memory); + return TypedValue(std::abs(args[0].ValueInt()), ctx.memory); case TypedValue::Type::Double: - return TypedValue(std::abs(args[0].Value()), ctx.memory); + return TypedValue(std::abs(args[0].ValueDouble()), ctx.memory); default: throw QueryRuntimeException("'abs' argument should be a number."); } @@ -666,11 +666,9 @@ TypedValue Abs(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, case TypedValue::Type::Null: \ return TypedValue(ctx.memory); \ case TypedValue::Type::Int: \ - return TypedValue(lowercased_name(args[0].Value()), \ - ctx.memory); \ + return TypedValue(lowercased_name(args[0].ValueInt()), ctx.memory); \ case TypedValue::Type::Double: \ - return TypedValue(lowercased_name(args[0].Value()), \ - ctx.memory); \ + return TypedValue(lowercased_name(args[0].ValueDouble()), ctx.memory); \ default: \ throw QueryRuntimeException(#lowercased_name \ " argument must be a number."); \ @@ -703,9 +701,9 @@ TypedValue Atan2(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, auto to_double = [](const TypedValue &t) -> double { switch (t.type()) { case TypedValue::Type::Int: - return t.Value(); + return t.ValueInt(); case TypedValue::Type::Double: - return t.Value(); + return t.ValueDouble(); default: throw QueryRuntimeException("Arguments of 'atan2' must be numbers."); } @@ -723,9 +721,9 @@ TypedValue Sign(TypedValue *args, int64_t nargs, const EvaluationContext &ctx, case TypedValue::Type::Null: return TypedValue(ctx.memory); case TypedValue::Type::Int: - return sign(args[0].Value()); + return sign(args[0].ValueInt()); case TypedValue::Type::Double: - return sign(args[0].Value()); + return sign(args[0].ValueDouble()); default: throw QueryRuntimeException("'sign' argument must be a number."); } diff --git a/src/query/interpret/eval.hpp b/src/query/interpret/eval.hpp index c52d91047..5e5bb41cd 100644 --- a/src/query/interpret/eval.hpp +++ b/src/query/interpret/eval.hpp @@ -93,7 +93,7 @@ class ExpressionEvaluator : public ExpressionVisitor { TypedValue Visit(AndOperator &op) override { auto value1 = op.expression1_->Accept(*this); - if (value1.IsBool() && !value1.Value()) { + if (value1.IsBool() && !value1.ValueBool()) { // If first expression is false, don't evaluate the second one. return value1; } @@ -116,7 +116,7 @@ class ExpressionEvaluator : public ExpressionVisitor { throw QueryRuntimeException("CASE expected boolean expression, got {}.", condition.type()); } - if (condition.Value()) { + if (condition.ValueBool()) { return if_operator.then_expression_->Accept(*this); } return if_operator.else_expression_->Accept(*this); @@ -147,7 +147,7 @@ class ExpressionEvaluator : public ExpressionVisitor { auto result = literal == element; if (result.IsNull()) { has_null = true; - } else if (result.Value()) { + } else if (result.ValueBool()) { return TypedValue(true, ctx_->memory); } } @@ -171,7 +171,7 @@ class ExpressionEvaluator : public ExpressionVisitor { if (!index.IsInt()) throw QueryRuntimeException( "Expected an integer as a list index, got {}.", index.type()); - auto index_int = index.Value(); + auto index_int = index.ValueInt(); // NOTE: Take non-const reference to list, so that we can move out the // indexed element as the result. auto &list = lhs.ValueList(); @@ -203,7 +203,7 @@ class ExpressionEvaluator : public ExpressionVisitor { if (!index.IsString()) throw QueryRuntimeException( "Expected a string as a property name, got {}.", index.type()); - return TypedValue(lhs.Value().PropsAt( + return TypedValue(lhs.ValueVertex().PropsAt( dba_->Property(std::string(index.ValueString()))), ctx_->memory); } @@ -212,7 +212,7 @@ class ExpressionEvaluator : public ExpressionVisitor { if (!index.IsString()) throw QueryRuntimeException( "Expected a string as a property name, got {}.", index.type()); - return TypedValue(lhs.Value().PropsAt( + return TypedValue(lhs.ValueEdge().PropsAt( dba_->Property(std::string(index.ValueString()))), ctx_->memory); } @@ -262,8 +262,8 @@ class ExpressionEvaluator : public ExpressionVisitor { return std::max(static_cast(0), std::min(bound, static_cast(list.size()))); }; - auto lower_bound = normalise_bound(_lower_bound.Value()); - auto upper_bound = normalise_bound(_upper_bound.Value()); + auto lower_bound = normalise_bound(_lower_bound.ValueInt()); + auto upper_bound = normalise_bound(_upper_bound.ValueInt()); if (upper_bound <= lower_bound) { return TypedValue(TypedValue::TVector(ctx_->memory), ctx_->memory); } @@ -282,11 +282,11 @@ class ExpressionEvaluator : public ExpressionVisitor { case TypedValue::Type::Null: return TypedValue(ctx_->memory); case TypedValue::Type::Vertex: - return TypedValue(expression_result.Value().PropsAt( + return TypedValue(expression_result.ValueVertex().PropsAt( GetProperty(property_lookup.property_)), ctx_->memory); case TypedValue::Type::Edge: - return TypedValue(expression_result.Value().PropsAt( + return TypedValue(expression_result.ValueEdge().PropsAt( GetProperty(property_lookup.property_)), ctx_->memory); case TypedValue::Type::Map: { @@ -311,7 +311,7 @@ class ExpressionEvaluator : public ExpressionVisitor { case TypedValue::Type::Null: return TypedValue(ctx_->memory); case TypedValue::Type::Vertex: { - const auto &vertex = expression_result.Value(); + const auto &vertex = expression_result.ValueVertex(); for (const auto &label : labels_test.labels_) { if (!vertex.has_label(GetLabel(label))) { return TypedValue(false, ctx_->memory); @@ -462,7 +462,7 @@ class ExpressionEvaluator : public ExpressionVisitor { "Predicate of ALL must evaluate to boolean, got {}.", result.type()); } - if (result.IsNull() || !result.Value()) { + if (result.IsNull() || !result.ValueBool()) { return result; } } @@ -489,7 +489,7 @@ class ExpressionEvaluator : public ExpressionVisitor { "Predicate of SINGLE must evaluate to boolean, got {}.", result.type()); } - if (result.IsNull() || !result.Value()) { + if (result.IsNull() || !result.ValueBool()) { continue; } // Return false if more than one element satisfies the predicate. @@ -549,7 +549,7 @@ class ExpressionEvaluator : public ExpressionVisitor { void SwitchAccessors(TypedValue &value) { switch (value.type()) { case TypedValue::Type::Vertex: { - auto &vertex = value.Value(); + auto &vertex = value.ValueVertex(); switch (graph_view_) { case GraphView::NEW: vertex.SwitchNew(); @@ -563,7 +563,7 @@ class ExpressionEvaluator : public ExpressionVisitor { break; } case TypedValue::Type::Edge: { - auto &edge = value.Value(); + auto &edge = value.ValueEdge(); switch (graph_view_) { case GraphView::NEW: edge.SwitchNew(); @@ -623,7 +623,7 @@ inline int64_t EvaluateInt(ExpressionEvaluator *evaluator, Expression *expr, const std::string &what) { TypedValue value = expr->Accept(*evaluator); try { - return value.Value(); + return value.ValueInt(); } catch (TypedValueException &e) { throw QueryRuntimeException(what + " must be an int"); } diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 86d39a9ec..9a38aee62 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -75,7 +75,7 @@ bool EvaluateFilter(ExpressionEvaluator &evaluator, Expression *filter) { throw QueryRuntimeException( "Filter expression must evaluate to bool or null, got {}.", result.type()); - return result.Value(); + return result.ValueBool(); } template @@ -218,7 +218,7 @@ bool CreateExpand::CreateExpandCursor::Pull(Frame &frame, // get the origin vertex TypedValue &vertex_value = frame[self_.input_symbol_]; ExpectType(self_.input_symbol_, vertex_value, TypedValue::Type::Vertex); - auto &v1 = vertex_value.Value(); + auto &v1 = vertex_value.ValueVertex(); // Similarly to CreateNode, newly created edges and nodes should use the // latest accesors. @@ -262,7 +262,7 @@ VertexAccessor &CreateExpand::CreateExpandCursor::OtherVertex( TypedValue &dest_node_value = frame[self_.node_info_.symbol]; ExpectType(self_.node_info_.symbol, dest_node_value, TypedValue::Type::Vertex); - return dest_node_value.Value(); + return dest_node_value.ValueVertex(); } else { return CreateLocalVertex(self_.node_info_, &frame, context); } @@ -556,7 +556,7 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) { if (vertex_value.IsNull()) continue; ExpectType(self_.input_symbol_, vertex_value, TypedValue::Type::Vertex); - auto &vertex = vertex_value.Value(); + auto &vertex = vertex_value.ValueVertex(); SwitchAccessor(vertex, self_.graph_view_); auto direction = self_.common_.direction; @@ -711,8 +711,7 @@ class ExpandVariableCursor : public Cursor { if (PullInput(frame, context)) { // if lower bound is zero we also yield empty paths if (lower_bound_ == 0) { - auto &start_vertex = - frame[self_.input_symbol_].Value(); + auto &start_vertex = frame[self_.input_symbol_].ValueVertex(); if (!self_.common_.existing_node || CheckExistingNode(start_vertex, self_.common_.node_symbol, frame)) { @@ -776,7 +775,7 @@ class ExpandVariableCursor : public Cursor { if (vertex_value.IsNull()) continue; ExpectType(self_.input_symbol_, vertex_value, TypedValue::Type::Vertex); - auto &vertex = vertex_value.Value(); + auto &vertex = vertex_value.ValueVertex(); SwitchAccessor(vertex, GraphView::OLD); // Evaluate the upper and lower bounds. @@ -889,7 +888,7 @@ class ExpandVariableCursor : public Cursor { bool found_existing = std::any_of(edges_on_frame.begin(), edges_on_frame.end(), [¤t_edge](const TypedValue &edge) { - return current_edge.first == edge.Value(); + return current_edge.first == edge.ValueEdge(); }); if (found_existing) continue; @@ -1211,7 +1210,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor { case TypedValue::Type::Null: return; case TypedValue::Type::Bool: - if (!result.Value()) return; + if (!result.ValueBool()) return; break; default: throw QueryRuntimeException( @@ -1265,7 +1264,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor { if (upper_bound_ < 1 || lower_bound_ > upper_bound_) continue; - const auto &vertex = vertex_value.Value(); + const auto &vertex = vertex_value.ValueVertex(); processed_.emplace(vertex, std::nullopt); expand_from_vertex(vertex); @@ -1284,7 +1283,7 @@ class SingleSourceShortestPathCursor : public query::plan::Cursor { edge_list.emplace_back(expansion.first); auto last_vertex = expansion.second; while (true) { - const EdgeAccessor &last_edge = edge_list.back().Value(); + const EdgeAccessor &last_edge = edge_list.back().ValueEdge(); last_vertex = last_edge.from() == last_vertex ? last_edge.to() : last_edge.from(); // origin_vertex must be in processed @@ -1389,7 +1388,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor { throw QueryRuntimeException( "Calculated weight must be numeric, got {}.", typed_weight.type()); } - if ((typed_weight < TypedValue(0, memory)).Value()) { + if ((typed_weight < TypedValue(0, memory)).ValueBool()) { throw QueryRuntimeException("Calculated weight must be non-negative!"); } @@ -1397,10 +1396,10 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor { auto next_weight = TypedValue(weight, memory) + typed_weight; auto found_it = total_cost_.find(next_state); if (found_it != total_cost_.end() && - found_it->second.Value() <= next_weight.Value()) + found_it->second.ValueDouble() <= next_weight.ValueDouble()) return; - pq_.push({next_weight.Value(), depth + 1, vertex, edge}); + pq_.push({next_weight.ValueDouble(), depth + 1, vertex, edge}); }; // Populates the priority queue structure with expansions @@ -1426,7 +1425,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor { if (!input_cursor_->Pull(frame, context)) return false; const auto &vertex_value = frame[self_.input_symbol_]; if (vertex_value.IsNull()) continue; - auto vertex = vertex_value.Value(); + auto vertex = vertex_value.ValueVertex(); if (self_.common_.existing_node) { const auto &node = frame[self_.common_.node_symbol]; // Due to optional matching the existing node could be null. @@ -1507,7 +1506,7 @@ class ExpandWeightedShortestPathCursor : public query::plan::Cursor { // Place destination node on the frame, handle existence flag. if (self_.common_.existing_node) { const auto &node = frame[self_.common_.node_symbol]; - if ((node != TypedValue(current_vertex, pull_memory)).Value()) + if ((node != TypedValue(current_vertex, pull_memory)).ValueBool()) continue; else // Prevent expanding other paths, because we found the @@ -1841,7 +1840,7 @@ bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) { for (TypedValue &expression_result : expression_results) { if (dba.should_abort()) throw HintedAbortError(); if (expression_result.type() == TypedValue::Type::Edge) - dba.RemoveEdge(expression_result.Value()); + dba.RemoveEdge(expression_result.ValueEdge()); } // delete vertices @@ -1849,7 +1848,7 @@ bool Delete::DeleteCursor::Pull(Frame &frame, ExecutionContext &context) { if (dba.should_abort()) throw HintedAbortError(); switch (expression_result.type()) { case TypedValue::Type::Vertex: { - VertexAccessor &va = expression_result.Value(); + VertexAccessor &va = expression_result.ValueVertex(); va.SwitchNew(); // necessary because an edge deletion could have // updated if (self_.detach_) @@ -1912,10 +1911,10 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, switch (lhs.type()) { case TypedValue::Type::Vertex: - PropsSetChecked(&lhs.Value(), self_.property_, rhs); + PropsSetChecked(&lhs.ValueVertex(), self_.property_, rhs); break; case TypedValue::Type::Edge: - PropsSetChecked(&lhs.Value(), self_.property_, rhs); + PropsSetChecked(&lhs.ValueEdge(), self_.property_, rhs); break; case TypedValue::Type::Null: // Skip setting properties on Null (can occur in optional match). @@ -1987,10 +1986,10 @@ void SetPropertiesOnRecord(database::GraphDbAccessor *dba, switch (rhs.type()) { case TypedValue::Type::Edge: - set_props(rhs.Value().Properties()); + set_props(rhs.ValueEdge().Properties()); break; case TypedValue::Type::Vertex: - set_props(rhs.Value().Properties()); + set_props(rhs.ValueVertex().Properties()); break; case TypedValue::Type::Map: { for (const auto &kv : rhs.ValueMap()) @@ -2023,12 +2022,12 @@ bool SetProperties::SetPropertiesCursor::Pull(Frame &frame, switch (lhs.type()) { case TypedValue::Type::Vertex: - SetPropertiesOnRecord(context.db_accessor, &lhs.Value(), - rhs, self_.op_); + SetPropertiesOnRecord(context.db_accessor, &lhs.ValueVertex(), rhs, + self_.op_); break; case TypedValue::Type::Edge: - SetPropertiesOnRecord(context.db_accessor, &lhs.Value(), - rhs, self_.op_); + SetPropertiesOnRecord(context.db_accessor, &lhs.ValueEdge(), rhs, + self_.op_); break; case TypedValue::Type::Null: // Skip setting properties on Null (can occur in optional match). @@ -2074,7 +2073,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { // Skip setting labels on Null (can occur in optional match). if (vertex_value.IsNull()) return true; ExpectType(self_.input_symbol_, vertex_value, TypedValue::Type::Vertex); - auto &vertex = vertex_value.Value(); + auto &vertex = vertex_value.ValueVertex(); vertex.SwitchNew(); try { for (auto label : self_.labels_) vertex.add_label(label); @@ -2123,7 +2122,7 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, switch (lhs.type()) { case TypedValue::Type::Vertex: try { - lhs.Value().PropsErase(self_.property_); + lhs.ValueVertex().PropsErase(self_.property_); } catch (const RecordDeletedError &) { throw QueryRuntimeException( "Trying to remove properties from a deleted node."); @@ -2131,7 +2130,7 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, break; case TypedValue::Type::Edge: try { - lhs.Value().PropsErase(self_.property_); + lhs.ValueEdge().PropsErase(self_.property_); } catch (const RecordDeletedError &) { throw QueryRuntimeException( "Trying to remove properties from a deleted edge."); @@ -2183,7 +2182,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, // Skip removing labels on Null (can occur in optional match). if (vertex_value.IsNull()) return true; ExpectType(self_.input_symbol_, vertex_value, TypedValue::Type::Vertex); - auto &vertex = vertex_value.Value(); + auto &vertex = vertex_value.ValueVertex(); vertex.SwitchNew(); try { for (auto label : self_.labels_) vertex.remove_label(label); @@ -2237,7 +2236,7 @@ bool ContainsSameEdge(const TypedValue &a, const TypedValue &b) { if (a.type() == TypedValue::Type::List) return compare_to_list(a, b); if (b.type() == TypedValue::Type::List) return compare_to_list(b, a); - return a.Value() == b.Value(); + return a.ValueEdge() == b.ValueEdge(); } } // namespace @@ -2276,7 +2275,6 @@ Accumulate::Accumulate(const std::shared_ptr &input, ACCEPT_WITH_INPUT(Accumulate) - std::vector Accumulate::ModifiedSymbols(const SymbolTable &) const { return symbols_; } @@ -2617,7 +2615,7 @@ class AggregateCursor : public Cursor { // since we skip nulls we either have a valid comparison, or // an exception was just thrown above // safe to assume a bool TypedValue - if (comparison_result.Value()) *value_it = input_value; + if (comparison_result.ValueBool()) *value_it = input_value; } catch (const TypedValueException &) { throw QueryRuntimeException("Unable to get MIN of '{}' and '{}'.", input_value.type(), value_it->type()); @@ -2629,7 +2627,7 @@ class AggregateCursor : public Cursor { EnsureOkForMinMax(input_value); try { TypedValue comparison_result = input_value > *value_it; - if (comparison_result.Value()) *value_it = input_value; + if (comparison_result.ValueBool()) *value_it = input_value; } catch (const TypedValueException &) { throw QueryRuntimeException("Unable to get MAX of '{}' and '{}'.", input_value.type(), value_it->type()); @@ -2728,7 +2726,7 @@ bool Skip::SkipCursor::Pull(Frame &frame, ExecutionContext &context) { throw QueryRuntimeException( "Number of elements to skip must be an integer."); - to_skip_ = to_skip.Value(); + to_skip_ = to_skip.ValueInt(); if (to_skip_ < 0) throw QueryRuntimeException( "Number of elements to skip must be non-negative."); @@ -2789,7 +2787,7 @@ bool Limit::LimitCursor::Pull(Frame &frame, ExecutionContext &context) { throw QueryRuntimeException( "Limit on number of returned elements must be an integer."); - limit_ = limit.Value(); + limit_ = limit.ValueInt(); if (limit_ < 0) throw QueryRuntimeException( "Limit on number of returned elements must be non-negative."); diff --git a/src/query/typed_value.cpp b/src/query/typed_value.cpp index 488611567..16b493572 100644 --- a/src/query/typed_value.cpp +++ b/src/query/typed_value.cpp @@ -28,23 +28,23 @@ TypedValue::TypedValue(const PropertyValue &value, return; case PropertyValue::Type::Bool: type_ = Type::Bool; - bool_v = value.Value(); + bool_v = value.ValueBool(); return; case PropertyValue::Type::Int: type_ = Type::Int; - int_v = value.Value(); + int_v = value.ValueInt(); return; case PropertyValue::Type::Double: type_ = Type::Double; - double_v = value.Value(); + double_v = value.ValueDouble(); return; case PropertyValue::Type::String: type_ = Type::String; - new (&string_v) TString(value.Value(), memory_); + new (&string_v) TString(value.ValueString(), memory_); return; case PropertyValue::Type::List: { type_ = Type::List; - const auto &vec = value.Value>(); + const auto &vec = value.ValueList(); new (&list_v) TVector(memory_); list_v.reserve(vec.size()); for (const auto &v : vec) list_v.emplace_back(v); @@ -52,7 +52,7 @@ TypedValue::TypedValue(const PropertyValue &value, } case PropertyValue::Type::Map: { type_ = Type::Map; - const auto &map = value.Value>(); + const auto &map = value.ValueMap(); new (&map_v) TMap(memory_); for (const auto &kv : map) map_v.emplace(kv.first, kv.second); return; @@ -73,23 +73,23 @@ TypedValue::TypedValue(PropertyValue &&other, utils::MemoryResource *memory) break; case PropertyValue::Type::Bool: type_ = Type::Bool; - bool_v = other.Value(); + bool_v = other.ValueBool(); break; case PropertyValue::Type::Int: type_ = Type::Int; - int_v = other.Value(); + int_v = other.ValueInt(); break; case PropertyValue::Type::Double: type_ = Type::Double; - double_v = other.Value(); + double_v = other.ValueDouble(); break; case PropertyValue::Type::String: type_ = Type::String; - new (&string_v) TString(other.Value(), memory_); + new (&string_v) TString(other.ValueString(), memory_); break; case PropertyValue::Type::List: { type_ = Type::List; - auto &vec = other.Value>(); + auto &vec = other.ValueList(); new (&list_v) TVector(memory_); list_v.reserve(vec.size()); for (auto &v : vec) list_v.emplace_back(std::move(v)); @@ -97,7 +97,7 @@ TypedValue::TypedValue(PropertyValue &&other, utils::MemoryResource *memory) } case PropertyValue::Type::Map: { type_ = Type::Map; - auto &map = other.Value>(); + auto &map = other.ValueMap(); new (&map_v) TMap(memory_); for (auto &kv : map) map_v.emplace(kv.first, std::move(kv.second)); break; @@ -214,31 +214,21 @@ TypedValue::operator PropertyValue() const { "Unsupported conversion from TypedValue to PropertyValue"); } -#define DEFINE_VALUE_AND_TYPE_GETTERS(type_param, type_enum, field) \ - template <> \ - type_param &TypedValue::Value() { \ - if (type_ != Type::type_enum) \ - throw TypedValueException( \ - "Incompatible template param '{}' and type '{}'", Type::type_enum, \ - type_); \ - return field; \ - } \ - \ - template <> \ - const type_param &TypedValue::Value() const { \ - if (type_ != Type::type_enum) \ - throw TypedValueException( \ - "Incompatible template param '{}' and type '{}'", Type::type_enum, \ - type_); \ - return field; \ - } \ - \ - type_param &TypedValue::Value##type_enum() { return Value(); } \ - \ - const type_param &TypedValue::Value##type_enum() const { \ - return Value(); \ - } \ - \ +#define DEFINE_VALUE_AND_TYPE_GETTERS(type_param, type_enum, field) \ + type_param &TypedValue::Value##type_enum() { \ + if (type_ != Type::type_enum) \ + throw TypedValueException("TypedValue is of type '{}', not '{}'", type_, \ + Type::type_enum); \ + return field; \ + } \ + \ + const type_param &TypedValue::Value##type_enum() const { \ + if (type_ != Type::type_enum) \ + throw TypedValueException("TypedValue is of type '{}', not '{}'", type_, \ + Type::type_enum); \ + return field; \ + } \ + \ bool TypedValue::Is##type_enum() const { return type_ == Type::type_enum; } DEFINE_VALUE_AND_TYPE_GETTERS(bool, Bool, bool_v) @@ -303,11 +293,11 @@ std::ostream &operator<<(std::ostream &os, const TypedValue &value) { case TypedValue::Type::Null: return os << "Null"; case TypedValue::Type::Bool: - return os << (value.Value() ? "true" : "false"); + return os << (value.ValueBool() ? "true" : "false"); case TypedValue::Type::Int: - return os << value.Value(); + return os << value.ValueInt(); case TypedValue::Type::Double: - return os << value.Value(); + return os << value.ValueDouble(); case TypedValue::Type::String: return os << value.ValueString(); case TypedValue::Type::List: @@ -322,11 +312,11 @@ std::ostream &operator<<(std::ostream &os, const TypedValue &value) { }); return os << "}"; case TypedValue::Type::Vertex: - return os << value.Value(); + return os << value.ValueVertex(); case TypedValue::Type::Edge: - return os << value.Value(); + return os << value.ValueEdge(); case TypedValue::Type::Path: - return os << value.Value(); + return os << value.ValuePath(); } LOG(FATAL) << "Unsupported PropertyValue::Type"; } @@ -565,9 +555,9 @@ TypedValue::~TypedValue() { double ToDouble(const TypedValue &value) { switch (value.type()) { case TypedValue::Type::Int: - return (double)value.Value(); + return (double)value.ValueInt(); case TypedValue::Type::Double: - return value.Value(); + return value.ValueDouble(); default: throw TypedValueException( "Unsupported TypedValue::Type conversion to double"); @@ -606,8 +596,7 @@ TypedValue operator<(const TypedValue &a, const TypedValue &b) { if (a.IsDouble() || b.IsDouble()) { return TypedValue(ToDouble(a) < ToDouble(b), a.GetMemoryResource()); } else { - return TypedValue(a.Value() < b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueInt() < b.ValueInt(), a.GetMemoryResource()); } } @@ -621,25 +610,22 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) { switch (a.type()) { case TypedValue::Type::Bool: - return TypedValue(a.Value() == b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueBool() == b.ValueBool(), a.GetMemoryResource()); case TypedValue::Type::Int: if (b.IsDouble()) return TypedValue(ToDouble(a) == ToDouble(b), a.GetMemoryResource()); else - return TypedValue(a.Value() == b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueInt() == b.ValueInt(), a.GetMemoryResource()); case TypedValue::Type::Double: return TypedValue(ToDouble(a) == ToDouble(b), a.GetMemoryResource()); case TypedValue::Type::String: return TypedValue(a.ValueString() == b.ValueString(), a.GetMemoryResource()); case TypedValue::Type::Vertex: - return TypedValue(a.Value() == b.Value(), + return TypedValue(a.ValueVertex() == b.ValueVertex(), a.GetMemoryResource()); case TypedValue::Type::Edge: - return TypedValue(a.Value() == b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueEdge() == b.ValueEdge(), a.GetMemoryResource()); case TypedValue::Type::List: { // We are not compatible with neo4j at this point. In neo4j 2 = [2] // compares @@ -672,7 +658,7 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) { if (found_b_it == map_b.end()) return TypedValue(false, a.GetMemoryResource()); TypedValue comparison = kv_a.second == found_b_it->second; - if (comparison.IsNull() || !comparison.Value()) + if (comparison.IsNull() || !comparison.ValueBool()) return TypedValue(false, a.GetMemoryResource()); } return TypedValue(true, a.GetMemoryResource()); @@ -686,7 +672,7 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) { TypedValue operator!(const TypedValue &a) { if (a.IsNull()) return TypedValue(a.GetMemoryResource()); - if (a.IsBool()) return TypedValue(!a.Value(), a.GetMemoryResource()); + if (a.IsBool()) return TypedValue(!a.ValueBool(), a.GetMemoryResource()); throw TypedValueException("Invalid logical not operand type (!{})", a.type()); } @@ -699,8 +685,8 @@ TypedValue operator!(const TypedValue &a) { std::string ValueToString(const TypedValue &value) { // TODO: Should this allocate a string through value.GetMemoryResource()? if (value.IsString()) return std::string(value.ValueString()); - if (value.IsInt()) return std::to_string(value.Value()); - if (value.IsDouble()) return fmt::format("{}", value.Value()); + if (value.IsInt()) return std::to_string(value.ValueInt()); + if (value.IsDouble()) return fmt::format("{}", value.ValueDouble()); // unsupported situations throw TypedValueException( "Unsupported TypedValue::Type conversion to string"); @@ -708,17 +694,15 @@ std::string ValueToString(const TypedValue &value) { TypedValue operator-(const TypedValue &a) { if (a.IsNull()) return TypedValue(a.GetMemoryResource()); - if (a.IsInt()) return TypedValue(-a.Value(), a.GetMemoryResource()); - if (a.IsDouble()) - return TypedValue(-a.Value(), a.GetMemoryResource()); + if (a.IsInt()) return TypedValue(-a.ValueInt(), a.GetMemoryResource()); + if (a.IsDouble()) return TypedValue(-a.ValueDouble(), a.GetMemoryResource()); throw TypedValueException("Invalid unary minus operand type (-{})", a.type()); } TypedValue operator+(const TypedValue &a) { if (a.IsNull()) return TypedValue(a.GetMemoryResource()); - if (a.IsInt()) return TypedValue(+a.Value(), a.GetMemoryResource()); - if (a.IsDouble()) - return TypedValue(+a.Value(), a.GetMemoryResource()); + if (a.IsInt()) return TypedValue(+a.ValueInt(), a.GetMemoryResource()); + if (a.IsDouble()) return TypedValue(+a.ValueDouble(), a.GetMemoryResource()); throw TypedValueException("Invalid unary plus operand type (+{})", a.type()); } @@ -778,8 +762,7 @@ TypedValue operator+(const TypedValue &a, const TypedValue &b) { if (a.IsDouble() || b.IsDouble()) { return TypedValue(ToDouble(a) + ToDouble(b), a.GetMemoryResource()); } else { - return TypedValue(a.Value() + b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueInt() + b.ValueInt(), a.GetMemoryResource()); } } @@ -791,8 +774,7 @@ TypedValue operator-(const TypedValue &a, const TypedValue &b) { if (a.IsDouble() || b.IsDouble()) { return TypedValue(ToDouble(a) - ToDouble(b), a.GetMemoryResource()); } else { - return TypedValue(a.Value() - b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueInt() - b.ValueInt(), a.GetMemoryResource()); } } @@ -804,10 +786,8 @@ TypedValue operator/(const TypedValue &a, const TypedValue &b) { if (a.IsDouble() || b.IsDouble()) { return TypedValue(ToDouble(a) / ToDouble(b), a.GetMemoryResource()); } else { - if (b.Value() == 0LL) - throw TypedValueException("Division by zero"); - return TypedValue(a.Value() / b.Value(), - a.GetMemoryResource()); + if (b.ValueInt() == 0LL) throw TypedValueException("Division by zero"); + return TypedValue(a.ValueInt() / b.ValueInt(), a.GetMemoryResource()); } } @@ -819,8 +799,7 @@ TypedValue operator*(const TypedValue &a, const TypedValue &b) { if (a.IsDouble() || b.IsDouble()) { return TypedValue(ToDouble(a) * ToDouble(b), a.GetMemoryResource()); } else { - return TypedValue(a.Value() * b.Value(), - a.GetMemoryResource()); + return TypedValue(a.ValueInt() * b.ValueInt(), a.GetMemoryResource()); } } @@ -833,9 +812,8 @@ TypedValue operator%(const TypedValue &a, const TypedValue &b) { return TypedValue(static_cast(fmod(ToDouble(a), ToDouble(b))), a.GetMemoryResource()); } else { - if (b.Value() == 0LL) throw TypedValueException("Mod with zero"); - return TypedValue(a.Value() % b.Value(), - a.GetMemoryResource()); + if (b.ValueInt() == 0LL) throw TypedValueException("Mod with zero"); + return TypedValue(a.ValueInt() % b.ValueInt(), a.GetMemoryResource()); } } @@ -850,9 +828,9 @@ TypedValue operator&&(const TypedValue &a, const TypedValue &b) { EnsureLogicallyOk(a, b, "logical AND"); // at this point we only have null and bool // if either operand is false, the result is false - if (a.IsBool() && !a.Value()) + if (a.IsBool() && !a.ValueBool()) return TypedValue(false, a.GetMemoryResource()); - if (b.IsBool() && !b.Value()) + if (b.IsBool() && !b.ValueBool()) return TypedValue(false, a.GetMemoryResource()); if (a.IsNull() || b.IsNull()) return TypedValue(a.GetMemoryResource()); // neither is false, neither is null, thus both are true @@ -863,9 +841,9 @@ TypedValue operator||(const TypedValue &a, const TypedValue &b) { EnsureLogicallyOk(a, b, "logical OR"); // at this point we only have null and bool // if either operand is true, the result is true - if (a.IsBool() && a.Value()) + if (a.IsBool() && a.ValueBool()) return TypedValue(true, a.GetMemoryResource()); - if (b.IsBool() && b.Value()) + if (b.IsBool() && b.ValueBool()) return TypedValue(true, a.GetMemoryResource()); if (a.IsNull() || b.IsNull()) return TypedValue(a.GetMemoryResource()); // neither is true, neither is null, thus both are false @@ -878,7 +856,7 @@ TypedValue operator^(const TypedValue &a, const TypedValue &b) { if (a.IsNull() || b.IsNull()) return TypedValue(a.GetMemoryResource()); else - return TypedValue(static_cast(a.Value() ^ b.Value()), + return TypedValue(static_cast(a.ValueBool() ^ b.ValueBool()), a.GetMemoryResource()); } @@ -888,7 +866,7 @@ bool TypedValue::BoolEqual::operator()(const TypedValue &lhs, TypedValue equality_result = lhs == rhs; switch (equality_result.type()) { case TypedValue::Type::Bool: - return equality_result.Value(); + return equality_result.ValueBool(); case TypedValue::Type::Null: return false; default: @@ -903,14 +881,14 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const { case TypedValue::Type::Null: return 31; case TypedValue::Type::Bool: - return std::hash{}(value.Value()); + return std::hash{}(value.ValueBool()); case TypedValue::Type::Int: // we cast int to double for hashing purposes // to be consistent with TypedValue equality // in which (2.0 == 2) returns true - return std::hash{}((double)value.Value()); + return std::hash{}((double)value.ValueInt()); case TypedValue::Type::Double: - return std::hash{}(value.Value()); + return std::hash{}(value.ValueDouble()); case TypedValue::Type::String: return std::hash{}(value.ValueString()); case TypedValue::Type::List: { @@ -926,9 +904,9 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const { return hash; } case TypedValue::Type::Vertex: - return value.Value().gid(); + return value.ValueVertex().gid(); case TypedValue::Type::Edge: - return value.Value().gid(); + return value.ValueEdge().gid(); case TypedValue::Type::Path: { const auto &vertices = value.ValuePath().vertices(); const auto &edges = value.ValuePath().edges(); diff --git a/src/query/typed_value.hpp b/src/query/typed_value.hpp index e1b3d89bd..8119fc61c 100644 --- a/src/query/typed_value.hpp +++ b/src/query/typed_value.hpp @@ -48,6 +48,7 @@ class TypedValue { * then it implicitly instantiates TypedValue::Value before * explicit instantiation in .cpp file. If the implementation is in * the .cpp file, it won't link. + * TODO: No longer the case as Value was removed. */ struct Hash { size_t operator()(const TypedValue &value) const; @@ -454,19 +455,6 @@ class TypedValue { Type type() const { return type_; } - /** - * Returns the value of the property as given type T. - * The behavior of this function is undefined if - * T does not correspond to this property's type_. - * - * @tparam T Type to interpret the value as. - * @return The value as type T. - */ - template - T &Value(); - template - const T &Value() const; - // TODO consider adding getters for primitives by value (and not by ref) #define DECLARE_VALUE_AND_TYPE_GETTERS(type_param, field) \ diff --git a/src/storage/common/types/property_value.cpp b/src/storage/common/types/property_value.cpp index 52b545555..04728ada1 100644 --- a/src/storage/common/types/property_value.cpp +++ b/src/storage/common/types/property_value.cpp @@ -1,106 +1,5 @@ #include "storage/common/types/property_value.hpp" -// const value extraction template instantiations -template <> -const bool &PropertyValue::Value() const { - if (type_ != Type::Bool) { - throw PropertyValueException("Incompatible template param and type"); - } - return bool_v; -} - -template <> -const int64_t &PropertyValue::Value() const { - if (type_ != Type::Int) { - throw PropertyValueException("Incompatible template param and type"); - } - return int_v; -} - -template <> -const double &PropertyValue::Value() const { - if (type_ != Type::Double) { - throw PropertyValueException("Incompatible template param and type"); - } - return double_v; -} - -template <> -const std::string &PropertyValue::Value() const { - if (type_ != Type::String) { - throw PropertyValueException("Incompatible template param and type"); - } - return string_v; -} - -template <> -const std::vector - &PropertyValue::Value>() const { - if (type_ != Type::List) { - throw PropertyValueException("Incompatible template param and type"); - } - return list_v; -} - -template <> -const std::map - &PropertyValue::Value>() const { - if (type_ != Type::Map) { - throw PropertyValueException("Incompatible template param and type"); - } - return map_v; -} - -// value extraction template instantiations -template <> -bool &PropertyValue::Value() { - if (type_ != Type::Bool) { - throw PropertyValueException("Incompatible template param and type"); - } - return bool_v; -} - -template <> -int64_t &PropertyValue::Value() { - if (type_ != Type::Int) { - throw PropertyValueException("Incompatible template param and type"); - } - return int_v; -} - -template <> -double &PropertyValue::Value() { - if (type_ != Type::Double) { - throw PropertyValueException("Incompatible template param and type"); - } - return double_v; -} - -template <> -std::string &PropertyValue::Value() { - if (type_ != Type::String) { - throw PropertyValueException("Incompatible template param and type"); - } - return string_v; -} - -template <> -std::vector &PropertyValue::Value>() { - if (type_ != Type::List) { - throw PropertyValueException("Incompatible template param and type"); - } - return list_v; -} - -template <> -std::map - &PropertyValue::Value>() { - if (type_ != Type::Map) { - throw PropertyValueException("Incompatible template param and type"); - } - return map_v; -} - // constructors PropertyValue::PropertyValue(const PropertyValue &other) : type_(other.type_) { switch (other.type_) { @@ -273,23 +172,23 @@ std::ostream &operator<<(std::ostream &os, const PropertyValue &value) { case PropertyValue::Type::Null: return os << "Null"; case PropertyValue::Type::Bool: - return os << (value.Value() ? "true" : "false"); + return os << (value.ValueBool() ? "true" : "false"); case PropertyValue::Type::String: - return os << value.Value(); + return os << value.ValueString(); case PropertyValue::Type::Int: - return os << value.Value(); + return os << value.ValueInt(); case PropertyValue::Type::Double: - return os << value.Value(); + return os << value.ValueDouble(); case PropertyValue::Type::List: os << "["; - for (const auto &x : value.Value>()) { + for (const auto &x : value.ValueList()) { os << x << ","; } return os << "]"; case PropertyValue::Type::Map: os << "{"; for (const auto &kv : - value.Value>()) { + value.ValueMap()) { os << kv.first << ": " << kv.second << ","; } return os << "}"; @@ -302,19 +201,17 @@ bool operator==(const PropertyValue &first, const PropertyValue &second) { case PropertyValue::Type::Null: return true; case PropertyValue::Type::Bool: - return first.Value() == second.Value(); + return first.ValueBool() == second.ValueBool(); case PropertyValue::Type::Int: - return first.Value() == second.Value(); + return first.ValueInt() == second.ValueInt(); case PropertyValue::Type::Double: - return first.Value() == second.Value(); + return first.ValueDouble() == second.ValueDouble(); case PropertyValue::Type::String: - return first.Value() == second.Value(); + return first.ValueString() == second.ValueString(); case PropertyValue::Type::List: - return first.Value>() == - second.Value>(); + return first.ValueList() == second.ValueList(); case PropertyValue::Type::Map: - return first.Value>() == - second.Value>(); + return first.ValueMap() == second.ValueMap(); } } @@ -324,18 +221,16 @@ bool operator<(const PropertyValue &first, const PropertyValue &second) { case PropertyValue::Type::Null: return false; case PropertyValue::Type::Bool: - return first.Value() < second.Value(); + return first.ValueBool() < second.ValueBool(); case PropertyValue::Type::Int: - return first.Value() < second.Value(); + return first.ValueInt() < second.ValueInt(); case PropertyValue::Type::Double: - return first.Value() < second.Value(); + return first.ValueDouble() < second.ValueDouble(); case PropertyValue::Type::String: - return first.Value() < second.Value(); + return first.ValueString() < second.ValueString(); case PropertyValue::Type::List: - return first.Value>() < - second.Value>(); + return first.ValueList() < second.ValueList(); case PropertyValue::Type::Map: - return first.Value>() < - second.Value>(); + return first.ValueMap() < second.ValueMap(); } } diff --git a/src/storage/common/types/property_value.hpp b/src/storage/common/types/property_value.hpp index 63d84de73..cff638713 100644 --- a/src/storage/common/types/property_value.hpp +++ b/src/storage/common/types/property_value.hpp @@ -89,19 +89,6 @@ class PropertyValue { bool IsNull() const { return type_ == Type::Null; } - /** - * Returns the value of the property as given type T. - * The behavior of this function is undefined if - * T does not correspond to this property's type_. - * - * @tparam T Type to interpret the value as. - * @return The value as type T. - */ - template - const T &Value() const; - template - T &Value(); - bool ValueBool() const { if (type_ != Type::Bool) { throw PropertyValueException("This value isn't a bool!"); diff --git a/src/storage/common/types/slk.cpp b/src/storage/common/types/slk.cpp index 0140c365c..e21e18840 100644 --- a/src/storage/common/types/slk.cpp +++ b/src/storage/common/types/slk.cpp @@ -9,23 +9,23 @@ void Save(const PropertyValue &value, slk::Builder *builder) { return; case PropertyValue::Type::Bool: slk::Save(static_cast(1), builder); - slk::Save(value.Value(), builder); + slk::Save(value.ValueBool(), builder); return; case PropertyValue::Type::Int: slk::Save(static_cast(2), builder); - slk::Save(value.Value(), builder); + slk::Save(value.ValueInt(), builder); return; case PropertyValue::Type::Double: slk::Save(static_cast(3), builder); - slk::Save(value.Value(), builder); + slk::Save(value.ValueDouble(), builder); return; case PropertyValue::Type::String: slk::Save(static_cast(4), builder); - slk::Save(value.Value(), builder); + slk::Save(value.ValueString(), builder); return; case PropertyValue::Type::List: { slk::Save(static_cast(5), builder); - const auto &values = value.Value>(); + const auto &values = value.ValueList(); size_t size = values.size(); slk::Save(size, builder); for (const auto &v : values) { @@ -35,7 +35,7 @@ void Save(const PropertyValue &value, slk::Builder *builder) { } case PropertyValue::Type::Map: { slk::Save(static_cast(6), builder); - const auto &map = value.Value>(); + const auto &map = value.ValueMap(); size_t size = map.size(); slk::Save(size, builder); for (const auto &kv : map) { diff --git a/src/storage/single_node/indexes/label_property_index.hpp b/src/storage/single_node/indexes/label_property_index.hpp index 66a86ada9..9f6545d5f 100644 --- a/src/storage/single_node/indexes/label_property_index.hpp +++ b/src/storage/single_node/indexes/label_property_index.hpp @@ -409,23 +409,23 @@ class LabelPropertyIndex { case PropertyValue::Type::Null: return false; case PropertyValue::Type::String: - return a.Value() < b.Value(); + return a.ValueString() < b.ValueString(); case PropertyValue::Type::Bool: - return a.Value() < b.Value(); + return a.ValueBool() < b.ValueBool(); case PropertyValue::Type::Int: - return a.Value() < b.Value(); + return a.ValueInt() < b.ValueInt(); case PropertyValue::Type::Double: - return a.Value() < b.Value(); + return a.ValueDouble() < b.ValueDouble(); case PropertyValue::Type::List: { - auto va = a.Value>(); - auto vb = b.Value>(); + auto va = a.ValueList(); + auto vb = b.ValueList(); if (va.size() != vb.size()) return va.size() < vb.size(); return lexicographical_compare(va.begin(), va.end(), vb.begin(), vb.end(), Less); } case PropertyValue::Type::Map: { - auto ma = a.Value>(); - auto mb = b.Value>(); + auto ma = a.ValueMap(); + auto mb = b.ValueMap(); if (ma.size() != mb.size()) return ma.size() < mb.size(); const auto cmp = [](const auto &a, const auto &b) { if (a.first != b.first) @@ -445,8 +445,8 @@ class LabelPropertyIndex { value.type() == PropertyValue::Type::Double) << "Invalid data type."; if (value.type() == PropertyValue::Type::Int) - return static_cast(value.Value()); - return value.Value(); + return static_cast(value.ValueInt()); + return value.ValueDouble(); }; // Types are int and double - convert int to double diff --git a/src/storage/single_node_ha/indexes/label_property_index.hpp b/src/storage/single_node_ha/indexes/label_property_index.hpp index 8a99a4e59..c3b153576 100644 --- a/src/storage/single_node_ha/indexes/label_property_index.hpp +++ b/src/storage/single_node_ha/indexes/label_property_index.hpp @@ -409,23 +409,23 @@ class LabelPropertyIndex { case PropertyValue::Type::Null: return false; case PropertyValue::Type::String: - return a.Value() < b.Value(); + return a.ValueString() < b.ValueString(); case PropertyValue::Type::Bool: - return a.Value() < b.Value(); + return a.ValueBool() < b.ValueBool(); case PropertyValue::Type::Int: - return a.Value() < b.Value(); + return a.ValueInt() < b.ValueInt(); case PropertyValue::Type::Double: - return a.Value() < b.Value(); + return a.ValueDouble() < b.ValueDouble(); case PropertyValue::Type::List: { - auto va = a.Value>(); - auto vb = b.Value>(); + auto va = a.ValueList(); + auto vb = b.ValueList(); if (va.size() != vb.size()) return va.size() < vb.size(); return lexicographical_compare(va.begin(), va.end(), vb.begin(), vb.end(), Less); } case PropertyValue::Type::Map: { - auto ma = a.Value>(); - auto mb = b.Value>(); + auto ma = a.ValueMap(); + auto mb = b.ValueMap(); if (ma.size() != mb.size()) return ma.size() < mb.size(); const auto cmp = [](const auto &a, const auto &b) { if (a.first != b.first) @@ -445,8 +445,8 @@ class LabelPropertyIndex { value.type() == PropertyValue::Type::Double) << "Invalid data type."; if (value.type() == PropertyValue::Type::Int) - return static_cast(value.Value()); - return value.Value(); + return static_cast(value.ValueInt()); + return value.ValueDouble(); }; // Types are int and double - convert int to double diff --git a/tests/unit/bfs_common.hpp b/tests/unit/bfs_common.hpp index 5d44bbc8d..5fc4400ae 100644 --- a/tests/unit/bfs_common.hpp +++ b/tests/unit/bfs_common.hpp @@ -274,8 +274,8 @@ void CheckPath(database::GraphDbAccessor *dba, const VertexAccessor &source, ASSERT_TRUE(edge.from() == curr || edge.to() == curr); VertexAccessor next = edge.from_is(curr) ? edge.to() : edge.from(); - int from = GetProp(curr, "id", dba).Value(); - int to = GetProp(next, "id", dba).Value(); + int from = GetProp(curr, "id", dba).ValueInt(); + int to = GetProp(next, "id", dba).ValueInt(); ASSERT_TRUE(utils::Contains(edges, std::make_pair(from, to))); curr = next; @@ -295,8 +295,8 @@ std::vector> CheckPathsAndExtractDistances( for (size_t i = 0; i < kVertexCount; ++i) distances[i][i] = 0; for (const auto &row : results) { - auto source = GetProp(row[0].ValueVertex(), "id", dba).Value(); - auto sink = GetProp(row[1].ValueVertex(), "id", dba).Value(); + auto source = GetProp(row[0].ValueVertex(), "id", dba).ValueInt(); + auto sink = GetProp(row[1].ValueVertex(), "id", dba).ValueInt(); distances[source][sink] = row[2].ValueList().size(); CheckPath(dba, row[0].ValueVertex(), row[1].ValueVertex(), row[2].ValueList(), edges); @@ -433,9 +433,9 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, auto edges = kEdges; if (blocked.IsEdge()) { int from = - GetProp(blocked.ValueEdge(), "from", dba_ptr.get()).Value(); + GetProp(blocked.ValueEdge(), "from", dba_ptr.get()).ValueInt(); int to = - GetProp(blocked.ValueEdge(), "to", dba_ptr.get()).Value(); + GetProp(blocked.ValueEdge(), "to", dba_ptr.get()).ValueInt(); edges.erase(std::remove_if(edges.begin(), edges.end(), [from, to](const auto &e) { return std::get<0>(e) == from && @@ -450,7 +450,7 @@ void BfsTest(Database *db, int lower_bound, int upper_bound, // When a vertex is blocked, we remove all edges that lead into it. if (blocked.IsVertex()) { int id = - GetProp(blocked.ValueVertex(), "id", dba_ptr.get()).Value(); + GetProp(blocked.ValueVertex(), "id", dba_ptr.get()).ValueInt(); edges_blocked.erase( std::remove_if(edges_blocked.begin(), edges_blocked.end(), [id](const auto &e) { return e.second == id; }), diff --git a/tests/unit/cypher_main_visitor.cpp b/tests/unit/cypher_main_visitor.cpp index ab5f90cc7..05940e0f8 100644 --- a/tests/unit/cypher_main_visitor.cpp +++ b/tests/unit/cypher_main_visitor.cpp @@ -1027,7 +1027,7 @@ TEST_P(CypherMainVisitorTest, NodePattern) { for (auto x : node->properties_) { TypedValue value = ast_generator.LiteralValue(x.second); ASSERT_TRUE(value.type() == TypedValue::Type::Int); - properties[x.first] = value.Value(); + properties[x.first] = value.ValueInt(); } EXPECT_THAT(properties, UnorderedElementsAre(Pair(ast_generator.Prop("a"), 5), @@ -1153,7 +1153,7 @@ TEST_P(CypherMainVisitorTest, RelationshipPatternDetails) { for (auto x : edge->properties_) { TypedValue value = ast_generator.LiteralValue(x.second); ASSERT_TRUE(value.type() == TypedValue::Type::Int); - properties[x.first] = value.Value(); + properties[x.first] = value.ValueInt(); } EXPECT_THAT(properties, UnorderedElementsAre(Pair(ast_generator.Prop("a"), 5), diff --git a/tests/unit/database_dump.cpp b/tests/unit/database_dump.cpp index c64b3dcff..63f8e0763 100644 --- a/tests/unit/database_dump.cpp +++ b/tests/unit/database_dump.cpp @@ -139,7 +139,7 @@ class DatabaseEnvironment { props.emplace(dba.PropertyName(kv.first), kv.second); } CHECK(props.count(kPropertyId) == 1); - const auto id = props[kPropertyId].Value(); + const auto id = props[kPropertyId].ValueInt(); gid_mapping[vertex.gid()] = id; vertices.insert({id, labels, props}); } diff --git a/tests/unit/graph_db_accessor.cpp b/tests/unit/graph_db_accessor.cpp index 00c9001c0..75586259a 100644 --- a/tests/unit/graph_db_accessor.cpp +++ b/tests/unit/graph_db_accessor.cpp @@ -387,8 +387,8 @@ TEST(GraphDbAccessorTest, Transfer) { auto dba3 = db.Access(); // we can transfer accessors even though the GraphDbAccessor they // belong to is not alive anymore - EXPECT_EQ(dba3.Transfer(v1)->PropsAt(prop).Value(), 1); - EXPECT_EQ(dba3.Transfer(e12)->PropsAt(prop).Value(), 12); + EXPECT_EQ(dba3.Transfer(v1)->PropsAt(prop).ValueInt(), 1); + EXPECT_EQ(dba3.Transfer(e12)->PropsAt(prop).ValueInt(), 12); } int main(int argc, char **argv) { diff --git a/tests/unit/graph_db_accessor_index_api.cpp b/tests/unit/graph_db_accessor_index_api.cpp index 21da58032..99ce98d2f 100644 --- a/tests/unit/graph_db_accessor_index_api.cpp +++ b/tests/unit/graph_db_accessor_index_api.cpp @@ -316,43 +316,37 @@ TEST_F(GraphDbAccessorIndex, LabelPropertyValueSorting) { EXPECT_EQ(property_value.type(), expected_property_value[cnt].type()); switch (property_value.type()) { case PropertyValue::Type::Bool: - EXPECT_EQ(property_value.Value(), - expected_property_value[cnt].Value()); + EXPECT_EQ(property_value.ValueBool(), + expected_property_value[cnt].ValueBool()); break; case PropertyValue::Type::Double: - EXPECT_EQ(property_value.Value(), - expected_property_value[cnt].Value()); + EXPECT_EQ(property_value.ValueDouble(), + expected_property_value[cnt].ValueDouble()); break; case PropertyValue::Type::Int: - EXPECT_EQ(property_value.Value(), - expected_property_value[cnt].Value()); + EXPECT_EQ(property_value.ValueInt(), + expected_property_value[cnt].ValueInt()); break; case PropertyValue::Type::String: - EXPECT_EQ(property_value.Value(), - expected_property_value[cnt].Value()); + EXPECT_EQ(property_value.ValueString(), + expected_property_value[cnt].ValueString()); break; case PropertyValue::Type::List: { - auto received_value = - property_value.Value>(); - auto expected_value = - expected_property_value[cnt].Value>(); + auto received_value = property_value.ValueList(); + auto expected_value = expected_property_value[cnt].ValueList(); EXPECT_EQ(received_value.size(), expected_value.size()); EXPECT_EQ(received_value.size(), 1); - EXPECT_EQ(received_value[0].Value(), - expected_value[0].Value()); + EXPECT_EQ(received_value[0].ValueInt(), expected_value[0].ValueInt()); break; } case PropertyValue::Type::Map: { - auto received_value = - property_value.Value>(); - auto expected_value = - expected_property_value[cnt] - .Value>(); + auto received_value = property_value.ValueMap(); + auto expected_value = expected_property_value[cnt].ValueMap(); EXPECT_EQ(received_value.size(), expected_value.size()); for (const auto &kv : expected_value) { auto found = expected_value.find(kv.first); EXPECT_NE(found, expected_value.end()); - EXPECT_EQ(kv.second.Value(), found->second.Value()); + EXPECT_EQ(kv.second.ValueInt(), found->second.ValueInt()); } break; } diff --git a/tests/unit/interpreter.cpp b/tests/unit/interpreter.cpp index e049a3851..f1df4169f 100644 --- a/tests/unit/interpreter.cpp +++ b/tests/unit/interpreter.cpp @@ -38,42 +38,42 @@ TEST_F(InterpreterTest, AstCache) { EXPECT_EQ(stream.GetHeader()[0], "2 + 3"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 5); + ASSERT_EQ(stream.GetResults()[0][0].ValueInt(), 5); } { // Cached ast, different literals. auto stream = Interpret("RETURN 5 + 4"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 9); + ASSERT_EQ(stream.GetResults()[0][0].ValueInt(), 9); } { // Different ast (because of different types). auto stream = Interpret("RETURN 5.5 + 4"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 9.5); + ASSERT_EQ(stream.GetResults()[0][0].ValueDouble(), 9.5); } { // Cached ast, same literals. auto stream = Interpret("RETURN 2 + 3"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 5); + ASSERT_EQ(stream.GetResults()[0][0].ValueInt(), 5); } { // Cached ast, different literals. auto stream = Interpret("RETURN 10.5 + 1"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 11.5); + ASSERT_EQ(stream.GetResults()[0][0].ValueDouble(), 11.5); } { // Cached ast, same literals, different whitespaces. auto stream = Interpret("RETURN 10.5 + 1"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 11.5); + ASSERT_EQ(stream.GetResults()[0][0].ValueDouble(), 11.5); } { // Cached ast, same literals, different named header. @@ -82,7 +82,7 @@ TEST_F(InterpreterTest, AstCache) { EXPECT_EQ(stream.GetHeader()[0], "10.5+1"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 11.5); + ASSERT_EQ(stream.GetResults()[0][0].ValueDouble(), 11.5); } } @@ -94,7 +94,7 @@ TEST_F(InterpreterTest, Parameters) { EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 25); + ASSERT_EQ(stream.GetResults()[0][0].ValueInt(), 25); } { // Not needed parameter. @@ -104,7 +104,7 @@ TEST_F(InterpreterTest, Parameters) { EXPECT_EQ(stream.GetHeader()[0], "$2 + $`a b`"); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - ASSERT_EQ(stream.GetResults()[0][0].Value(), 25); + ASSERT_EQ(stream.GetResults()[0][0].ValueInt(), 25); } { // Cached ast, different parameters. @@ -119,8 +119,7 @@ TEST_F(InterpreterTest, Parameters) { Interpret("RETURN $2", {{"2", std::vector{5, 2, 3}}}); ASSERT_EQ(stream.GetResults().size(), 1U); ASSERT_EQ(stream.GetResults()[0].size(), 1U); - auto result = - query::test_common::ToList(stream.GetResults()[0][0]); + auto result = query::test_common::ToIntList(stream.GetResults()[0][0]); ASSERT_THAT(result, testing::ElementsAre(5, 2, 3)); } { @@ -218,20 +217,20 @@ TEST_F(InterpreterTest, Bfs) { std::unordered_set matched_ids; for (const auto &result : stream.GetResults()) { - const auto &edges = query::test_common::ToList(result[0]); + const auto &edges = query::test_common::ToEdgeList(result[0]); // Check that path is of expected length. Returned paths should be from // shorter to longer ones. EXPECT_EQ(edges.size(), expected_level); // Check that starting node is correct. EXPECT_EQ( - edges[0].from().PropsAt(dba.Property(kId)).template Value(), + edges[0].from().PropsAt(dba.Property(kId)).ValueInt(), 0); for (int i = 1; i < static_cast(edges.size()); ++i) { // Check that edges form a connected path. EXPECT_EQ(edges[i - 1].to(), edges[i].from()); } auto matched_id = - edges.back().to().PropsAt(dba.Property(kId)).Value(); + edges.back().to().PropsAt(dba.Property(kId)).ValueInt(); // Check that we didn't match that node already. EXPECT_TRUE(matched_ids.insert(matched_id).second); // Check that shortest path was found. @@ -283,7 +282,7 @@ TEST_F(InterpreterTest, ShortestPath) { {"r1"}, {"r2"}, {"r1", "r2"}}; for (const auto &result : stream.GetResults()) { - const auto &edges = query::test_common::ToList(result[0]); + const auto &edges = query::test_common::ToEdgeList(result[0]); std::vector datum; for (const auto &edge : edges) { diff --git a/tests/unit/property_value_store.cpp b/tests/unit/property_value_store.cpp index 8a680b4a8..1eff609e8 100644 --- a/tests/unit/property_value_store.cpp +++ b/tests/unit/property_value_store.cpp @@ -58,10 +58,10 @@ TEST_F(PropertyValueStoreTest, AtMemory) { EXPECT_EQ(PropertyValue(At(0, Location::Memory)).type(), PropertyValue::Type::Null); Set(0, Location::Memory, some_string); - EXPECT_EQ(PropertyValue(At(0, Location::Memory)).Value(), + EXPECT_EQ(PropertyValue(At(0, Location::Memory)).ValueString(), some_string); Set(120, Location::Memory, 42); - EXPECT_EQ(PropertyValue(At(120, Location::Memory)).Value(), 42); + EXPECT_EQ(PropertyValue(At(120, Location::Memory)).ValueInt(), 42); } TEST_F(PropertyValueStoreTest, AtDisk) { @@ -70,10 +70,10 @@ TEST_F(PropertyValueStoreTest, AtDisk) { EXPECT_EQ(PropertyValue(At(0, Location::Disk)).type(), PropertyValue::Type::Null); Set(0, Location::Disk, some_string); - EXPECT_EQ(PropertyValue(At(0, Location::Disk)).Value(), + EXPECT_EQ(PropertyValue(At(0, Location::Disk)).ValueString(), some_string); Set(120, Location::Disk, 42); - EXPECT_EQ(PropertyValue(At(120, Location::Disk)).Value(), 42); + EXPECT_EQ(PropertyValue(At(120, Location::Disk)).ValueInt(), 42); } TEST_F(PropertyValueStoreTest, AtNull) { @@ -155,18 +155,18 @@ TEST_F(PropertyValueStoreTest, ClearDisk) { TEST_F(PropertyValueStoreTest, ReplaceMemory) { Set(10, Location::Memory, 42); - EXPECT_EQ(At(10, Location::Memory).Value(), 42); + EXPECT_EQ(At(10, Location::Memory).ValueInt(), 42); Set(10, Location::Memory, 0.25f); EXPECT_EQ(At(10, Location::Memory).type(), PropertyValue::Type::Double); - EXPECT_FLOAT_EQ(At(10, Location::Memory).Value(), 0.25); + EXPECT_FLOAT_EQ(At(10, Location::Memory).ValueDouble(), 0.25); } TEST_F(PropertyValueStoreTest, ReplaceDisk) { Set(10, Location::Disk, 42); - EXPECT_EQ(At(10, Location::Disk).Value(), 42); + EXPECT_EQ(At(10, Location::Disk).ValueInt(), 42); Set(10, Location::Disk, 0.25f); EXPECT_EQ(At(10, Location::Disk).type(), PropertyValue::Type::Double); - EXPECT_FLOAT_EQ(At(10, Location::Disk).Value(), 0.25); + EXPECT_FLOAT_EQ(At(10, Location::Disk).ValueDouble(), 0.25); } TEST_F(PropertyValueStoreTest, SizeMemory) { @@ -236,16 +236,16 @@ TEST_F(PropertyValueStoreTest, InsertRetrieveListMemory) { auto p = At(0, Location::Memory); EXPECT_EQ(p.type(), PropertyValue::Type::List); - auto l = p.Value>(); + auto l = p.ValueList(); EXPECT_EQ(l.size(), 5); EXPECT_EQ(l[0].type(), PropertyValue::Type::Int); - EXPECT_EQ(l[0].Value(), 1); + EXPECT_EQ(l[0].ValueInt(), 1); EXPECT_EQ(l[1].type(), PropertyValue::Type::Bool); - EXPECT_EQ(l[1].Value(), true); + EXPECT_EQ(l[1].ValueBool(), true); EXPECT_EQ(l[2].type(), PropertyValue::Type::Double); - EXPECT_EQ(l[2].Value(), 2.5); + EXPECT_EQ(l[2].ValueDouble(), 2.5); EXPECT_EQ(l[3].type(), PropertyValue::Type::String); - EXPECT_EQ(l[3].Value(), "something"); + EXPECT_EQ(l[3].ValueString(), "something"); EXPECT_EQ(l[4].type(), PropertyValue::Type::Null); } @@ -256,16 +256,16 @@ TEST_F(PropertyValueStoreTest, InsertRetrieveListDisk) { auto p = At(0, Location::Disk); EXPECT_EQ(p.type(), PropertyValue::Type::List); - auto l = p.Value>(); + auto l = p.ValueList(); EXPECT_EQ(l.size(), 5); EXPECT_EQ(l[0].type(), PropertyValue::Type::Int); - EXPECT_EQ(l[0].Value(), 1); + EXPECT_EQ(l[0].ValueInt(), 1); EXPECT_EQ(l[1].type(), PropertyValue::Type::Bool); - EXPECT_EQ(l[1].Value(), true); + EXPECT_EQ(l[1].ValueBool(), true); EXPECT_EQ(l[2].type(), PropertyValue::Type::Double); - EXPECT_EQ(l[2].Value(), 2.5); + EXPECT_EQ(l[2].ValueDouble(), 2.5); EXPECT_EQ(l[3].type(), PropertyValue::Type::String); - EXPECT_EQ(l[3].Value(), "something"); + EXPECT_EQ(l[3].ValueString(), "something"); EXPECT_EQ(l[4].type(), PropertyValue::Type::Null); } @@ -275,17 +275,17 @@ TEST_F(PropertyValueStoreTest, InsertRetrieveMap) { auto p = At(0, Location::Memory); EXPECT_EQ(p.type(), PropertyValue::Type::Map); - auto m = p.Value>(); + auto m = p.ValueMap(); EXPECT_EQ(m.size(), 3); auto get = [&m](const std::string &prop_name) { return m.find(prop_name)->second; }; EXPECT_EQ(get("a").type(), PropertyValue::Type::Int); - EXPECT_EQ(get("a").Value(), 1); + EXPECT_EQ(get("a").ValueInt(), 1); EXPECT_EQ(get("b").type(), PropertyValue::Type::Bool); - EXPECT_EQ(get("b").Value(), true); + EXPECT_EQ(get("b").ValueBool(), true); EXPECT_EQ(get("c").type(), PropertyValue::Type::String); - EXPECT_EQ(get("c").Value(), "something"); + EXPECT_EQ(get("c").ValueString(), "something"); } TEST_F(PropertyValueStoreTest, InsertRetrieveMapDisk) { @@ -294,17 +294,17 @@ TEST_F(PropertyValueStoreTest, InsertRetrieveMapDisk) { auto p = At(0, Location::Disk); EXPECT_EQ(p.type(), PropertyValue::Type::Map); - auto m = p.Value>(); + auto m = p.ValueMap(); EXPECT_EQ(m.size(), 3); auto get = [&m](const std::string &prop_name) { return m.find(prop_name)->second; }; EXPECT_EQ(get("a").type(), PropertyValue::Type::Int); - EXPECT_EQ(get("a").Value(), 1); + EXPECT_EQ(get("a").ValueInt(), 1); EXPECT_EQ(get("b").type(), PropertyValue::Type::Bool); - EXPECT_EQ(get("b").Value(), true); + EXPECT_EQ(get("b").ValueBool(), true); EXPECT_EQ(get("c").type(), PropertyValue::Type::String); - EXPECT_EQ(get("c").Value(), "something"); + EXPECT_EQ(get("c").ValueString(), "something"); } TEST_F(PropertyValueStoreTest, Iterator) { @@ -316,22 +316,22 @@ TEST_F(PropertyValueStoreTest, Iterator) { auto it = Begin(); ASSERT_TRUE(it != End()); EXPECT_EQ(it->first.Id(), 0); - EXPECT_EQ((*it).second.Value(), "a"); + EXPECT_EQ((*it).second.ValueString(), "a"); ++it; ASSERT_TRUE(it != End()); EXPECT_EQ((*it).first.Id(), 1); - EXPECT_EQ(it->second.Value(), 1); + EXPECT_EQ(it->second.ValueInt(), 1); ++it; ASSERT_TRUE(it != End()); EXPECT_EQ(it->first.Id(), 2); - EXPECT_EQ((*it).second.Value(), "b"); + EXPECT_EQ((*it).second.ValueString(), "b"); ++it; ASSERT_TRUE(it != End()); EXPECT_EQ((*it).first.Id(), 3); - EXPECT_EQ(it->second.Value(), 2); + EXPECT_EQ(it->second.ValueInt(), 2); ++it; ASSERT_TRUE(it == End()); @@ -348,30 +348,26 @@ TEST_F(PropertyValueStoreTest, CopyConstructor) { PropertyValueStore new_props = props; for (int i = 1; i <= 3; ++i) - EXPECT_EQ(new_props.at(storage::Property(i, Location::Memory)) - .Value(), - "mem_" + std::to_string(i)); - for (int i = 4; i <= 5; ++i) EXPECT_EQ( - new_props.at(storage::Property(i, Location::Disk)).Value(), - "disk_" + std::to_string(i)); + new_props.at(storage::Property(i, Location::Memory)).ValueString(), + "mem_" + std::to_string(i)); + for (int i = 4; i <= 5; ++i) + EXPECT_EQ(new_props.at(storage::Property(i, Location::Disk)).ValueString(), + "disk_" + std::to_string(i)); props.set(storage::Property(1, Location::Memory), "mem_1_update"); - EXPECT_EQ( - new_props.at(storage::Property(1, Location::Memory)).Value(), - "mem_1"); + EXPECT_EQ(new_props.at(storage::Property(1, Location::Memory)).ValueString(), + "mem_1"); new_props.set(storage::Property(2, Location::Memory), "mem_2_update"); - EXPECT_EQ( - props.at(storage::Property(2, Location::Memory)).Value(), - "mem_2"); + EXPECT_EQ(props.at(storage::Property(2, Location::Memory)).ValueString(), + "mem_2"); props.set(storage::Property(4, Location::Disk), "disk_4_update"); - EXPECT_EQ( - new_props.at(storage::Property(4, Location::Disk)).Value(), - "disk_4"); + EXPECT_EQ(new_props.at(storage::Property(4, Location::Disk)).ValueString(), + "disk_4"); new_props.set(storage::Property(5, Location::Disk), "disk_5_update"); - EXPECT_EQ(props.at(storage::Property(5, Location::Disk)).Value(), + EXPECT_EQ(props.at(storage::Property(5, Location::Disk)).ValueString(), "disk_5"); } diff --git a/tests/unit/query_common.hpp b/tests/unit/query_common.hpp index 822ce03e4..43e592810 100644 --- a/tests/unit/query_common.hpp +++ b/tests/unit/query_common.hpp @@ -39,20 +39,26 @@ namespace query { namespace test_common { -template -auto ToList(const TypedValue &t) { - std::vector list; +auto ToIntList(const TypedValue &t) { + std::vector list; for (auto x : t.ValueList()) { - list.push_back(x.Value()); + list.push_back(x.ValueInt()); } return list; }; -template -auto ToMap(const TypedValue &t) { - std::map map; +auto ToEdgeList(const TypedValue &t) { + std::vector list; + for (auto x : t.ValueList()) { + list.push_back(x.ValueEdge()); + } + return list; +}; + +auto ToIntMap(const TypedValue &t) { + std::map map; for (const auto &kv : t.ValueMap()) - map.emplace(kv.first, kv.second.Value()); + map.emplace(kv.first, kv.second.ValueInt()); return map; }; diff --git a/tests/unit/query_expression_evaluator.cpp b/tests/unit/query_expression_evaluator.cpp index b8df172b4..1c5915476 100644 --- a/tests/unit/query_expression_evaluator.cpp +++ b/tests/unit/query_expression_evaluator.cpp @@ -21,7 +21,7 @@ #include "query_common.hpp" using namespace query; -using query::test_common::ToList; +using query::test_common::ToIntList; using testing::ElementsAre; using testing::UnorderedElementsAre; @@ -1240,24 +1240,19 @@ TEST_F(FunctionTest, Range) { EXPECT_THROW(EvaluateFunction("RANGE", 1, TypedValue(), 1.3), QueryRuntimeException); EXPECT_THROW(EvaluateFunction("RANGE", 1, 2, 0), QueryRuntimeException); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 1, 3)), - ElementsAre(1, 2, 3)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", -1, 5, 2)), + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 1, 3)), ElementsAre(1, 2, 3)); + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", -1, 5, 2)), ElementsAre(-1, 1, 3, 5)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 2, 10, 3)), + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 2, 10, 3)), ElementsAre(2, 5, 8)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 2, 2, 2)), - ElementsAre(2)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 3, 0, 5)), - ElementsAre()); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 5, 1, -2)), + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 2, 2, 2)), ElementsAre(2)); + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 3, 0, 5)), ElementsAre()); + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 5, 1, -2)), ElementsAre(5, 3, 1)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 6, 1, -2)), + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 6, 1, -2)), ElementsAre(6, 4, 2)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", 2, 2, -3)), - ElementsAre(2)); - EXPECT_THAT(ToList(EvaluateFunction("RANGE", -2, 4, -1)), - ElementsAre()); + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", 2, 2, -3)), ElementsAre(2)); + EXPECT_THAT(ToIntList(EvaluateFunction("RANGE", -2, 4, -1)), ElementsAre()); } TEST_F(FunctionTest, Keys) { diff --git a/tests/unit/query_plan_accumulate_aggregate.cpp b/tests/unit/query_plan_accumulate_aggregate.cpp index e9ce6f7a9..293881bb6 100644 --- a/tests/unit/query_plan_accumulate_aggregate.cpp +++ b/tests/unit/query_plan_accumulate_aggregate.cpp @@ -15,8 +15,8 @@ using namespace query; using namespace query::plan; -using query::test_common::ToList; -using query::test_common::ToMap; +using query::test_common::ToIntList; +using query::test_common::ToIntMap; using testing::UnorderedElementsAre; TEST(QueryPlan, Accumulate) { @@ -70,7 +70,7 @@ TEST(QueryPlan, Accumulate) { std::vector results_data; for (const auto &row : results) for (const auto &column : row) - results_data.emplace_back(column.Value()); + results_data.emplace_back(column.ValueInt()); if (accumulate) EXPECT_THAT(results_data, testing::ElementsAre(2, 2, 2, 2)); else @@ -195,28 +195,28 @@ TEST_F(QueryPlanAggregateOps, WithData) { ASSERT_EQ(results[0].size(), 8); // count(*) ASSERT_EQ(results[0][0].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][0].Value(), 4); + EXPECT_EQ(results[0][0].ValueInt(), 4); // count ASSERT_EQ(results[0][1].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][1].Value(), 3); + EXPECT_EQ(results[0][1].ValueInt(), 3); // min ASSERT_EQ(results[0][2].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][2].Value(), 5); + EXPECT_EQ(results[0][2].ValueInt(), 5); // max ASSERT_EQ(results[0][3].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][3].Value(), 12); + EXPECT_EQ(results[0][3].ValueInt(), 12); // sum ASSERT_EQ(results[0][4].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][4].Value(), 24); + EXPECT_EQ(results[0][4].ValueInt(), 24); // avg ASSERT_EQ(results[0][5].type(), TypedValue::Type::Double); - EXPECT_FLOAT_EQ(results[0][5].Value(), 24 / 3.0); + EXPECT_FLOAT_EQ(results[0][5].ValueDouble(), 24 / 3.0); // collect list ASSERT_EQ(results[0][6].type(), TypedValue::Type::List); - EXPECT_THAT(ToList(results[0][6]), UnorderedElementsAre(5, 7, 12)); + EXPECT_THAT(ToIntList(results[0][6]), UnorderedElementsAre(5, 7, 12)); // collect map ASSERT_EQ(results[0][7].type(), TypedValue::Type::Map); - auto map = ToMap(results[0][7]); + auto map = ToIntMap(results[0][7]); ASSERT_EQ(map.size(), 1); EXPECT_EQ(map.begin()->first, "key"); EXPECT_FALSE(std::set({5, 7, 12}).insert(map.begin()->second).second); @@ -259,10 +259,10 @@ TEST_F(QueryPlanAggregateOps, WithoutDataWithoutGroupBy) { ASSERT_EQ(results[0].size(), 8); // count(*) ASSERT_EQ(results[0][0].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][0].Value(), 0); + EXPECT_EQ(results[0][0].ValueInt(), 0); // count ASSERT_EQ(results[0][1].type(), TypedValue::Type::Int); - EXPECT_EQ(results[0][1].Value(), 0); + EXPECT_EQ(results[0][1].ValueInt(), 0); // min EXPECT_TRUE(results[0][2].IsNull()); // max @@ -273,10 +273,10 @@ TEST_F(QueryPlanAggregateOps, WithoutDataWithoutGroupBy) { EXPECT_TRUE(results[0][5].IsNull()); // collect list ASSERT_EQ(results[0][6].type(), TypedValue::Type::List); - EXPECT_EQ(ToList(results[0][6]).size(), 0); + EXPECT_EQ(ToIntList(results[0][6]).size(), 0); // collect map ASSERT_EQ(results[0][7].type(), TypedValue::Type::Map); - EXPECT_EQ(ToMap(results[0][7]).size(), 0); + EXPECT_EQ(ToIntMap(results[0][7]).size(), 0); } TEST(QueryPlan, AggregateGroupByValues) { @@ -392,7 +392,7 @@ TEST(QueryPlan, AggregateNoInput) { EXPECT_EQ(1, results.size()); EXPECT_EQ(1, results[0].size()); EXPECT_EQ(TypedValue::Type::Int, results[0][0].type()); - EXPECT_EQ(1, results[0][0].Value()); + EXPECT_EQ(1, results[0][0].ValueInt()); } TEST(QueryPlan, AggregateCountEdgeCases) { @@ -425,7 +425,7 @@ TEST(QueryPlan, AggregateCountEdgeCases) { EXPECT_EQ(1, results.size()); EXPECT_EQ(1, results[0].size()); EXPECT_EQ(TypedValue::Type::Int, results[0][0].type()); - return results[0][0].Value(); + return results[0][0].ValueInt(); }; // no vertices yet in database diff --git a/tests/unit/query_plan_bag_semantics.cpp b/tests/unit/query_plan_bag_semantics.cpp index 4be76f010..ef7d01030 100644 --- a/tests/unit/query_plan_bag_semantics.cpp +++ b/tests/unit/query_plan_bag_semantics.cpp @@ -217,9 +217,9 @@ TEST(QueryPlan, OrderByMultiple) { ASSERT_EQ(N * N, results.size()); for (int j = 0; j < N * N; ++j) { ASSERT_EQ(results[j][0].type(), TypedValue::Type::Int); - EXPECT_EQ(results[j][0].Value(), j / N); + EXPECT_EQ(results[j][0].ValueInt(), j / N); ASSERT_EQ(results[j][1].type(), TypedValue::Type::Int); - EXPECT_EQ(results[j][1].Value(), N - 1 - j % N); + EXPECT_EQ(results[j][1].ValueInt(), N - 1 - j % N); } } diff --git a/tests/unit/query_plan_create_set_remove_delete.cpp b/tests/unit/query_plan_create_set_remove_delete.cpp index 094bf5933..08f16144d 100644 --- a/tests/unit/query_plan_create_set_remove_delete.cpp +++ b/tests/unit/query_plan_create_set_remove_delete.cpp @@ -46,7 +46,7 @@ TEST(QueryPlan, CreateNodeWithAttributes) { auto prop_eq = TypedValue(vertex.PropsAt(property.second)) == TypedValue(42); ASSERT_EQ(prop_eq.type(), TypedValue::Type::Bool); - EXPECT_TRUE(prop_eq.Value()); + EXPECT_TRUE(prop_eq.ValueBool()); } EXPECT_EQ(vertex_count, 1); } @@ -82,10 +82,10 @@ TEST(QueryPlan, CreateReturn) { EXPECT_EQ(1, results.size()); EXPECT_EQ(2, results[0].size()); EXPECT_EQ(TypedValue::Type::Vertex, results[0][0].type()); - EXPECT_EQ(1, results[0][0].Value().labels().size()); - EXPECT_EQ(label, results[0][0].Value().labels()[0]); + EXPECT_EQ(1, results[0][0].ValueVertex().labels().size()); + EXPECT_EQ(label, results[0][0].ValueVertex().labels()[0]); EXPECT_EQ(TypedValue::Type::Int, results[0][1].type()); - EXPECT_EQ(42, results[0][1].Value()); + EXPECT_EQ(42, results[0][1].ValueInt()); dba.AdvanceCommand(); EXPECT_EQ(1, CountIterable(dba.Vertices(false))); @@ -146,10 +146,10 @@ TEST(QueryPlan, CreateExpand) { storage::Label label = vertex.labels()[0]; if (label == label_node_1) { // node created by first op - EXPECT_EQ(vertex.PropsAt(property.second).Value(), 1); + EXPECT_EQ(vertex.PropsAt(property.second).ValueInt(), 1); } else if (label == label_node_2) { // node create by expansion - EXPECT_EQ(vertex.PropsAt(property.second).Value(), 2); + EXPECT_EQ(vertex.PropsAt(property.second).ValueInt(), 2); } else { // should not happen FAIL(); @@ -157,7 +157,7 @@ TEST(QueryPlan, CreateExpand) { for (EdgeAccessor edge : dba.Edges(false)) { EXPECT_EQ(edge.EdgeType(), edge_type); - EXPECT_EQ(edge.PropsAt(property.second).Value(), 3); + EXPECT_EQ(edge.PropsAt(property.second).ValueInt(), 3); } } } @@ -487,11 +487,11 @@ TEST(QueryPlan, SetProperty) { EXPECT_EQ(CountIterable(dba.Edges(false)), 2); for (EdgeAccessor edge : dba.Edges(false)) { ASSERT_EQ(edge.PropsAt(prop1).type(), PropertyValue::Type::Int); - EXPECT_EQ(edge.PropsAt(prop1).Value(), 42); + EXPECT_EQ(edge.PropsAt(prop1).ValueInt(), 42); VertexAccessor from = edge.from(); VertexAccessor to = edge.to(); ASSERT_EQ(from.PropsAt(prop1).type(), PropertyValue::Type::Int); - EXPECT_EQ(from.PropsAt(prop1).Value(), 42); + EXPECT_EQ(from.PropsAt(prop1).ValueInt(), 42); ASSERT_EQ(to.PropsAt(prop1).type(), PropertyValue::Type::Null); } } @@ -542,23 +542,23 @@ TEST(QueryPlan, SetProperties) { EXPECT_EQ(from.Properties().size(), update ? 2 : 1); if (update) { ASSERT_EQ(from.PropsAt(prop_a).type(), PropertyValue::Type::Int); - EXPECT_EQ(from.PropsAt(prop_a).Value(), 0); + EXPECT_EQ(from.PropsAt(prop_a).ValueInt(), 0); } ASSERT_EQ(from.PropsAt(prop_b).type(), PropertyValue::Type::Int); - EXPECT_EQ(from.PropsAt(prop_b).Value(), 1); + EXPECT_EQ(from.PropsAt(prop_b).ValueInt(), 1); EXPECT_EQ(edge.Properties().size(), update ? 2 : 1); if (update) { ASSERT_EQ(edge.PropsAt(prop_b).type(), PropertyValue::Type::Int); - EXPECT_EQ(edge.PropsAt(prop_b).Value(), 1); + EXPECT_EQ(edge.PropsAt(prop_b).ValueInt(), 1); } ASSERT_EQ(edge.PropsAt(prop_c).type(), PropertyValue::Type::Int); - EXPECT_EQ(edge.PropsAt(prop_c).Value(), 2); + EXPECT_EQ(edge.PropsAt(prop_c).ValueInt(), 2); VertexAccessor to = edge.to(); EXPECT_EQ(to.Properties().size(), 1); ASSERT_EQ(to.PropsAt(prop_c).type(), PropertyValue::Type::Int); - EXPECT_EQ(to.PropsAt(prop_c).Value(), 2); + EXPECT_EQ(to.PropsAt(prop_c).ValueInt(), 2); } }; @@ -719,7 +719,7 @@ TEST(QueryPlan, NodeFilterSet) { v1.Reconstruct(); auto prop_eq = TypedValue(v1.PropsAt(prop.second)) == TypedValue(42 + 2); ASSERT_EQ(prop_eq.type(), TypedValue::Type::Bool); - EXPECT_TRUE(prop_eq.Value()); + EXPECT_TRUE(prop_eq.ValueBool()); } TEST(QueryPlan, FilterRemove) { @@ -827,11 +827,11 @@ TEST(QueryPlan, Merge) { v3.Reconstruct(); ASSERT_EQ(v1.PropsAt(prop.second).type(), PropertyValue::Type::Int); - ASSERT_EQ(v1.PropsAt(prop.second).Value(), 1); + ASSERT_EQ(v1.PropsAt(prop.second).ValueInt(), 1); ASSERT_EQ(v2.PropsAt(prop.second).type(), PropertyValue::Type::Int); - ASSERT_EQ(v2.PropsAt(prop.second).Value(), 1); + ASSERT_EQ(v2.PropsAt(prop.second).ValueInt(), 1); ASSERT_EQ(v3.PropsAt(prop.second).type(), PropertyValue::Type::Int); - ASSERT_EQ(v3.PropsAt(prop.second).Value(), 2); + ASSERT_EQ(v3.PropsAt(prop.second).ValueInt(), 2); } TEST(QueryPlan, MergeNoInput) { diff --git a/tests/unit/query_plan_match_filter_return.cpp b/tests/unit/query_plan_match_filter_return.cpp index 8ce7cfeba..4338b1d9b 100644 --- a/tests/unit/query_plan_match_filter_return.cpp +++ b/tests/unit/query_plan_match_filter_return.cpp @@ -35,12 +35,11 @@ class MatchReturnFixture : public testing::Test { for (int i = 0; i < count; i++) dba_.InsertVertex(); } - template - std::vector Results(std::shared_ptr &op) { - std::vector res; + std::vector PathResults(std::shared_ptr &op) { + std::vector res; auto context = MakeContext(storage, symbol_table, &dba_); for (const auto &row : CollectProduce(*op, &context)) - res.emplace_back(row[0].Value()); + res.emplace_back(row[0].ValuePath()); return res; } }; @@ -81,7 +80,7 @@ TEST_F(MatchReturnFixture, MatchReturnPath) { NEXPR("path", IDENT("path")->MapTo(path_sym)) ->MapTo(symbol_table.CreateSymbol("named_expression_1", true)); auto produce = MakeProduce(make_path, output); - auto results = Results(produce); + auto results = PathResults(produce); ASSERT_EQ(results.size(), 2); std::vector expected_paths; for (const auto &v : dba_.Vertices(false)) expected_paths.emplace_back(v); @@ -115,10 +114,8 @@ TEST(QueryPlan, MatchReturnCartesian) { EXPECT_EQ(results.size(), 4); // ensure the result ordering is OK: // "n" from the results is the same for the first two rows, while "m" isn't - EXPECT_EQ(results[0][0].Value(), - results[1][0].Value()); - EXPECT_NE(results[0][1].Value(), - results[1][1].Value()); + EXPECT_EQ(results[0][0].ValueVertex(), results[1][0].ValueVertex()); + EXPECT_NE(results[0][1].ValueVertex(), results[1][1].ValueVertex()); } TEST(QueryPlan, StandaloneReturn) { @@ -141,7 +138,7 @@ TEST(QueryPlan, StandaloneReturn) { auto results = CollectProduce(*produce, &context); EXPECT_EQ(results.size(), 1); EXPECT_EQ(results[0].size(), 1); - EXPECT_EQ(results[0][0].Value(), 42); + EXPECT_EQ(results[0][0].ValueInt(), 42); } TEST(QueryPlan, NodeFilterLabelsAndProperties) { @@ -288,8 +285,8 @@ TEST(QueryPlan, Cartesian) { EXPECT_EQ(results.size(), 9); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { - EXPECT_EQ(results[3 * i + j][0].Value(), vertices[j]); - EXPECT_EQ(results[3 * i + j][1].Value(), vertices[i]); + EXPECT_EQ(results[3 * i + j][0].ValueVertex(), vertices[j]); + EXPECT_EQ(results[3 * i + j][1].ValueVertex(), vertices[i]); } } } @@ -368,9 +365,9 @@ TEST(QueryPlan, CartesianThreeWay) { for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < 3; ++k) { - EXPECT_EQ(results[id][0].Value(), vertices[k]); - EXPECT_EQ(results[id][1].Value(), vertices[j]); - EXPECT_EQ(results[id][2].Value(), vertices[i]); + EXPECT_EQ(results[id][0].ValueVertex(), vertices[k]); + EXPECT_EQ(results[id][1].ValueVertex(), vertices[j]); + EXPECT_EQ(results[id][2].ValueVertex(), vertices[i]); ++id; } } @@ -580,18 +577,27 @@ class QueryPlanExpandVariable : public testing::Test { /** * Pulls from the given input and returns the results under the given symbol. - * - * @return a vector of values of the given type. - * @tparam TResult type of the result that is sought. */ - template - auto GetResults(std::shared_ptr input_op, Symbol symbol) { + auto GetListResults(std::shared_ptr input_op, Symbol symbol) { Frame frame(symbol_table.max_position()); auto cursor = input_op->MakeCursor(utils::NewDeleteResource()); auto context = MakeContext(storage, symbol_table, &dba_); - std::vector results; + std::vector> results; while (cursor->Pull(frame, context)) - results.emplace_back(frame[symbol].Value()); + results.emplace_back(frame[symbol].ValueList()); + return results; + } + + /** + * Pulls from the given input and returns the results under the given symbol. + */ + auto GetPathResults(std::shared_ptr input_op, Symbol symbol) { + Frame frame(symbol_table.max_position()); + auto cursor = input_op->MakeCursor(utils::NewDeleteResource()); + auto context = MakeContext(storage, symbol_table, &dba_); + std::vector results; + while (cursor->Pull(frame, context)) + results.emplace_back(frame[symbol].ValuePath()); return results; } @@ -604,9 +610,7 @@ class QueryPlanExpandVariable : public testing::Test { auto GetEdgeListSizes(std::shared_ptr input_op, Symbol symbol) { map_int count_per_length; - for (const auto &edge_list : - GetResults>>( - input_op, symbol)) { + for (const auto &edge_list : GetListResults(input_op, symbol)) { auto length = edge_list.size(); auto found = count_per_length.find(length); if (found == count_per_length.end()) @@ -772,7 +776,7 @@ TEST_F(QueryPlanExpandVariable, NamedPath) { expected_paths.emplace_back(v, e1, e1.to(), e2, e2.to()); ASSERT_EQ(expected_paths.size(), 8); - auto results = GetResults(create_path, path_symbol); + auto results = GetPathResults(create_path, path_symbol); ASSERT_EQ(results.size(), 8); EXPECT_TRUE(std::is_permutation(results.begin(), results.end(), expected_paths.begin())); @@ -890,10 +894,10 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { auto context = MakeContext(storage, symbol_table, &dba); while (cursor->Pull(frame, context)) { results.push_back(ResultType{std::vector(), - frame[node_sym].Value(), - frame[total_weight].Value()}); + frame[node_sym].ValueVertex(), + frame[total_weight].ValueDouble()}); for (const TypedValue &edge : frame[edge_list_sym].ValueList()) - results.back().path.emplace_back(edge.Value()); + results.back().path.emplace_back(edge.ValueEdge()); } return results; @@ -901,12 +905,12 @@ class QueryPlanExpandWeightedShortestPath : public testing::Test { template auto GetProp(const TAccessor &accessor) { - return accessor.PropsAt(prop.second).template Value(); + return accessor.PropsAt(prop.second).ValueInt(); } template auto GetDoubleProp(const TAccessor &accessor) { - return accessor.PropsAt(prop.second).template Value(); + return accessor.PropsAt(prop.second).ValueDouble(); } Expression *PropNe(Symbol symbol, int value) { @@ -1167,10 +1171,10 @@ TEST(QueryPlan, ExpandOptional) { int v1_is_n_count = 0; for (auto &row : results) { ASSERT_EQ(row[0].type(), TypedValue::Type::Vertex); - VertexAccessor &va = row[0].Value(); + VertexAccessor &va = row[0].ValueVertex(); auto va_p = va.PropsAt(prop); ASSERT_EQ(va_p.type(), PropertyValue::Type::Int); - if (va_p.Value() == 1) { + if (va_p.ValueInt() == 1) { v1_is_n_count++; EXPECT_EQ(row[1].type(), TypedValue::Type::Edge); EXPECT_EQ(row[2].type(), TypedValue::Type::Vertex); @@ -1535,8 +1539,7 @@ TEST(QueryPlan, Distinct) { for (const auto &row : results) { ASSERT_EQ(1, row.size()); ASSERT_EQ(row[0].type(), output_it->type()); - if (assume_int_value) - EXPECT_EQ(output_it->Value(), row[0].Value()); + if (assume_int_value) EXPECT_EQ(output_it->ValueInt(), row[0].ValueInt()); output_it++; } }; @@ -1581,7 +1584,7 @@ TEST(QueryPlan, ScanAllByLabel) { ASSERT_EQ(results.size(), 1); auto result_row = results[0]; ASSERT_EQ(result_row.size(), 1); - EXPECT_EQ(result_row[0].Value(), labeled_vertex); + EXPECT_EQ(result_row[0].ValueVertex(), labeled_vertex); } TEST(QueryPlan, ScanAllByLabelProperty) { @@ -1626,10 +1629,9 @@ TEST(QueryPlan, ScanAllByLabelProperty) { ASSERT_EQ(results.size(), expected.size()); for (size_t i = 0; i < expected.size(); i++) { TypedValue equal = - TypedValue(results[i][0].Value().PropsAt(prop)) == - expected[i]; + TypedValue(results[i][0].ValueVertex().PropsAt(prop)) == expected[i]; ASSERT_EQ(equal.type(), TypedValue::Type::Bool); - EXPECT_TRUE(equal.Value()); + EXPECT_TRUE(equal.ValueBool()); } }; @@ -1696,7 +1698,7 @@ TEST(QueryPlan, ScanAllByLabelPropertyEqualityNoError) { ASSERT_EQ(results.size(), 1); const auto &row = results[0]; ASSERT_EQ(row.size(), 1); - auto vertex = row[0].Value(); + auto vertex = row[0].ValueVertex(); TypedValue value(vertex.PropsAt(prop)); TypedValue::BoolEqual eq; EXPECT_TRUE(eq(value, TypedValue(42))); diff --git a/tests/unit/query_pretty_print.cpp b/tests/unit/query_pretty_print.cpp index a07b2c39f..8a8a3b7c9 100644 --- a/tests/unit/query_pretty_print.cpp +++ b/tests/unit/query_pretty_print.cpp @@ -10,7 +10,6 @@ #include "utils/string.hpp" using namespace query; -using query::test_common::ToList; using query::test_common::ToString; using testing::ElementsAre; using testing::UnorderedElementsAre; diff --git a/tests/unit/record_edge_vertex_accessor.cpp b/tests/unit/record_edge_vertex_accessor.cpp index 86fde4735..ec40a363f 100644 --- a/tests/unit/record_edge_vertex_accessor.cpp +++ b/tests/unit/record_edge_vertex_accessor.cpp @@ -23,8 +23,8 @@ TEST(RecordAccessor, Properties) { EXPECT_EQ(vertex.PropsAt(property).type(), PropertyValue::Type::Null); vertex.PropsSet(property, 42); - EXPECT_EQ(vertex.PropsAt(property).Value(), 42); - EXPECT_EQ(properties.at(property).Value(), 42); + EXPECT_EQ(vertex.PropsAt(property).ValueInt(), 42); + EXPECT_EQ(properties.at(property).ValueInt(), 42); EXPECT_EQ(vertex.PropsAt(property_other).type(), PropertyValue::Type::Null); EXPECT_EQ(properties.at(property_other).type(), PropertyValue::Type::Null); diff --git a/tests/unit/state_delta.cpp b/tests/unit/state_delta.cpp index 747839af5..c4fcad87e 100644 --- a/tests/unit/state_delta.cpp +++ b/tests/unit/state_delta.cpp @@ -173,7 +173,7 @@ TEST(StateDelta, SetPropertyVertex) { auto vertex = dba.FindVertexOptional(gid0, false); EXPECT_TRUE(vertex); auto prop = vertex->PropsAt(dba.Property("property")); - EXPECT_EQ(prop.Value(), 2212); + EXPECT_EQ(prop.ValueInt(), 2212); } } @@ -203,6 +203,6 @@ TEST(StateDelta, SetPropertyEdge) { auto edge = dba.FindEdgeOptional(gid2, false); EXPECT_TRUE(edge); auto prop = edge->PropsAt(dba.Property("property")); - EXPECT_EQ(prop.Value(), 2212); + EXPECT_EQ(prop.ValueInt(), 2212); } } diff --git a/tests/unit/stripped.cpp b/tests/unit/stripped.cpp index 9f1ac53c9..7c6be5e4f 100644 --- a/tests/unit/stripped.cpp +++ b/tests/unit/stripped.cpp @@ -3,10 +3,10 @@ // Created by Florijan Stamenkovic on 07.03.17. // -#include "query/frontend/stripped.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "query/exceptions.hpp" +#include "query/frontend/stripped.hpp" #include "query/typed_value.hpp" using namespace query; @@ -18,7 +18,7 @@ using testing::Pair; using testing::UnorderedElementsAre; void EXPECT_PROP_TRUE(const TypedValue &a) { - EXPECT_TRUE(a.type() == TypedValue::Type::Bool && a.Value()); + EXPECT_TRUE(a.type() == TypedValue::Type::Bool && a.ValueBool()); } void EXPECT_PROP_EQ(const TypedValue &a, const TypedValue &b) { @@ -39,8 +39,8 @@ TEST(QueryStripper, ZeroInteger) { StrippedQuery stripped("RETURN 0"); EXPECT_EQ(stripped.literals().size(), 1); EXPECT_EQ(stripped.literals().At(0).first, 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), 0); - EXPECT_EQ(stripped.literals().AtTokenPosition(1).Value(), 0); + EXPECT_EQ(stripped.literals().At(0).second.ValueInt(), 0); + EXPECT_EQ(stripped.literals().AtTokenPosition(1).ValueInt(), 0); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedIntToken); } @@ -48,57 +48,57 @@ TEST(QueryStripper, DecimalInteger) { StrippedQuery stripped("RETURN 42"); EXPECT_EQ(stripped.literals().size(), 1); EXPECT_EQ(stripped.literals().At(0).first, 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), 42); - EXPECT_EQ(stripped.literals().AtTokenPosition(1).Value(), 42); + EXPECT_EQ(stripped.literals().At(0).second.ValueInt(), 42); + EXPECT_EQ(stripped.literals().AtTokenPosition(1).ValueInt(), 42); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedIntToken); } TEST(QueryStripper, OctalInteger) { StrippedQuery stripped("RETURN 010"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), 8); + EXPECT_EQ(stripped.literals().At(0).second.ValueInt(), 8); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedIntToken); } TEST(QueryStripper, HexInteger) { StrippedQuery stripped("RETURN 0xa"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), 10); + EXPECT_EQ(stripped.literals().At(0).second.ValueInt(), 10); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedIntToken); } TEST(QueryStripper, RegularDecimal) { StrippedQuery stripped("RETURN 42.3"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_FLOAT_EQ(stripped.literals().At(0).second.Value(), 42.3); + EXPECT_FLOAT_EQ(stripped.literals().At(0).second.ValueDouble(), 42.3); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedDoubleToken); } TEST(QueryStripper, ExponentDecimal) { StrippedQuery stripped("RETURN 4e2"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_FLOAT_EQ(stripped.literals().At(0).second.Value(), 4e2); + EXPECT_FLOAT_EQ(stripped.literals().At(0).second.ValueDouble(), 4e2); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedDoubleToken); } TEST(QueryStripper, ExponentDecimal2) { StrippedQuery stripped("RETURN 4e-2"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_FLOAT_EQ(stripped.literals().At(0).second.Value(), 4e-2); + EXPECT_FLOAT_EQ(stripped.literals().At(0).second.ValueDouble(), 4e-2); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedDoubleToken); } TEST(QueryStripper, ExponentDecimal3) { StrippedQuery stripped("RETURN 0.1e-2"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_FLOAT_EQ(stripped.literals().At(0).second.Value(), 0.1e-2); + EXPECT_FLOAT_EQ(stripped.literals().At(0).second.ValueDouble(), 0.1e-2); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedDoubleToken); } TEST(QueryStripper, ExponentDecimal4) { StrippedQuery stripped("RETURN .1e-2"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_FLOAT_EQ(stripped.literals().At(0).second.Value(), .1e-2); + EXPECT_FLOAT_EQ(stripped.literals().At(0).second.ValueDouble(), .1e-2); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedDoubleToken); } @@ -111,28 +111,28 @@ TEST(QueryStripper, SymbolicNameStartingWithE) { TEST(QueryStripper, StringLiteral) { StrippedQuery stripped("RETURN 'something'"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), "something"); + EXPECT_EQ(stripped.literals().At(0).second.ValueString(), "something"); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedStringToken); } TEST(QueryStripper, StringLiteral2) { StrippedQuery stripped("RETURN 'so\\'me'"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), "so'me"); + EXPECT_EQ(stripped.literals().At(0).second.ValueString(), "so'me"); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedStringToken); } TEST(QueryStripper, StringLiteral3) { StrippedQuery stripped("RETURN \"so\\\"me'\""); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), "so\"me'"); + EXPECT_EQ(stripped.literals().At(0).second.ValueString(), "so\"me'"); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedStringToken); } TEST(QueryStripper, StringLiteral4) { StrippedQuery stripped("RETURN '\\u1Aa4'"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), u8"\u1Aa4"); + EXPECT_EQ(stripped.literals().At(0).second.ValueString(), u8"\u1Aa4"); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedStringToken); } @@ -147,8 +147,7 @@ TEST(QueryStripper, LowSurrogateAlone) { TEST(QueryStripper, Surrogates) { StrippedQuery stripped("RETURN '\\ud83d\\udeeb'"); EXPECT_EQ(stripped.literals().size(), 1); - EXPECT_EQ(stripped.literals().At(0).second.Value(), - u8"\U0001f6eb"); + EXPECT_EQ(stripped.literals().At(0).second.ValueString(), u8"\U0001f6eb"); EXPECT_EQ(stripped.query(), "RETURN " + kStrippedStringToken); } @@ -192,8 +191,8 @@ TEST(QueryStripper, MapLiteral) { TEST(QueryStripper, RangeLiteral) { StrippedQuery stripped("MATCH (n)-[*2..3]-() RETURN n"); EXPECT_EQ(stripped.literals().size(), 2); - EXPECT_EQ(stripped.literals().At(0).second.Value(), 2); - EXPECT_EQ(stripped.literals().At(1).second.Value(), 3); + EXPECT_EQ(stripped.literals().At(0).second.ValueInt(), 2); + EXPECT_EQ(stripped.literals().At(1).second.ValueInt(), 3); EXPECT_EQ(stripped.query(), "MATCH ( n ) - [ * " + kStrippedIntToken + " .. " + kStrippedIntToken + " ] - ( ) RETURN n"); diff --git a/tests/unit/typed_value.cpp b/tests/unit/typed_value.cpp index d9e588bd8..a05c9ac7f 100644 --- a/tests/unit/typed_value.cpp +++ b/tests/unit/typed_value.cpp @@ -44,11 +44,11 @@ class AllTypesFixture : public testing::Test { }; void EXPECT_PROP_FALSE(const TypedValue &a) { - EXPECT_TRUE(a.type() == TypedValue::Type::Bool && !a.Value()); + EXPECT_TRUE(a.type() == TypedValue::Type::Bool && !a.ValueBool()); } void EXPECT_PROP_TRUE(const TypedValue &a) { - EXPECT_TRUE(a.type() == TypedValue::Type::Bool && a.Value()); + EXPECT_TRUE(a.type() == TypedValue::Type::Bool && a.ValueBool()); } void EXPECT_PROP_EQ(const TypedValue &a, const TypedValue &b) { @@ -79,15 +79,15 @@ TEST(TypedValue, CreationTypes) { } TEST(TypedValue, CreationValues) { - EXPECT_EQ(TypedValue(true).Value(), true); - EXPECT_EQ(TypedValue(false).Value(), false); + EXPECT_EQ(TypedValue(true).ValueBool(), true); + EXPECT_EQ(TypedValue(false).ValueBool(), false); EXPECT_EQ(TypedValue(std::string("bla")).ValueString(), "bla"); EXPECT_EQ(TypedValue("bla2").ValueString(), "bla2"); - EXPECT_EQ(TypedValue(55).Value(), 55); + EXPECT_EQ(TypedValue(55).ValueInt(), 55); - EXPECT_FLOAT_EQ(TypedValue(66.6).Value(), 66.6); + EXPECT_FLOAT_EQ(TypedValue(66.6).ValueDouble(), 66.6); } TEST(TypedValue, Equals) { @@ -238,8 +238,8 @@ TEST(TypedValue, LogicalNot) { TEST(TypedValue, UnaryMinus) { EXPECT_TRUE((-TypedValue()).type() == TypedValue::Type::Null); - EXPECT_PROP_EQ(TypedValue(-TypedValue(2).Value()), TypedValue(-2)); - EXPECT_FLOAT_EQ((-TypedValue(2.0).Value()), -2.0); + EXPECT_PROP_EQ(TypedValue(-TypedValue(2).ValueInt()), TypedValue(-2)); + EXPECT_FLOAT_EQ((-TypedValue(2.0).ValueDouble()), -2.0); EXPECT_THROW(-TypedValue(true), TypedValueException); EXPECT_THROW(-TypedValue("something"), TypedValueException); @@ -248,8 +248,8 @@ TEST(TypedValue, UnaryMinus) { TEST(TypedValue, UnaryPlus) { EXPECT_TRUE((+TypedValue()).type() == TypedValue::Type::Null); - EXPECT_PROP_EQ(TypedValue(+TypedValue(2).Value()), TypedValue(2)); - EXPECT_FLOAT_EQ((+TypedValue(2.0).Value()), 2.0); + EXPECT_PROP_EQ(TypedValue(+TypedValue(2).ValueInt()), TypedValue(2)); + EXPECT_FLOAT_EQ((+TypedValue(2.0).ValueDouble()), 2.0); EXPECT_THROW(+TypedValue(true), TypedValueException); EXPECT_THROW(+TypedValue("something"), TypedValueException); @@ -311,8 +311,8 @@ TEST_F(TypedValueArithmeticTest, Sum) { true, [](const TypedValue &a, const TypedValue &b) { return a + b; }); // sum of props of the same type - EXPECT_EQ((TypedValue(2) + TypedValue(3)).Value(), 5); - EXPECT_FLOAT_EQ((TypedValue(2.5) + TypedValue(1.25)).Value(), 3.75); + EXPECT_EQ((TypedValue(2) + TypedValue(3)).ValueInt(), 5); + EXPECT_FLOAT_EQ((TypedValue(2.5) + TypedValue(1.25)).ValueDouble(), 3.75); EXPECT_EQ((TypedValue("one") + TypedValue("two")).ValueString(), "onetwo"); // sum of string and numbers @@ -339,12 +339,12 @@ TEST_F(TypedValueArithmeticTest, Difference) { false, [](const TypedValue &a, const TypedValue &b) { return a - b; }); // difference of props of the same type - EXPECT_EQ((TypedValue(2) - TypedValue(3)).Value(), -1); - EXPECT_FLOAT_EQ((TypedValue(2.5) - TypedValue(2.25)).Value(), 0.25); + EXPECT_EQ((TypedValue(2) - TypedValue(3)).ValueInt(), -1); + EXPECT_FLOAT_EQ((TypedValue(2.5) - TypedValue(2.25)).ValueDouble(), 0.25); // implicit casting - EXPECT_FLOAT_EQ((TypedValue(2) - TypedValue(0.5)).Value(), 1.5); - EXPECT_FLOAT_EQ((TypedValue(2.5) - TypedValue(2)).Value(), 0.5); + EXPECT_FLOAT_EQ((TypedValue(2) - TypedValue(0.5)).ValueDouble(), 1.5); + EXPECT_FLOAT_EQ((TypedValue(2.5) - TypedValue(2)).ValueDouble(), 0.5); } TEST_F(TypedValueArithmeticTest, Divison) { @@ -356,10 +356,10 @@ TEST_F(TypedValueArithmeticTest, Divison) { EXPECT_PROP_EQ(TypedValue(10) / TypedValue(4), TypedValue(2)); EXPECT_PROP_EQ(TypedValue(10.0) / TypedValue(2.0), TypedValue(5.0)); - EXPECT_FLOAT_EQ((TypedValue(10.0) / TypedValue(4.0)).Value(), 2.5); + EXPECT_FLOAT_EQ((TypedValue(10.0) / TypedValue(4.0)).ValueDouble(), 2.5); - EXPECT_FLOAT_EQ((TypedValue(10) / TypedValue(4.0)).Value(), 2.5); - EXPECT_FLOAT_EQ((TypedValue(10.0) / TypedValue(4)).Value(), 2.5); + EXPECT_FLOAT_EQ((TypedValue(10) / TypedValue(4.0)).ValueDouble(), 2.5); + EXPECT_FLOAT_EQ((TypedValue(10.0) / TypedValue(4)).ValueDouble(), 2.5); } TEST_F(TypedValueArithmeticTest, Multiplication) { @@ -367,10 +367,10 @@ TEST_F(TypedValueArithmeticTest, Multiplication) { false, [](const TypedValue &a, const TypedValue &b) { return a * b; }); EXPECT_PROP_EQ(TypedValue(10) * TypedValue(2), TypedValue(20)); - EXPECT_FLOAT_EQ((TypedValue(12.5) * TypedValue(6.6)).Value(), + EXPECT_FLOAT_EQ((TypedValue(12.5) * TypedValue(6.6)).ValueDouble(), 12.5 * 6.6); - EXPECT_FLOAT_EQ((TypedValue(10) * TypedValue(4.5)).Value(), 10 * 4.5); - EXPECT_FLOAT_EQ((TypedValue(10.2) * TypedValue(4)).Value(), 10.2 * 4); + EXPECT_FLOAT_EQ((TypedValue(10) * TypedValue(4.5)).ValueDouble(), 10 * 4.5); + EXPECT_FLOAT_EQ((TypedValue(10.2) * TypedValue(4)).ValueDouble(), 10.2 * 4); } TEST_F(TypedValueArithmeticTest, Modulo) { @@ -382,10 +382,10 @@ TEST_F(TypedValueArithmeticTest, Modulo) { EXPECT_PROP_EQ(TypedValue(10) % TypedValue(4), TypedValue(2)); EXPECT_PROP_EQ(TypedValue(10.0) % TypedValue(2.0), TypedValue(0.0)); - EXPECT_FLOAT_EQ((TypedValue(10.0) % TypedValue(3.25)).Value(), 0.25); + EXPECT_FLOAT_EQ((TypedValue(10.0) % TypedValue(3.25)).ValueDouble(), 0.25); - EXPECT_FLOAT_EQ((TypedValue(10) % TypedValue(4.0)).Value(), 2.0); - EXPECT_FLOAT_EQ((TypedValue(10.0) % TypedValue(4)).Value(), 2.0); + EXPECT_FLOAT_EQ((TypedValue(10) % TypedValue(4.0)).ValueDouble(), 2.0); + EXPECT_FLOAT_EQ((TypedValue(10.0) % TypedValue(4)).ValueDouble(), 2.0); } class TypedValueLogicTest : public AllTypesFixture {