Replace unordered_map with map in storage v2
Summary: `std::unordered_map` is 56 bytes in size, `std::map` is 48 bytes in size. Also, `std::map` doesn't require the key type to be hashable. Reviewers: mtomic, teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2218
This commit is contained in:
parent
111dd8bf19
commit
10136f43dc
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "utils/spin_lock.hpp"
|
||||
|
||||
@ -20,7 +20,7 @@ struct Edge {
|
||||
|
||||
Gid gid;
|
||||
|
||||
std::unordered_map<uint64_t, storage::PropertyValue> properties;
|
||||
std::map<uint64_t, storage::PropertyValue> properties;
|
||||
|
||||
utils::SpinLock lock;
|
||||
bool deleted;
|
||||
|
@ -90,9 +90,8 @@ Result<PropertyValue> EdgeAccessor::GetProperty(uint64_t property, View view) {
|
||||
return Result<PropertyValue>{std::move(value)};
|
||||
}
|
||||
|
||||
Result<std::unordered_map<uint64_t, PropertyValue>> EdgeAccessor::Properties(
|
||||
View view) {
|
||||
std::unordered_map<uint64_t, PropertyValue> properties;
|
||||
Result<std::map<uint64_t, PropertyValue>> EdgeAccessor::Properties(View view) {
|
||||
std::map<uint64_t, PropertyValue> properties;
|
||||
bool deleted = false;
|
||||
Delta *delta = nullptr;
|
||||
{
|
||||
@ -137,11 +136,9 @@ Result<std::unordered_map<uint64_t, PropertyValue>> EdgeAccessor::Properties(
|
||||
}
|
||||
});
|
||||
if (deleted) {
|
||||
return Result<std::unordered_map<uint64_t, PropertyValue>>{
|
||||
Error::DELETED_OBJECT};
|
||||
return Result<std::map<uint64_t, PropertyValue>>{Error::DELETED_OBJECT};
|
||||
}
|
||||
return Result<std::unordered_map<uint64_t, PropertyValue>>{
|
||||
std::move(properties)};
|
||||
return Result<std::map<uint64_t, PropertyValue>>{std::move(properties)};
|
||||
}
|
||||
|
||||
} // namespace storage
|
||||
|
@ -37,7 +37,7 @@ class EdgeAccessor final {
|
||||
|
||||
Result<PropertyValue> GetProperty(uint64_t property, View view);
|
||||
|
||||
Result<std::unordered_map<uint64_t, PropertyValue>> Properties(View view);
|
||||
Result<std::map<uint64_t, PropertyValue>> Properties(View view);
|
||||
|
||||
Gid Gid() const { return edge_->gid; }
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "utils/spin_lock.hpp"
|
||||
@ -22,7 +22,7 @@ struct Vertex {
|
||||
Gid gid;
|
||||
|
||||
std::vector<uint64_t> labels;
|
||||
std::unordered_map<uint64_t, storage::PropertyValue> properties;
|
||||
std::map<uint64_t, storage::PropertyValue> properties;
|
||||
|
||||
std::vector<std::tuple<uint64_t, Vertex *, Edge *>> in_edges;
|
||||
std::vector<std::tuple<uint64_t, Vertex *, Edge *>> out_edges;
|
||||
|
@ -250,9 +250,9 @@ Result<PropertyValue> VertexAccessor::GetProperty(uint64_t property,
|
||||
return Result<PropertyValue>{std::move(value)};
|
||||
}
|
||||
|
||||
Result<std::unordered_map<uint64_t, PropertyValue>> VertexAccessor::Properties(
|
||||
Result<std::map<uint64_t, PropertyValue>> VertexAccessor::Properties(
|
||||
View view) {
|
||||
std::unordered_map<uint64_t, PropertyValue> properties;
|
||||
std::map<uint64_t, PropertyValue> properties;
|
||||
bool deleted = false;
|
||||
Delta *delta = nullptr;
|
||||
{
|
||||
@ -297,11 +297,9 @@ Result<std::unordered_map<uint64_t, PropertyValue>> VertexAccessor::Properties(
|
||||
}
|
||||
});
|
||||
if (deleted) {
|
||||
return Result<std::unordered_map<uint64_t, PropertyValue>>{
|
||||
Error::DELETED_OBJECT};
|
||||
return Result<std::map<uint64_t, PropertyValue>>{Error::DELETED_OBJECT};
|
||||
}
|
||||
return Result<std::unordered_map<uint64_t, PropertyValue>>{
|
||||
std::move(properties)};
|
||||
return Result<std::map<uint64_t, PropertyValue>>{std::move(properties)};
|
||||
}
|
||||
|
||||
Result<std::vector<EdgeAccessor>>
|
||||
|
@ -37,7 +37,7 @@ class VertexAccessor final {
|
||||
|
||||
Result<PropertyValue> GetProperty(uint64_t property, View view);
|
||||
|
||||
Result<std::unordered_map<uint64_t, PropertyValue>> Properties(View view);
|
||||
Result<std::map<uint64_t, PropertyValue>> Properties(View view);
|
||||
|
||||
Result<std::vector<EdgeAccessor>>
|
||||
InEdges(const std::vector<uint64_t> &edge_types, View view);
|
||||
|
Loading…
Reference in New Issue
Block a user