NameIDMapper refactored
This commit is contained in:
@@ -876,32 +876,6 @@ Result<std::optional<EdgeAccessor>> DiskStorage::DiskAccessor::DeleteEdge(EdgeAc
|
||||
&disk_storage->indices_, &disk_storage->constraints_, config_, true);
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::DiskAccessor::LabelToName(LabelId label) const { return storage_->LabelToName(label); }
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::DiskAccessor::PropertyToName(PropertyId property) const {
|
||||
return storage_->PropertyToName(property);
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::DiskAccessor::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return storage_->EdgeTypeToName(edge_type);
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
LabelId DiskStorage::DiskAccessor::NameToLabel(const std::string_view name) { return storage_->NameToLabel(name); }
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
PropertyId DiskStorage::DiskAccessor::NameToProperty(const std::string_view name) {
|
||||
return storage_->NameToProperty(name);
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
EdgeTypeId DiskStorage::DiskAccessor::NameToEdgeType(const std::string_view name) {
|
||||
return storage_->NameToEdgeType(name);
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
void DiskStorage::DiskAccessor::AdvanceCommand() { ++transaction_.command_id; }
|
||||
|
||||
@@ -1269,34 +1243,6 @@ std::optional<uint64_t> DiskStorage::DiskAccessor::GetTransactionId() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::LabelToName(LabelId label) const { return name_id_mapper_.IdToName(label.AsUint()); }
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::PropertyToName(PropertyId property) const {
|
||||
return name_id_mapper_.IdToName(property.AsUint());
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &DiskStorage::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return name_id_mapper_.IdToName(edge_type.AsUint());
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
LabelId DiskStorage::NameToLabel(const std::string_view name) {
|
||||
return LabelId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
PropertyId DiskStorage::NameToProperty(const std::string_view name) {
|
||||
return PropertyId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
EdgeTypeId DiskStorage::NameToEdgeType(const std::string_view name) {
|
||||
return EdgeTypeId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
utils::BasicResult<StorageIndexDefinitionError, void> DiskStorage::CreateIndex(
|
||||
LabelId label, const std::optional<uint64_t> desired_commit_timestamp) {
|
||||
/// TODO: (andi): Here we will probably use some lock to protect reading from and writing to the RocksDB at the
|
||||
|
||||
@@ -168,19 +168,6 @@ class DiskStorage final : public Storage {
|
||||
|
||||
Result<std::optional<EdgeAccessor>> DeleteEdge(EdgeAccessor *edge) override;
|
||||
|
||||
const std::string &LabelToName(LabelId label) const override;
|
||||
const std::string &PropertyToName(PropertyId property) const override;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
LabelId NameToLabel(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
PropertyId NameToProperty(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
EdgeTypeId NameToEdgeType(std::string_view name) override;
|
||||
|
||||
bool LabelIndexExists(LabelId label) const override { throw utils::NotYetImplemented("LabelIndexExists()"); }
|
||||
|
||||
bool LabelPropertyIndexExists(LabelId label, PropertyId property) const override {
|
||||
@@ -254,19 +241,6 @@ class DiskStorage final : public Storage {
|
||||
new DiskAccessor{this, override_isolation_level.value_or(isolation_level_), storage_mode_});
|
||||
}
|
||||
|
||||
const std::string &LabelToName(LabelId label) const override;
|
||||
const std::string &PropertyToName(PropertyId property) const override;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
LabelId NameToLabel(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
PropertyId NameToProperty(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
EdgeTypeId NameToEdgeType(std::string_view name) override;
|
||||
|
||||
/// Create an index.
|
||||
/// Returns void if the index has been created.
|
||||
/// Returns `StorageIndexDefinitionError` if an error occures. Error can be:
|
||||
|
||||
@@ -603,30 +603,6 @@ Result<std::optional<EdgeAccessor>> InMemoryStorage::InMemoryAccessor::DeleteEdg
|
||||
&mem_storage->indices_, &mem_storage->constraints_, config_, true);
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::InMemoryAccessor::LabelToName(LabelId label) const {
|
||||
return storage_->LabelToName(label);
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::InMemoryAccessor::PropertyToName(PropertyId property) const {
|
||||
return storage_->PropertyToName(property);
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::InMemoryAccessor::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return storage_->EdgeTypeToName(edge_type);
|
||||
}
|
||||
|
||||
LabelId InMemoryStorage::InMemoryAccessor::NameToLabel(const std::string_view name) {
|
||||
return storage_->NameToLabel(name);
|
||||
}
|
||||
|
||||
PropertyId InMemoryStorage::InMemoryAccessor::NameToProperty(const std::string_view name) {
|
||||
return storage_->NameToProperty(name);
|
||||
}
|
||||
|
||||
EdgeTypeId InMemoryStorage::InMemoryAccessor::NameToEdgeType(const std::string_view name) {
|
||||
return storage_->NameToEdgeType(name);
|
||||
}
|
||||
|
||||
void InMemoryStorage::InMemoryAccessor::AdvanceCommand() { ++transaction_.command_id; }
|
||||
|
||||
utils::BasicResult<StorageDataManipulationError, void> InMemoryStorage::InMemoryAccessor::Commit(
|
||||
@@ -940,30 +916,6 @@ std::optional<uint64_t> InMemoryStorage::InMemoryAccessor::GetTransactionId() co
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::LabelToName(LabelId label) const {
|
||||
return name_id_mapper_.IdToName(label.AsUint());
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::PropertyToName(PropertyId property) const {
|
||||
return name_id_mapper_.IdToName(property.AsUint());
|
||||
}
|
||||
|
||||
const std::string &InMemoryStorage::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return name_id_mapper_.IdToName(edge_type.AsUint());
|
||||
}
|
||||
|
||||
LabelId InMemoryStorage::NameToLabel(const std::string_view name) {
|
||||
return LabelId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
PropertyId InMemoryStorage::NameToProperty(const std::string_view name) {
|
||||
return PropertyId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
EdgeTypeId InMemoryStorage::NameToEdgeType(const std::string_view name) {
|
||||
return EdgeTypeId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
utils::BasicResult<StorageIndexDefinitionError, void> InMemoryStorage::CreateIndex(
|
||||
LabelId label, const std::optional<uint64_t> desired_commit_timestamp) {
|
||||
std::unique_lock<utils::RWLock> storage_guard(main_lock_);
|
||||
|
||||
@@ -189,19 +189,6 @@ class InMemoryStorage final : public Storage {
|
||||
/// @throw std::bad_alloc
|
||||
Result<std::optional<EdgeAccessor>> DeleteEdge(EdgeAccessor *edge) override;
|
||||
|
||||
const std::string &LabelToName(LabelId label) const override;
|
||||
const std::string &PropertyToName(PropertyId property) const override;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
LabelId NameToLabel(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
PropertyId NameToProperty(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
EdgeTypeId NameToEdgeType(std::string_view name) override;
|
||||
|
||||
bool LabelIndexExists(LabelId label) const override {
|
||||
return static_cast<InMemoryStorage *>(storage_)->indices_.label_index.IndexExists(label);
|
||||
}
|
||||
@@ -255,19 +242,6 @@ class InMemoryStorage final : public Storage {
|
||||
new InMemoryAccessor{this, override_isolation_level.value_or(isolation_level_), storage_mode_});
|
||||
}
|
||||
|
||||
const std::string &LabelToName(LabelId label) const override;
|
||||
const std::string &PropertyToName(PropertyId property) const override;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
LabelId NameToLabel(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
PropertyId NameToProperty(std::string_view name) override;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
EdgeTypeId NameToEdgeType(std::string_view name) override;
|
||||
|
||||
/// Create an index.
|
||||
/// Returns void if the index has been created.
|
||||
/// Returns `StorageIndexDefinitionError` if an error occures. Error can be:
|
||||
|
||||
@@ -279,4 +279,46 @@ Storage::Accessor::Accessor(Accessor &&other) noexcept
|
||||
other.commit_timestamp_.reset();
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &Storage::LabelToName(LabelId label) const { return name_id_mapper_.IdToName(label.AsUint()); }
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &Storage::PropertyToName(PropertyId property) const {
|
||||
return name_id_mapper_.IdToName(property.AsUint());
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
const std::string &Storage::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return name_id_mapper_.IdToName(edge_type.AsUint());
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
LabelId Storage::NameToLabel(const std::string_view name) { return LabelId::FromUint(name_id_mapper_.NameToId(name)); }
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
PropertyId Storage::NameToProperty(const std::string_view name) {
|
||||
return PropertyId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
// this should be handled on an above level of abstraction
|
||||
EdgeTypeId Storage::NameToEdgeType(const std::string_view name) {
|
||||
return EdgeTypeId::FromUint(name_id_mapper_.NameToId(name));
|
||||
}
|
||||
|
||||
const std::string &Storage::Accessor::LabelToName(LabelId label) const { return storage_->LabelToName(label); }
|
||||
|
||||
const std::string &Storage::Accessor::PropertyToName(PropertyId property) const {
|
||||
return storage_->PropertyToName(property);
|
||||
}
|
||||
|
||||
const std::string &Storage::Accessor::EdgeTypeToName(EdgeTypeId edge_type) const {
|
||||
return storage_->EdgeTypeToName(edge_type);
|
||||
}
|
||||
|
||||
LabelId Storage::Accessor::NameToLabel(const std::string_view name) { return storage_->NameToLabel(name); }
|
||||
|
||||
PropertyId Storage::Accessor::NameToProperty(const std::string_view name) { return storage_->NameToProperty(name); }
|
||||
|
||||
EdgeTypeId Storage::Accessor::NameToEdgeType(const std::string_view name) { return storage_->NameToEdgeType(name); }
|
||||
|
||||
} // namespace memgraph::storage
|
||||
|
||||
@@ -272,18 +272,18 @@ class Storage {
|
||||
/// @throw std::bad_alloc
|
||||
virtual Result<std::optional<EdgeAccessor>> DeleteEdge(EdgeAccessor *edge) = 0;
|
||||
|
||||
virtual const std::string &LabelToName(LabelId label) const = 0;
|
||||
virtual const std::string &PropertyToName(PropertyId property) const = 0;
|
||||
virtual const std::string &EdgeTypeToName(EdgeTypeId edge_type) const = 0;
|
||||
const std::string &LabelToName(LabelId label) const;
|
||||
const std::string &PropertyToName(PropertyId property) const;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual LabelId NameToLabel(std::string_view name) = 0;
|
||||
LabelId NameToLabel(std::string_view name);
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual PropertyId NameToProperty(std::string_view name) = 0;
|
||||
PropertyId NameToProperty(std::string_view name);
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual EdgeTypeId NameToEdgeType(std::string_view name) = 0;
|
||||
EdgeTypeId NameToEdgeType(std::string_view name);
|
||||
|
||||
virtual bool LabelIndexExists(LabelId label) const = 0;
|
||||
|
||||
@@ -322,18 +322,18 @@ class Storage {
|
||||
virtual std::unique_ptr<Accessor> Access(std::optional<IsolationLevel> override_isolation_level) = 0;
|
||||
std::unique_ptr<Accessor> Access() { return Access(std::optional<IsolationLevel>{}); }
|
||||
|
||||
virtual const std::string &LabelToName(LabelId label) const = 0;
|
||||
virtual const std::string &PropertyToName(PropertyId property) const = 0;
|
||||
virtual const std::string &EdgeTypeToName(EdgeTypeId edge_type) const = 0;
|
||||
const std::string &LabelToName(LabelId label) const;
|
||||
const std::string &PropertyToName(PropertyId property) const;
|
||||
const std::string &EdgeTypeToName(EdgeTypeId edge_type) const;
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual LabelId NameToLabel(std::string_view name) = 0;
|
||||
LabelId NameToLabel(std::string_view name);
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual PropertyId NameToProperty(std::string_view name) = 0;
|
||||
PropertyId NameToProperty(std::string_view name);
|
||||
|
||||
/// @throw std::bad_alloc if unable to insert a new mapping
|
||||
virtual EdgeTypeId NameToEdgeType(std::string_view name) = 0;
|
||||
EdgeTypeId NameToEdgeType(std::string_view name);
|
||||
|
||||
/// Create an index.
|
||||
/// Returns void if the index has been created.
|
||||
|
||||
Reference in New Issue
Block a user