You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by je...@apache.org on 2022/06/06 03:31:18 UTC

[incubator-hugegraph] 04/05: call updateIfAbsent() for schema insert

This is an automated email from the ASF dual-hosted git repository.

jermy pushed a commit to branch schema-update-bug-rebase
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit 40a5196a5b815f63b3885be4cf9aa03ca59c6ac3
Author: Zhangmei Li <li...@baidu.com>
AuthorDate: Wed Mar 2 16:44:51 2022 +0800

    call updateIfAbsent() for schema insert
    
    Change-Id: I02989962791fa369600f8dedbfd56e2b40c79077
---
 .../main/java/com/baidu/hugegraph/backend/store/BackendTable.java   | 4 ++--
 .../main/java/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 9753076eb..f8ec5fe23 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 @@ public abstract class BackendTable<Session extends BackendSession, Entry> {
     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 abstract class BackendTable<Session extends BackendSession, 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 98cf4309d..340b66928 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 @@ public class SchemaTransaction extends IndexableTransaction {
 
             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);
             }