User-defined vertex ids - why do they need to end in 000?
I tried to define a user-id but I have encountered the same issue as above, which i have to supply id that ends in 000.
And on line 507 of StandardJanusGraphTx, we have this pre-condition:
Preconditions.checkArgument(vertexId == null || IDManager.VertexIDType.NormalVertex.is(vertexId), "Not a valid vertex id: %s", vertexId);
What's the reason for this constraint? And could this be a bug? Should the pre-condition be applied to VertexIDType.UserVertex instead?
Suffix 000 is for NormalVertex. The suffix are described in the following file: https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-core/src/main/java/org/janusgraph/graphdb/idmanagement/IDManager.java#L35-L55
I am also confused about this behavior, i try to use customized vertex id, but i found that i can only use id with value times by 8 (like 256, 264, 272...). What should i do if i want to control vertex id totally free.
You need to call graph.getIDManager().toVertexId(custom_id) to get a valid id.
Thanks for your answer, actually I have tried as your suggestion, for example a execution like g.addV(“A”).property(id,graph.getIDManager().toVertexId(1) ) will add a vertex with Id 256 actually, but I want to add a vertex with id 1 exactly, is that possible?
Expect your further answer, thanks!
for example a execution like g.addV(“A”).property(id,graph.getIDManager().toVertexId(1) ) will add a vertex with Id 256 actually, but I want to add a vertex with id 1 exactly, is that possible
No, that is not possible by design. Different suffixes are used by different types of vertices, many of which are reserved. Normal user vertices always have 000 as the suffix.