From 113dbc011638e2dd6c388a6a95387e18c2300a94 Mon Sep 17 00:00:00 2001 From: Wang Zhiyong Date: Thu, 17 Oct 2024 09:47:23 +0800 Subject: [PATCH] Add missing `pair_unique` in output of dbms.graph.getGraphSchema() (#707) --- src/core/edge_index.h | 5 ++++- src/core/schema.cpp | 14 -------------- src/core/schema.h | 1 - src/cypher/procedure/procedure.cpp | 1 + 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/core/edge_index.h b/src/core/edge_index.h index bdf8b5cc2b..95c5572d9d 100644 --- a/src/core/edge_index.h +++ b/src/core/edge_index.h @@ -475,7 +475,10 @@ class EdgeIndex { } bool IsUnique() const { - return type_ == IndexType::GlobalUniqueIndex || type_ == IndexType::PairUniqueIndex; + return type_ == IndexType::GlobalUniqueIndex; + } + bool IsPairUnique() const { + return type_ == IndexType::PairUniqueIndex; } IndexType GetType() const { return type_; } diff --git a/src/core/schema.cpp b/src/core/schema.cpp index 51a5bb4b3a..a053bc98d3 100644 --- a/src/core/schema.cpp +++ b/src/core/schema.cpp @@ -281,20 +281,6 @@ void Schema::DeleteCreatedEdgeIndex(KvTransaction& txn, const EdgeUid& euid, con } } -bool Schema::EdgeUniqueIndexConflict(KvTransaction& txn, const Value& record) { - for (auto& idx : indexed_fields_) { - auto& fe = fields_[idx]; - EdgeIndex* index = fe.GetEdgeIndex(); - FMA_ASSERT(index); - if (!index->IsUnique()) continue; - if (fe.GetIsNull(record)) continue; - if (index->UniqueIndexConflict(txn, fe.GetConstRef(record))) { - return true; - } - } - return false; -} - void Schema::AddEdgeToIndex(KvTransaction& txn, const EdgeUid& euid, const Value& record, std::vector& created) { created.reserve(fields_.size()); diff --git a/src/core/schema.h b/src/core/schema.h index 6390666f37..bce2cf2c59 100644 --- a/src/core/schema.h +++ b/src/core/schema.h @@ -499,7 +499,6 @@ class Schema { void AddEdgeToIndex(KvTransaction& txn, const EdgeUid& euid, const Value& record, std::vector& created); - bool EdgeUniqueIndexConflict(KvTransaction& txn, const Value& record); void AddVectorToVectorIndex(KvTransaction& txn, VertexId vid, const Value& record); diff --git a/src/cypher/procedure/procedure.cpp b/src/cypher/procedure/procedure.cpp index 2d37b468f9..74d98f9297 100644 --- a/src/cypher/procedure/procedure.cpp +++ b/src/cypher/procedure/procedure.cpp @@ -2241,6 +2241,7 @@ void BuiltinProcedure::DbmsGraphGetGraphSchema(RTContext *ctx, const Record *rec if (vi) { property["index"] = true; property["unique"] = vi->IsUnique(); + property["pair_unique"] = vi->IsPairUnique(); } edge["properties"].push_back(property); }