From 40a5196a5b815f63b3885be4cf9aa03ca59c6ac3 Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Wed, 2 Mar 2022 16:44:51 +0800 Subject: [PATCH] call updateIfAbsent() for schema insert Change-Id: I02989962791fa369600f8dedbfd56e2b40c79077 --- .../com/baidu/hugegraph/backend/store/BackendTable.java | 4 ++-- .../com/baidu/hugegraph/backend/tx/SchemaTransaction.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java index 9753076ebf..f8ec5fe238 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendTable.java @@ -69,7 +69,7 @@ protected void registerMetaHandlers() { public void updateIfPresent(Session session, Entry entry) { // TODO: use fine-grained row lock synchronized (this.table) { - assert !session.hasChanges(); + assert session == null || !session.hasChanges(); if (this.queryExist(session, entry)) { this.insert(session, entry); if (session != null) { @@ -82,7 +82,7 @@ public void updateIfPresent(Session session, Entry entry) { public void updateIfAbsent(Session session, Entry entry) { // TODO: use fine-grained row lock synchronized (this.table) { - assert !session.hasChanges(); + assert session == null || !session.hasChanges(); if (!this.queryExist(session, entry)) { this.insert(session, entry); if (session != null) { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/SchemaTransaction.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/SchemaTransaction.java index 98cf4309d2..340b66928c 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/SchemaTransaction.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/SchemaTransaction.java @@ -408,11 +408,11 @@ private void saveSchema(SchemaElement schema, boolean update) { if (update) { this.doUpdateIfPresent(entry); - // TODO: support updateIfPresent + // TODO: also support updateIfPresent for index-update this.indexTx.updateNameIndex(schema, false); } else { - // TODO: support updateIfAbsentProperty - this.doInsert(entry); + // TODO: support updateIfAbsentProperty (property: label name) + this.doUpdateIfAbsent(entry); this.indexTx.updateNameIndex(schema, false); }