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

Enable setting custom vertex ids in TP3 interface #147 #148

Merged
merged 2 commits into from
Jun 16, 2017

Conversation

amcp
Copy link

@amcp amcp commented Mar 3, 2017

fixes #147, another bug fix that didn't make it into Titan by the end of 2015
Signed-off-by: Alexander Patrikalakis [email protected]

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label Mar 3, 2017
@sjudeng
Copy link
Contributor

sjudeng commented Mar 3, 2017

I wonder if this might solve the issue I saw with custom vertex ids in upgrading to TinkerPop 3.2.3 (see notes in #78). To resolve there I updated test GraphComputerImplementations to include configuration around id generation but I wasn't happy with that approach.

@amcp
Copy link
Author

amcp commented Mar 3, 2017

@sjudeng I've got to put in for the night it being 2AM here, but if this interests you and given the extremely small size of the fix I encourage you to pick up from here and rip out the config workaround you put in GraphComputerImplementations to see if it fixes the issue you encountered.

@sjudeng
Copy link
Contributor

sjudeng commented Mar 8, 2017

I took a look at this branch. Initially I was having test failures of the form The provided key/value array must have a String or T on even array indices, which I resolved with the below update.

--- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java
+++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphBlueprintsTransaction.java
@@ -115,7 +115,8 @@ public abstract class JanusGraphBlueprintsTransaction implements JanusGraphTrans
             label = (labelValue instanceof VertexLabel)?(VertexLabel)labelValue:getOrCreateVertexLabel((String) labelValue);
         }
 
-        final JanusGraphVertex vertex = addVertex(ElementHelper.getIdValue(keyValues).orElse(null), label);
+        final Number id = (Number) ElementHelper.getIdValue(keyValues).orElse(null);
+        JanusGraphVertex vertex = addVertex(id != null ? id.longValue() : null, label);

I then tried running through tests in the PeerPressureTest suite via InMemoryJanusGraphComputerTest, which use custom vertex ids. But these gave errors at StandardJanusGraphTx.java#L514. I experimented with an additional conditional there for graph.getConfiguration().allowVertexIdSetting() && UserVertex.is(vertexId) but that also failed (UserVertex.is(vertexId) was false). I also tried forcing it past that error but then ended up with an error lower down at IDManager.java#L474.

Copy link
Contributor

@sjudeng sjudeng left a comment

Choose a reason for hiding this comment

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

See note above regarding build errors. I'll try to look at this as well when I get some time.

Alexander Patrikalakis and others added 2 commits June 11, 2017 22:25
… user vertex ids and valid JanusGraph vertex ids.

Signed-off-by: sjudeng <[email protected]>
@sjudeng
Copy link
Contributor

sjudeng commented Jun 12, 2017

@amcp I rebased and added a commit to this PR. The commit includes a fix to JanusGraphBlueprintsTransaction to resolve test failures as described in the comment above. Also during testing I found that the existing documented method for converting user ids to vertex ids, JanusGraphId#toVertexId(long), is no longer valid as it doesn't take into account partitioning bits used in JanusGraph vertex assignment. Attempts to flush vertices with custom ids created using this method can lead to assert/IllegalArgumentException errors. To resolve this issue I added methods to IDManager for converting user vertex ids to/from JanusGraph vertex ids and deprecated JanusGraphId.

All default and TinkerPop tests are passing with these updates. Given my involvement in the implementation I think it would be best to have another independent review.

@sjudeng sjudeng dismissed their stale review June 12, 2017 11:31

Dismissing my review since I contributed to the implementation.

Copy link
Author

@amcp amcp left a comment

Choose a reason for hiding this comment

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

minor comments.

* @return a corresponding JanusGraph vertex id
* @see #fromVertexId(long)
*/
public long toVertexId(long id) {
Copy link
Author

Choose a reason for hiding this comment

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

can you test this method?

Copy link
Contributor

Choose a reason for hiding this comment

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

@amcp There's a test added as part of the commit (see VertexIDAssignerTest#testCustomIdAssignment).

* @return original user provided id
* @see #toVertexId(long)
*/
public long fromVertexId(long id) {
Copy link
Author

Choose a reason for hiding this comment

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

can you test this method?

@amcp
Copy link
Author

amcp commented Jun 13, 2017

@sjudeng I agree we need another review.
@analytically the content of this PR changed slightly so can you re-review please?

Copy link
Contributor

@analytically analytically left a comment

Choose a reason for hiding this comment

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

Let's merge.

@amcp amcp merged commit 224b82d into JanusGraph:master Jun 16, 2017
@amcp amcp deleted the fixBlueprintsCustomIds branch June 16, 2017 11:23
bwatson-rti-org pushed a commit to bwatson-rti-org/janusgraph that referenced this pull request Mar 9, 2019
Enable setting custom vertex ids in TP3 interface JanusGraph#147
micpod pushed a commit to micpod/janusgraph that referenced this pull request Nov 5, 2019
Enable setting custom vertex ids in TP3 interface JanusGraph#147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR is compliant with the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable custom id setting in JanusGraphBlueprintsTransaction
4 participants