-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check exist same Id when inserting vertices with customized id strategy #189
Conversation
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java
Outdated
Show resolved
Hide resolved
88ca656
to
0a4449b
Compare
|
||
public static final ConfigOption<Boolean> CHECK_CUSTOMIZED_ID_VERTEX = | ||
new ConfigOption<>( | ||
"check_customzied_id_vertex", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vertex.check_customzied_id_exist
@@ -207,6 +207,10 @@ protected BackendMutation prepareCommit() { | |||
|
|||
protected void prepareAdditions(Map<Id, HugeVertex> addedVertexes, | |||
Map<Id, HugeEdge> addedEdges) { | |||
HugeConfig config = this.graph().configuration(); | |||
if (config.get(CoreOptions.CHECK_CUSTOMIZED_ID_VERTEX)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer to add a private field for it
0a4449b
to
a03f5d1
Compare
@@ -113,6 +115,8 @@ public GraphTransaction(HugeGraph graph, BackendStore store) { | |||
assert !this.indexTx.autoCommit(); | |||
|
|||
final HugeConfig conf = graph.configuration(); | |||
this.checkIdExist = conf.get( | |||
CoreOptions.VERTEX_CHECK_CUSTOMIZED_ID_EXIST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to:
this.checkVertexId = conf.get(CoreOptions.VERTEX_CHECK_CUSTOMIZED_ID)
@@ -235,6 +242,29 @@ protected void prepareAdditions(Map<Id, HugeVertex> addedVertexes, | |||
} | |||
} | |||
|
|||
private void checkCustomizedIdVertex(Map<Id, HugeVertex> addedVertexes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkVertexWithCustomizedId
a03f5d1
to
29a3e75
Compare
29a3e75
to
6479b43
Compare
IdQuery idQuery = new IdQuery(HugeType.VERTEX, ids); | ||
Iterator<HugeVertex> results = this.queryVerticesFromBackend(idQuery); | ||
if (results.hasNext()) { | ||
HugeVertex vertex = results.next(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to call results.next()
@@ -207,6 +211,9 @@ protected BackendMutation prepareCommit() { | |||
|
|||
protected void prepareAdditions(Map<Id, HugeVertex> addedVertexes, | |||
Map<Id, HugeEdge> addedEdges) { | |||
if (this.checkVertexId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkVertexExist
@@ -207,6 +211,9 @@ protected BackendMutation prepareCommit() { | |||
|
|||
protected void prepareAdditions(Map<Id, HugeVertex> addedVertexes, | |||
Map<Id, HugeEdge> addedEdges) { | |||
if (this.checkVertexId) { | |||
this.checkVertexWithCustomizedId(addedVertexes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkVertexExistIfCustomizedId
6479b43
to
5edeb6c
Compare
5edeb6c
to
55daee5
Compare
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java
Outdated
Show resolved
Hide resolved
55daee5
to
8539d20
Compare
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphTransaction.java
Outdated
Show resolved
Hide resolved
Implement #185 Change-Id: Iabac4af7804aa07c449280cf30eb65ab17d9bd97
8539d20
to
908192b
Compare
Implement #185
Change-Id: Iabac4af7804aa07c449280cf30eb65ab17d9bd97