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

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

Open
raz-viber opened this issue Aug 29, 2019 · 5 comments
Open

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

raz-viber opened this issue Aug 29, 2019 · 5 comments

Comments

@raz-viber
Copy link

raz-viber commented Aug 29, 2019

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?

@farodin91
Copy link
Contributor

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

@liu-chao-simon
Copy link

liu-chao-simon commented Oct 31, 2021

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.

@li-boxuan
Copy link
Member

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

@liu-chao-simon
Copy link

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!

@li-boxuan
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants