Skip to content

Commit

Permalink
Define loading mode to speed up when loading data (#1188)
Browse files Browse the repository at this point in the history
Change-Id: Ia9a93a3f0433c67353d89eb877a799ed5202fac1
  • Loading branch information
Linary authored Sep 23, 2020
1 parent 2fceac9 commit ba30654
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public GraphMode mode() {

@Override
public void mode(GraphMode mode) {
LOG.info("Graph {} will work in {} mode", this, mode);
this.mode = mode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.baidu.hugegraph.config.HugeConfig;
import com.baidu.hugegraph.event.EventHub;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.type.define.GraphMode;
import com.baidu.hugegraph.util.Events;
import com.baidu.hugegraph.util.Log;

Expand Down Expand Up @@ -216,6 +217,10 @@ public ExecutorService backendExecutor() {
return this.backendExecutor;
}

public GraphMode graphMode() {
return this.params.mode();
}

private HugeConfig config() {
return this.params.configuration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.baidu.hugegraph.backend.store.BackendStore;
import com.baidu.hugegraph.backend.store.raft.RaftBackendStore.IncrCounter;
import com.baidu.hugegraph.type.HugeType;
import com.baidu.hugegraph.type.define.GraphMode;
import com.baidu.hugegraph.util.LZ4Util;
import com.baidu.hugegraph.util.Log;

Expand Down Expand Up @@ -81,8 +82,10 @@ private void registerCommands() {
this.store.beginTx();
for (BackendMutation mutation : ms) {
this.store.mutate(mutation);
// update cache on follower
this.updateCacheIfNeeded(mutation);
// update cache on follower when graph run in general mode
if (this.context.graphMode() == GraphMode.NONE) {
this.updateCacheIfNeeded(mutation);
}
}
this.store.commitTx();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ protected void prepareAdditions(Map<Id, HugeVertex> addedVertices,
v.committed();
this.checkAggregateProperty(v);
// Check whether passed all non-null properties
this.checkNonnullProperty(v);
if (!this.graphMode().loading()) {
this.checkNonnullProperty(v);
}

// Add vertex entry
this.doInsert(this.serializer.writeVertex(v));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public enum GraphMode {
* 1. Not allowed create schema with specified id
* 2. Support create vertex with id for AUTOMATIC id strategy
*/
MERGING(3, "merging");
MERGING(3, "merging"),

/*
* LOADING mode used to load data via hugegraph-loader.
*/
LOADING(4, "loading");

private final byte code;
private final String name;
Expand All @@ -62,4 +67,8 @@ public String string() {
public boolean maintaining() {
return this == RESTORING || this == MERGING;
}

public boolean loading() {
return this == LOADING;
}
}

0 comments on commit ba30654

Please sign in to comment.