From 381aefe5ad7db83be300a4ddf58cb77e43167c23 Mon Sep 17 00:00:00 2001 From: zhangyi51 Date: Tue, 27 Oct 2020 21:11:21 +0800 Subject: [PATCH] improve Change-Id: I57331425089e18582f5938536c5026e703ce34c6 --- .../baidu/hugegraph/schema/builder/AbstractBuilder.java | 7 +++++++ .../baidu/hugegraph/schema/builder/IndexLabelBuilder.java | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java index 9674a05096..a6b49e03e4 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java @@ -30,9 +30,11 @@ import com.baidu.hugegraph.schema.EdgeLabel; import com.baidu.hugegraph.schema.IndexLabel; import com.baidu.hugegraph.schema.PropertyKey; +import com.baidu.hugegraph.schema.SchemaElement; import com.baidu.hugegraph.schema.VertexLabel; import com.baidu.hugegraph.type.HugeType; import com.baidu.hugegraph.type.define.GraphMode; +import com.baidu.hugegraph.type.define.SchemaStatus; import com.baidu.hugegraph.util.E; import com.baidu.hugegraph.util.LockUtil; @@ -77,6 +79,11 @@ protected V lockCheckAndCreateSchema(HugeType type, String name, } } + protected void updateSchemaStatus(SchemaElement element, + SchemaStatus status) { + this.transaction.updateSchemaStatus(element, status); + } + protected void checkSchemaIdIfRestoringMode(HugeType type, Id id) { if (this.transaction.graphMode() == GraphMode.RESTORING) { E.checkArgument(id != null, diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java index 8d28fe5354..86393efa4b 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java @@ -231,8 +231,7 @@ public IndexLabel.CreatedIndexLabel createWithTask() { return new IndexLabel.CreatedIndexLabel(indexLabel, rebuildTask); } catch (Throwable e) { - indexLabel.status(SchemaStatus.INVALID); - this.graph().addIndexLabel(schemaLabel, indexLabel); + this.updateSchemaStatus(indexLabel, SchemaStatus.INVALID); throw e; } });