memgraph/include/storage/model/properties/properties.hpp
Kruno Tomola Fabro 5a42e15c4a Alpha version of label indexes.
Squashed messages from 9 commits:

9.
Properties now uses PropertyFamily and contained classes.
Fetching,seting,clearing properties can be done with PropertyFamilyKey or PropertyTypeKey.
Hierarchy of newly added clases is:
Vertices -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags}
Edges -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags}

PropertyFamilyKey -> PropertyType
PropertyTypeKey -> PropertyType

PropertyType t0,t1;
let t0!=t1 be true
let t0.family==t1.family be true

then next is true
PropertyTypeKey{&t0}!=PropertyTypeKey{&t1}
PropertyFamilyKey{&t0}==PropertyFamilyKey{&t1}
PropertyFamilyKey{&t0}==PropertyTypeKey{&t1}
PropertyTypeKey{&t0}==PropertyFamilyKey{&t1}

8.
Intermedate commit.
Noticed that integration queries throw SEGFAULT.

7.
Defined interface for indexes.
Fixed three memory leaks.
Fixed integration_queries test which now passes.

6.
Commit which return Xorshift128plus to valid shape.

5.
Tmp commit.

4.
Label Index is compiling.

3.
tmp

2.
Vertex::Accessor now updates Label index.

1.
Applied changes for code review.
2016-08-18 15:34:36 +01:00

52 lines
1.2 KiB
C++

#pragma once
#include <map>
#include "storage/model/properties/property.hpp"
#include "storage/model/properties/property_family.hpp"
#include "utils/option.hpp"
using prop_key_t = PropertyFamily::PropertyType::PropertyFamilyKey;
template <class T>
using type_key_t = PropertyFamily::PropertyType::PropertyTypeKey<T>;
class Properties
{
public:
using sptr = std::shared_ptr<Properties>;
auto begin() const { return props.begin(); }
auto cbegin() const { return props.cbegin(); }
auto end() const { return props.end(); }
auto cend() const { return props.cend(); }
size_t size() const { return props.size(); }
const Property &at(prop_key_t &key) const;
template <class T>
auto at(type_key_t<T> &key) const;
template <class T, class... Args>
void set(type_key_t<T> &key, Args &&... args);
void set(prop_key_t &key, Property::sptr value);
void clear(prop_key_t &key);
template <class Handler>
void accept(Handler &handler) const
{
for (auto &kv : props)
handler.handle(kv.first, *kv.second);
handler.finish();
}
private:
using props_t = std::map<prop_key_t, Property::sptr>;
props_t props;
};