janusgraph icon indicating copy to clipboard operation
janusgraph copied to clipboard

User-defined vertex ids - why do they need to end in 000?

Open raz-viber opened this issue 6 years ago • 5 comments

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?

raz-viber avatar Aug 29 '19 12:08 raz-viber

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

farodin91 avatar Aug 29 '19 19:08 farodin91

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.

liu-chao-simon avatar Oct 31 '21 12:10 liu-chao-simon

You need to call graph.getIDManager().toVertexId(custom_id) to get a valid id.

li-boxuan avatar Oct 31 '21 14:10 li-boxuan

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!

liu-chao-simon avatar Oct 31 '21 15:10 liu-chao-simon

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.

li-boxuan avatar Oct 31 '21 15:10 li-boxuan