Skip to content
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

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

Linary
Copy link
Contributor

@Linary Linary commented Nov 13, 2018

Implement #185

Change-Id: Iabac4af7804aa07c449280cf30eb65ab17d9bd97


public static final ConfigOption<Boolean> CHECK_CUSTOMIZED_ID_VERTEX =
new ConfigOption<>(
"check_customzied_id_vertex",
Copy link
Contributor

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)) {
Copy link
Contributor

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

@Linary Linary force-pushed the check-vertex-exist branch from 0a4449b to a03f5d1 Compare November 14, 2018 09:11
javeme
javeme previously requested changes Nov 15, 2018
@@ -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);
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkVertexWithCustomizedId

javeme
javeme previously requested changes Nov 15, 2018
IdQuery idQuery = new IdQuery(HugeType.VERTEX, ids);
Iterator<HugeVertex> results = this.queryVerticesFromBackend(idQuery);
if (results.hasNext()) {
HugeVertex vertex = results.next();
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkVertexExistIfCustomizedId

javeme
javeme previously approved these changes Nov 16, 2018
javeme
javeme previously approved these changes Nov 16, 2018
Implement #185

Change-Id: Iabac4af7804aa07c449280cf30eb65ab17d9bd97
@Linary Linary force-pushed the check-vertex-exist branch from 8539d20 to 908192b Compare November 16, 2018 11:01
@Linary Linary dismissed stale reviews from javeme and zhoney November 16, 2018 11:03

done

@zhoney zhoney merged commit 1362d78 into master Nov 16, 2018
@Linary Linary deleted the check-vertex-exist branch November 16, 2018 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants