Remove inheritance from storage types

Reviewers: teon.banek, msantl

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1757
This commit is contained in:
Matej Ferencevic 2018-12-05 12:45:16 +01:00
parent 7638b09867
commit e70ac03607
18 changed files with 271 additions and 139 deletions

View File

@ -26,7 +26,7 @@ cpp<#
(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address")
(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:define-rpc create-bfs-subcursor
(:request
@ -40,9 +40,9 @@ cpp<#
"query::EdgeAtom::Direction"
'(in out both)))
(edge-types "std::vector<storage::EdgeType>"
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Common"
:capnp-save (lcp:capnp-save-vector "::storage::capnp::EdgeType"
"storage::EdgeType")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Common"
:capnp-load (lcp:capnp-load-vector "::storage::capnp::EdgeType"
"storage::EdgeType"))
(filter-lambda "query::plan::ExpansionLambda"
:capnp-type "DistOps.ExpansionLambda"

View File

@ -19,15 +19,15 @@ cpp<#
(lcp:define-rpc populate-index
(:request
((label "storage::Label" :capnp-type "Storage.Common")
(property "storage::Property" :capnp-type "Storage.Common")
((label "storage::Label" :capnp-type "Storage.Label")
(property "storage::Property" :capnp-type "Storage.Property")
(tx-id "tx::TransactionId" :capnp-type "UInt64")))
(:response ()))
(lcp:define-rpc create-index
(:request
((label "storage::Label" :capnp-type "Storage.Common")
(property "storage::Property" :capnp-type "Storage.Common")))
((label "storage::Label" :capnp-type "Storage.Label")
(property "storage::Property" :capnp-type "Storage.Property")))
(:response ()))
(lcp:pop-namespace) ;; distributed

View File

@ -24,9 +24,9 @@ cpp<#
(lcp:capnp-type-conversion "tx::TransactionId" "UInt64")
(lcp:capnp-type-conversion "gid::Gid" "UInt64")
(lcp:capnp-type-conversion "storage::Label" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::Property" "Storage.Common")
(lcp:capnp-type-conversion "storage::Label" "Storage.Label")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:capnp-type-conversion "storage::Property" "Storage.Property")
(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address")
(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address")
@ -56,15 +56,15 @@ cpp<#
(lcp:define-struct create-vertex-req-data ()
((tx-id "tx::TransactionId")
(labels "std::vector<storage::Label>"
:capnp-save (lcp:capnp-save-vector "storage::capnp::Common" "storage::Label")
:capnp-load (lcp:capnp-load-vector "storage::capnp::Common" "storage::Label"))
:capnp-save (lcp:capnp-save-vector "storage::capnp::Label" "storage::Label")
:capnp-load (lcp:capnp-load-vector "storage::capnp::Label" "storage::Label"))
(properties "std::unordered_map<storage::Property, PropertyValue>"
:capnp-type "Utils.Map(Storage.Common, Storage.PropertyValue)"
:capnp-type "Utils.Map(Storage.Property, Storage.PropertyValue)"
:capnp-save
(lambda (builder member capnp-name)
(declare (ignore capnp-name))
#>cpp
utils::SaveMap<storage::capnp::Common, storage::capnp::PropertyValue>(
utils::SaveMap<storage::capnp::Property, storage::capnp::PropertyValue>(
${member}, &${builder},
[](auto *builder, const auto &entry) {
auto key_builder = builder->initKey();
@ -77,7 +77,7 @@ cpp<#
(lambda (reader member capnp-name)
(declare (ignore capnp-name))
#>cpp
utils::LoadMap<storage::capnp::Common, storage::capnp::PropertyValue>(
utils::LoadMap<storage::capnp::Property, storage::capnp::PropertyValue>(
&${member}, ${reader},
[](const auto &reader) {
storage::Property prop;

View File

@ -24,9 +24,9 @@ cpp<#
(lcp:capnp-type-conversion "tx::TransactionId" "UInt64")
(lcp:capnp-type-conversion "gid::Gid" "UInt64")
(lcp:capnp-type-conversion "storage::Label" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::Property" "Storage.Common")
(lcp:capnp-type-conversion "storage::Label" "Storage.Label")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:capnp-type-conversion "storage::Property" "Storage.Property")
(lcp:capnp-type-conversion "storage::EdgeAddress" "Storage.Address")
(lcp:capnp-type-conversion "storage::VertexAddress" "Storage.Address")

View File

@ -27,9 +27,9 @@ cpp<#
(lcp:capnp-type-conversion "tx::TransactionId" "UInt64")
(lcp:capnp-type-conversion "gid::Gid" "UInt64")
(lcp:capnp-type-conversion "storage::Label" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::Property" "Storage.Common")
(lcp:capnp-type-conversion "storage::Label" "Storage.Label")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:capnp-type-conversion "storage::Property" "Storage.Property")
(lcp:define-struct state-delta ()
(

View File

@ -42,9 +42,9 @@ cpp<#
(lcp:capnp-import 'utils "/utils/serialization.capnp")
(lcp:capnp-type-conversion "PropertyValue" "Storage.PropertyValue")
(lcp:capnp-type-conversion "storage::Label" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::Property" "Storage.Common")
(lcp:capnp-type-conversion "storage::Label" "Storage.Label")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:capnp-type-conversion "storage::Property" "Storage.Property")
(lcp:capnp-type-conversion "Symbol" "Symbol.Symbol")
(defun save-ast-pointer (builder member capnp-name)
@ -631,7 +631,7 @@ cpp<#
(lcp:define-class map-literal (base-literal)
((elements "std::unordered_map<std::pair<std::string, storage::Property>, Expression *>"
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Common), Tree)"
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Property), Tree)"
:capnp-save #'save-property-map
:capnp-load #'load-property-map
:scope :public))
@ -750,10 +750,10 @@ cpp<#
:capnp-load (load-ast-pointer "Expression *"))
(labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")
:capnp-load (lcp:capnp-load-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")))
(:public
#>cpp
@ -1207,13 +1207,13 @@ cpp<#
(lcp:define-class node-atom (pattern-atom)
((labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")
:capnp-load (lcp:capnp-load-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label"))
(properties "std::unordered_map<std::pair<std::string, storage::Property>, Expression *>"
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Common), Tree)"
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Property), Tree)"
:capnp-save #'save-property-map
:capnp-load #'load-property-map
:scope :public))
@ -1255,14 +1255,14 @@ cpp<#
(direction "Direction" :initval "Direction::BOTH" :scope :public)
(edge-types "std::vector<storage::EdgeType>" :scope :public
:capnp-save (lcp:capnp-save-vector
"storage::capnp::Common"
"storage::capnp::EdgeType"
"storage::EdgeType")
:capnp-load (lcp:capnp-load-vector
"storage::capnp::Common"
"storage::capnp::EdgeType"
"storage::EdgeType"))
(properties "std::unordered_map<std::pair<std::string, storage::Property>, Expression *>"
:scope :public
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Common), Tree)"
:capnp-type "Utils.Map(Utils.Pair(Text, Storage.Property), Tree)"
:capnp-save #'save-property-map
:capnp-load #'load-property-map)
(lower-bound "Expression *" :initval "nullptr" :scope :public
@ -1633,8 +1633,8 @@ cpp<#
((action "Action" :scope :public)
(label "storage::Label" :scope :public)
(properties "std::vector<storage::Property>" :scope :public
:capnp-save (lcp:capnp-save-vector "storage::capnp::Common" "storage::Property")
:capnp-load (lcp:capnp-load-vector "storage::capnp::Common" "storage::Property")))
:capnp-save (lcp:capnp-save-vector "storage::capnp::Property" "storage::Property")
:capnp-load (lcp:capnp-load-vector "storage::capnp::Property" "storage::Property")))
(:public
(lcp:define-enum action
(create create-unique drop)
@ -2047,10 +2047,10 @@ cpp<#
:capnp-load (load-ast-pointer "Identifier *"))
(labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")
:capnp-load (lcp:capnp-load-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")))
(:public
#>cpp
@ -2119,10 +2119,10 @@ cpp<#
:capnp-load (load-ast-pointer "Identifier *"))
(labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")
:capnp-load (lcp:capnp-load-vector
"storage::capnp::Common"
"storage::capnp::Label"
"storage::Label")))
(:public
#>cpp

View File

@ -130,9 +130,9 @@ cpp<#
(lcp:capnp-import 'query "/query/serialization.capnp")
(lcp:capnp-type-conversion "Symbol" "Semantic.Symbol")
(lcp:capnp-type-conversion "storage::Label" "Storage.Common")
(lcp:capnp-type-conversion "storage::Property" "Storage.Common")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.Common")
(lcp:capnp-type-conversion "storage::Label" "Storage.Label")
(lcp:capnp-type-conversion "storage::Property" "Storage.Property")
(lcp:capnp-type-conversion "storage::EdgeType" "Storage.EdgeType")
(lcp:capnp-type-conversion "GraphView" "Query.GraphView")
(lcp:define-class logical-operator ("::utils::Visitable<HierarchicalLogicalOperatorVisitor>")
@ -671,9 +671,9 @@ expansion. The direction is relative to the starting vertex for each expansion."
:documentation "storage::EdgeType specifying which edges we want
to expand. If empty, all edges are valid. If not empty, only edges with one of
the given types are valid."
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Common"
:capnp-save (lcp:capnp-save-vector "::storage::capnp::EdgeType"
"storage::EdgeType")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Common"
:capnp-load (lcp:capnp-load-vector "::storage::capnp::EdgeType"
"storage::EdgeType"))
(existing-node :bool :documentation "If the given node atom refer to a symbol
that has already been expanded and should be just validated in the frame.")
@ -1224,8 +1224,8 @@ that the old props are discarded and replaced with new ones.")
:capnp-load #'load-operator-pointer)
(input-symbol "Symbol" :scope :public)
(labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Common" "storage::Label")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Common" "storage::Label")))
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Label" "storage::Label")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Label" "storage::Label")))
(:documentation
"Logical operator for setting an arbitrary number of labels on a Vertex.
@ -1312,8 +1312,8 @@ It does NOT remove labels that are already set on that Vertex.")
:capnp-load #'load-operator-pointer)
(input-symbol "Symbol" :scope :public)
(labels "std::vector<storage::Label>" :scope :public
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Common" "storage::Label")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Common" "storage::Label")))
:capnp-save (lcp:capnp-save-vector "::storage::capnp::Label" "storage::Label")
:capnp-load (lcp:capnp-load-vector "::storage::capnp::Label" "storage::Label")))
(:documentation
"Logical operator for removing an arbitrary number of labels on a Vertex.

View File

@ -6,26 +6,25 @@
#include <glog/logging.h>
#include "utils/total_ordering.hpp"
namespace storage {
using IdT = uint16_t;
const IdT IdMask = std::numeric_limits<IdT>::max() >> 1;
const IdT IdNotMask = ~IdMask;
// In case of a new location Mask value has to be updated.
enum class Location : uint16_t { Memory = 0x8000, Disk = 0x0000 };
//
// |-------------|--------------|
// |---location--|------id------|
// |-Memory|Disk-|-----2^15-----|
enum class Location : IdT { Memory = 0x8000, Disk = 0x0000 };
/**
* |-------------|--------------|
* |---location--|------id------|
* |-Memory|Disk-|-----2^15-----|
*/
template <typename TSpecificType>
class Common : public utils::TotalOrdering<TSpecificType> {
class Label final {
public:
using IdT = uint16_t;
Common() = default;
explicit Common(const IdT id, const Location location = Location::Memory)
: id_((id & Mask) | static_cast<uint16_t>(location)) {
Label() = default;
explicit Label(const IdT id, const Location location = Location::Memory)
: id_((id & IdMask) | static_cast<IdT>(location)) {
// TODO(ipaljak): A better way would be to throw an exception
// and send a message to the user that a new Id can't be created.
// By doing that, database instance will continue to work and user
@ -33,58 +32,141 @@ class Common : public utils::TotalOrdering<TSpecificType> {
// CHECK isn't user friendly at all because it will immediately
// terminate the whole process.
// TODO implement throw and error handling
CHECK(id <= Mask) << "Number of used ids overflowed!";
CHECK(id <= IdMask) << "Number of used ids overflowed!";
}
friend bool operator==(const TSpecificType &a, const TSpecificType &b) {
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
Location Location() const {
return static_cast<enum Location>(id_ & IdNotMask);
}
friend bool operator==(const Label &a, const Label &b) {
return a.Id() == b.Id();
}
friend bool operator<(const TSpecificType &a, const TSpecificType &b) {
friend bool operator!=(const Label &a, const Label &b) {
return a.Id() != b.Id();
}
friend bool operator<(const Label &a, const Label &b) {
return a.Id() < b.Id();
}
IdT Id() const { return static_cast<IdT>(id_ & Mask); }
Location Location() const {
return static_cast<enum Location>(id_ & NotMask);
friend bool operator>(const Label &a, const Label &b) {
return a.Id() > b.Id();
}
friend bool operator<=(const Label &a, const Label &b) {
return a.Id() <= b.Id();
}
friend bool operator>=(const Label &a, const Label &b) {
return a.Id() >= b.Id();
}
struct Hash {
std::hash<IdT> hash{};
size_t operator()(const TSpecificType &t) const { return hash(t.id_); }
};
IdT id_{0};
};
class EdgeType final {
public:
EdgeType() = default;
explicit EdgeType(const IdT id, const Location location = Location::Memory)
: id_((id & IdMask) | static_cast<IdT>(location)) {
// TODO(ipaljak): A better way would be to throw an exception
// and send a message to the user that a new Id can't be created.
// By doing that, database instance will continue to work and user
// has a chance to make an appropriate action.
// CHECK isn't user friendly at all because it will immediately
// terminate the whole process.
// TODO implement throw and error handling
CHECK(id <= IdMask) << "Number of used ids overflowed!";
}
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
Location Location() const {
return static_cast<enum Location>(id_ & IdNotMask);
}
friend bool operator==(const EdgeType &a, const EdgeType &b) {
return a.Id() == b.Id();
}
friend bool operator!=(const EdgeType &a, const EdgeType &b) {
return a.Id() != b.Id();
}
friend bool operator<(const EdgeType &a, const EdgeType &b) {
return a.Id() < b.Id();
}
friend bool operator>(const EdgeType &a, const EdgeType &b) {
return a.Id() > b.Id();
}
friend bool operator<=(const EdgeType &a, const EdgeType &b) {
return a.Id() <= b.Id();
}
friend bool operator>=(const EdgeType &a, const EdgeType &b) {
return a.Id() >= b.Id();
}
IdT id_{0};
protected:
~Common() {}
private:
static constexpr IdT Mask = std::numeric_limits<IdT>::max() >> 1;
static constexpr IdT NotMask = ~Mask;
};
class Label final : public Common<Label> {
using Common::Common;
};
class Property final {
public:
Property() = default;
explicit Property(const IdT id, const Location location = Location::Memory)
: id_((id & IdMask) | static_cast<IdT>(location)) {
// TODO(ipaljak): A better way would be to throw an exception
// and send a message to the user that a new Id can't be created.
// By doing that, database instance will continue to work and user
// has a chance to make an appropriate action.
// CHECK isn't user friendly at all because it will immediately
// terminate the whole process.
// TODO implement throw and error handling
CHECK(id <= IdMask) << "Number of used ids overflowed!";
}
class EdgeType final : public Common<EdgeType> {
using Common::Common;
};
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
Location Location() const {
return static_cast<enum Location>(id_ & IdNotMask);
}
class Property final : public Common<Property> {
using Common::Common;
friend bool operator==(const Property &a, const Property &b) {
return a.Id() == b.Id();
}
friend bool operator!=(const Property &a, const Property &b) {
return a.Id() != b.Id();
}
friend bool operator<(const Property &a, const Property &b) {
return a.Id() < b.Id();
}
friend bool operator>(const Property &a, const Property &b) {
return a.Id() > b.Id();
}
friend bool operator<=(const Property &a, const Property &b) {
return a.Id() <= b.Id();
}
friend bool operator>=(const Property &a, const Property &b) {
return a.Id() >= b.Id();
}
IdT id_{0};
};
} // namespace storage
namespace std {
template <>
struct hash<storage::Label> {
size_t operator()(const storage::Label &k) const {
return hash<storage::IdT>()(k.Id());
}
};
template <>
struct hash<storage::Label> : public storage::Common<storage::Label>::Hash {};
template <>
struct hash<storage::EdgeType>
: public storage::Common<storage::EdgeType>::Hash {};
template <>
struct hash<storage::Property>
: public storage::Common<storage::Property>::Hash {};
struct hash<storage::EdgeType> {
size_t operator()(const storage::EdgeType &k) const {
return hash<storage::IdT>()(k.Id());
}
};
template <>
struct hash<storage::Property> {
size_t operator()(const storage::Property &k) const {
return hash<storage::IdT>()(k.Id());
}
};
} // namespace std

View File

@ -12,7 +12,7 @@ namespace storage {
/** SingleNode implementation of ConcurrentIdMapper. */
template <typename TId>
class SingleNodeConcurrentIdMapper : public ConcurrentIdMapper<TId> {
using StorageT = typename TId::IdT;
using StorageT = IdT;
public:
SingleNodeConcurrentIdMapper() = default;

View File

@ -20,26 +20,26 @@ cpp<#
(lcp:define-rpc label-id
(:request ((member "std::string")))
(:response ((member "Label" :capnp-type "S.Common"))))
(:response ((member "Label" :capnp-type "S.Label"))))
(lcp:define-rpc id-label
(:request ((member "Label" :capnp-type "S.Common")))
(:request ((member "Label" :capnp-type "S.Label")))
(:response ((member "std::string"))))
(lcp:define-rpc edge-type-id
(:request ((member "std::string")))
(:response ((member "EdgeType" :capnp-type "S.Common"))))
(:response ((member "EdgeType" :capnp-type "S.EdgeType"))))
(lcp:define-rpc id-edge-type
(:request ((member "EdgeType" :capnp-type "S.Common")))
(:request ((member "EdgeType" :capnp-type "S.EdgeType")))
(:response ((member "std::string"))))
(lcp:define-rpc property-id
(:request ((member "std::string")))
(:response ((member "Property" :capnp-type "S.Common"))))
(:response ((member "Property" :capnp-type "S.Property"))))
(lcp:define-rpc id-property
(:request ((member "Property" :capnp-type "S.Common")))
(:request ((member "Property" :capnp-type "S.Property")))
(:response ((member "std::string"))))
(lcp:pop-namespace)

View File

@ -3,18 +3,17 @@
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("storage::capnp");
struct Common {
struct Label {
storage @0 :UInt16;
union {
label @1 :Label;
edgeType @2 :EdgeType;
property @3 :Property;
}
}
struct Label {}
struct EdgeType {}
struct Property {}
struct EdgeType {
storage @0 :UInt16;
}
struct Property {
storage @0 :UInt16;
}
struct Address {
storage @0 :UInt64;
@ -41,7 +40,7 @@ struct PropertyValueStore {
properties @0 :List(Entry);
struct Entry {
id @0 :Common;
id @0 :Property;
value @1 :PropertyValue;
}
}

View File

@ -5,6 +5,30 @@
namespace storage {
void Save(const Label &label, capnp::Label::Builder *builder) {
builder->setStorage(label.id_);
}
void Load(Label *label, const capnp::Label::Reader &reader) {
label->id_ = reader.getStorage();
}
void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder) {
builder->setStorage(edge_type.id_);
}
void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader) {
edge_type->id_ = reader.getStorage();
}
void Save(const Property &property, capnp::Property::Builder *builder) {
builder->setStorage(property.id_);
}
void Load(Property *property, const capnp::Property::Reader &reader) {
property->id_ = reader.getStorage();
}
void SaveCapnpPropertyValue(const PropertyValue &value,
capnp::PropertyValue::Builder *builder) {
switch (value.type()) {

View File

@ -28,15 +28,17 @@ void Load(Address<TLocalObj> *address, const capnp::Address::Reader &reader) {
address->storage_ = reader.getStorage();
}
template <class Type>
void Save(const Common<Type> &common, capnp::Common::Builder *builder) {
builder->setStorage(common.id_);
}
void Save(const Label &label, capnp::Label::Builder *builder);
template <class Type>
void Load(Common<Type> *common, const capnp::Common::Reader &reader) {
common->id_ = reader.getStorage();
}
void Load(Label *label, const capnp::Label::Reader &reader);
void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder);
void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader);
void Save(const Property &property, capnp::Property::Builder *builder);
void Load(Property *property, const capnp::Property::Reader &reader);
void SaveCapnpPropertyValue(const PropertyValue &value,
capnp::PropertyValue::Builder *builder);

View File

@ -11,7 +11,7 @@ namespace storage {
/** SingleNode implementation of ConcurrentIdMapper. */
template <typename TId>
class ConcurrentIdMapper {
using StorageT = typename TId::IdT;
using StorageT = IdT;
public:
ConcurrentIdMapper() = default;

View File

@ -11,7 +11,7 @@ namespace storage {
/** SingleNode implementation of ConcurrentIdMapper. */
template <typename TId>
class ConcurrentIdMapper {
using StorageT = typename TId::IdT;
using StorageT = IdT;
public:
ConcurrentIdMapper() = default;

View File

@ -3,18 +3,17 @@
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("storage::capnp");
struct Common {
struct Label {
storage @0 :UInt16;
union {
label @1 :Label;
edgeType @2 :EdgeType;
property @3 :Property;
}
}
struct Label {}
struct EdgeType {}
struct Property {}
struct EdgeType {
storage @0 :UInt16;
}
struct Property {
storage @0 :UInt16;
}
struct PropertyValue {
union {

View File

@ -2,6 +2,30 @@
namespace storage {
void Save(const Label &label, capnp::Label::Builder *builder) {
builder->setStorage(label.id_);
}
void Load(Label *label, const capnp::Label::Reader &reader) {
label->id_ = reader.getStorage();
}
void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder) {
builder->setStorage(edge_type.id_);
}
void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader) {
edge_type->id_ = reader.getStorage();
}
void Save(const Property &property, capnp::Property::Builder *builder) {
builder->setStorage(property.id_);
}
void Load(Property *property, const capnp::Property::Reader &reader) {
property->id_ = reader.getStorage();
}
void SaveCapnpPropertyValue(const PropertyValue &value,
capnp::PropertyValue::Builder *builder) {
switch (value.type()) {

View File

@ -6,15 +6,17 @@
namespace storage {
template <class Type>
void Save(const Common<Type> &common, capnp::Common::Builder *builder) {
builder->setStorage(common.id_);
}
void Save(const Label &label, capnp::Label::Builder *builder);
template <class Type>
void Load(Common<Type> *common, const capnp::Common::Reader &reader) {
common->id_ = reader.getStorage();
}
void Load(Label *label, const capnp::Label::Reader &reader);
void Save(const EdgeType &edge_type, capnp::EdgeType::Builder *builder);
void Load(EdgeType *edge_type, const capnp::EdgeType::Reader &reader);
void Save(const Property &property, capnp::Property::Builder *builder);
void Load(Property *property, const capnp::Property::Reader &reader);
void SaveCapnpPropertyValue(const PropertyValue &value,
capnp::PropertyValue::Builder *builder);