From 13c33149e59a72e4f5d709c597fa3721aecb090b Mon Sep 17 00:00:00 2001 From: antoniofilipovic Date: Wed, 8 Feb 2023 15:38:48 +0100 Subject: [PATCH] add std::vector instead of std::map --- src/query/db_accessor.hpp | 4 ++-- src/query/interpret/eval.hpp | 10 ---------- src/query/plan/operator.cpp | 14 ++------------ src/storage/v2/property_store.cpp | 2 +- src/storage/v2/property_store.hpp | 2 +- src/storage/v2/vertex_accessor.cpp | 4 ++-- src/storage/v2/vertex_accessor.hpp | 4 ++-- 7 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/query/db_accessor.hpp b/src/query/db_accessor.hpp index 8e3f1c6c9..38f2170e1 100644 --- a/src/query/db_accessor.hpp +++ b/src/query/db_accessor.hpp @@ -126,8 +126,8 @@ class VertexAccessor final { } storage::Result> SetProperties( - std::map &properties) { - return impl_.SetBatchProperties(properties); + std::vector> &properties) { + return impl_.SetProperties(properties); } storage::Result RemoveProperty(storage::PropertyId key) { diff --git a/src/query/interpret/eval.hpp b/src/query/interpret/eval.hpp index a0e4bab42..1a55f820b 100644 --- a/src/query/interpret/eval.hpp +++ b/src/query/interpret/eval.hpp @@ -231,8 +231,6 @@ class ExpressionEvaluator : public ExpressionVisitor { } TypedValue Visit(SubscriptOperator &list_indexing) override { - // auto start = std::chrono::steady_clock::now(); - ReferenceExpressionEvaluator referenceExpressionEvaluator(frame_, symbol_table_, ctx_, dba_, view_); auto *lhs = list_indexing.expression1_->Accept(referenceExpressionEvaluator); @@ -255,14 +253,6 @@ class ExpressionEvaluator : public ExpressionVisitor { if (index_int >= static_cast(list.size()) || index_int < 0) return TypedValue(ctx_->memory); // NOTE: Explicit move is needed, so that we return the move constructed // value and preserve the correct MemoryResource. - // auto end = std::chrono::steady_clock::now(); - // std::chrono::duration dif = end - start; - // total2 += dif; - - // if (total2 > new_print2) { - // std::cout << "Time difference visit = " << total2.count() << "[s]" << std::endl; - // new_print2 += static_cast>(1.0); - // } return TypedValue(list[index_int]); } diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index 3015206c2..0470d0afc 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -212,12 +212,10 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram // TODO: PropsSetChecked allocates a PropertyValue, make it use context.memory // when we update PropertyValue with custom allocator. - // auto start = std::chrono::steady_clock::now(); - - std::map properties; + std::vector> properties; if (const auto *node_info_properties = std::get_if(&node_info.properties)) { for (const auto &[key, value_expression] : *node_info_properties) { - properties.emplace(key, value_expression->Accept(evaluator)); + properties.emplace_back(key, value_expression->Accept(evaluator)); // PropsSetChecked(&new_node, key, ); } new_node.SetProperties(properties); @@ -228,14 +226,6 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram PropsSetChecked(&new_node, property_id, value); } } - // auto end = std::chrono::steady_clock::now(); - // std::chrono::duration dif = end - start; - // total += dif; - - // if (total > new_print) { - // std::cout << "Time difference props set checked = " << total.count() << "[s]" << std::endl; - // new_print += static_cast>(10.0); - // } (*frame)[node_info.symbol] = new_node; return (*frame)[node_info.symbol].ValueVertex(); diff --git a/src/storage/v2/property_store.cpp b/src/storage/v2/property_store.cpp index 549da207f..7ac237ff2 100644 --- a/src/storage/v2/property_store.cpp +++ b/src/storage/v2/property_store.cpp @@ -1167,7 +1167,7 @@ bool PropertyStore::SetProperty(PropertyId property, const PropertyValue &value) } // use this function only when inserting new properties -bool PropertyStore::SetProperties(std::map &properties) { +bool PropertyStore::SetProperties(std::vector> &properties) { uint64_t size; uint8_t *data; std::tie(size, data) = GetSizeData(buffer_); diff --git a/src/storage/v2/property_store.hpp b/src/storage/v2/property_store.hpp index 1b7423c8b..ffd8a30f7 100644 --- a/src/storage/v2/property_store.hpp +++ b/src/storage/v2/property_store.hpp @@ -61,7 +61,7 @@ class PropertyStore { /// @throw std::bad_alloc bool SetProperty(PropertyId property, const PropertyValue &value); - bool SetProperties(std::map &properties); + bool SetProperties(std::vector> &properties); /// Remove all properties and return `true` if any removal took place. /// `false` is returned if there were no properties to remove. The time diff --git a/src/storage/v2/vertex_accessor.cpp b/src/storage/v2/vertex_accessor.cpp index 12361f155..5132086d8 100644 --- a/src/storage/v2/vertex_accessor.cpp +++ b/src/storage/v2/vertex_accessor.cpp @@ -245,8 +245,8 @@ Result VertexAccessor::SetProperty(PropertyId property, const Pro return std::move(current_value); } -Result> VertexAccessor::SetBatchProperties( - std::map &properties) { +Result> VertexAccessor::SetProperties( + std::vector> &properties) { // Be careful when calling this function // It will set properties in batch, without checking if property already exists diff --git a/src/storage/v2/vertex_accessor.hpp b/src/storage/v2/vertex_accessor.hpp index 54a61bd72..099d7830a 100644 --- a/src/storage/v2/vertex_accessor.hpp +++ b/src/storage/v2/vertex_accessor.hpp @@ -68,8 +68,8 @@ class VertexAccessor final { /// @throw std::bad_alloc Result SetProperty(PropertyId property, const PropertyValue &value); - Result> SetBatchProperties( - std::map &properties); + Result> SetProperties( + std::vector> &properties); /// Remove all properties and return the values of the removed properties. /// @throw std::bad_alloc