Expose Id mappings from accessor-less Storage
Reviewers: mtomic, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2285
This commit is contained in:
parent
ed9f82bcf4
commit
134525851b
@ -65,7 +65,7 @@ class NameIdMapper final {
|
||||
// Currently, we never delete anything from the `utils::SkipList` so the
|
||||
// references will always be valid. If you change this class to remove unused
|
||||
// names, be sure to change the signature of this function.
|
||||
const std::string &IdToName(uint64_t id) {
|
||||
const std::string &IdToName(uint64_t id) const {
|
||||
auto id_to_name_acc = id_to_name_.access();
|
||||
auto result = id_to_name_acc.find(id);
|
||||
CHECK(result != id_to_name_acc.end())
|
||||
|
@ -556,24 +556,30 @@ Result<bool> Storage::Accessor::DeleteEdge(EdgeAccessor *edge) {
|
||||
return Result<bool>{true};
|
||||
}
|
||||
|
||||
const std::string &Storage::Accessor::LabelToName(LabelId label) {
|
||||
return storage_->name_id_mapper_.IdToName(label.AsUint());
|
||||
const std::string &Storage::Accessor::LabelToName(LabelId label) const {
|
||||
return storage_->LabelToName(label);
|
||||
}
|
||||
const std::string &Storage::Accessor::PropertyToName(PropertyId property) {
|
||||
return storage_->name_id_mapper_.IdToName(property.AsUint());
|
||||
|
||||
const std::string &Storage::Accessor::PropertyToName(
|
||||
PropertyId property) const {
|
||||
return storage_->PropertyToName(property);
|
||||
}
|
||||
const std::string &Storage::Accessor::EdgeTypeToName(EdgeTypeId edge_type) {
|
||||
return storage_->name_id_mapper_.IdToName(edge_type.AsUint());
|
||||
|
||||
const std::string &Storage::Accessor::EdgeTypeToName(
|
||||
EdgeTypeId edge_type) const {
|
||||
return storage_->EdgeTypeToName(edge_type);
|
||||
}
|
||||
|
||||
LabelId Storage::Accessor::NameToLabel(const std::string &name) {
|
||||
return LabelId::FromUint(storage_->name_id_mapper_.NameToId(name));
|
||||
return storage_->NameToLabel(name);
|
||||
}
|
||||
|
||||
PropertyId Storage::Accessor::NameToProperty(const std::string &name) {
|
||||
return PropertyId::FromUint(storage_->name_id_mapper_.NameToId(name));
|
||||
return storage_->NameToProperty(name);
|
||||
}
|
||||
|
||||
EdgeTypeId Storage::Accessor::NameToEdgeType(const std::string &name) {
|
||||
return EdgeTypeId::FromUint(storage_->name_id_mapper_.NameToId(name));
|
||||
return storage_->NameToEdgeType(name);
|
||||
}
|
||||
|
||||
void Storage::Accessor::AdvanceCommand() { ++transaction_.command_id; }
|
||||
@ -832,6 +838,30 @@ Storage::Accessor Storage::Access() {
|
||||
return Accessor{this, transaction_id, start_timestamp};
|
||||
}
|
||||
|
||||
const std::string &Storage::LabelToName(LabelId label) const {
|
||||
return name_id_mapper_.IdToName(label.AsUint());
|
||||
}
|
||||
|
||||
const std::string &Storage::PropertyToName(PropertyId property) const {
|
||||
return name_id_mapper_.IdToName(property.AsUint());
|
||||
}
|
||||
|
||||
const std::string &Storage::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return name_id_mapper_.IdToName(edge_type.AsUint());
|
||||
}
|
||||
|
||||
LabelId Storage::NameToLabel(const std::string &name) {
|
||||
return LabelId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
PropertyId Storage::NameToProperty(const std::string &name) {
|
||||
return PropertyId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
EdgeTypeId Storage::NameToEdgeType(const std::string &name) {
|
||||
return EdgeTypeId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
VerticesIterable Storage::Accessor::Vertices(LabelId label, View view) {
|
||||
return VerticesIterable(
|
||||
storage_->indices_.label_index.Vertices(label, view, &transaction_));
|
||||
|
@ -205,9 +205,9 @@ class Storage final {
|
||||
|
||||
Result<bool> DeleteEdge(EdgeAccessor *edge);
|
||||
|
||||
const std::string &LabelToName(LabelId label);
|
||||
const std::string &PropertyToName(PropertyId property);
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type);
|
||||
const std::string &LabelToName(LabelId label) const;
|
||||
const std::string &PropertyToName(PropertyId property) const;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const;
|
||||
|
||||
LabelId NameToLabel(const std::string &name);
|
||||
PropertyId NameToProperty(const std::string &name);
|
||||
@ -230,6 +230,14 @@ class Storage final {
|
||||
|
||||
Accessor Access();
|
||||
|
||||
const std::string &LabelToName(LabelId label) const;
|
||||
const std::string &PropertyToName(PropertyId property) const;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const;
|
||||
|
||||
LabelId NameToLabel(const std::string &name);
|
||||
PropertyId NameToProperty(const std::string &name);
|
||||
EdgeTypeId NameToEdgeType(const std::string &name);
|
||||
|
||||
bool CreateIndex(LabelId label, PropertyId property) {
|
||||
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
|
||||
return indices_.label_property_index.CreateIndex(label, property,
|
||||
|
Loading…
Reference in New Issue
Block a user