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

adding vertex with custom id? #45

Closed
chrislusf opened this issue Jan 18, 2017 · 2 comments
Closed

adding vertex with custom id? #45

chrislusf opened this issue Jan 18, 2017 · 2 comments

Comments

@chrislusf
Copy link

When g.addV(), there are no way to specify the id. The id is auto-generated.

Is it possible to specify the id directly? We have UUID for all entities. Avoiding another redirection will save the extra index on UUID.

@rafatuita
Copy link
Contributor

Once the database is initialized using this "graph.set-vertex-id=false", which is the default, you can't set the IDs.
What it means is that, exporting/importing data using GraphReader's on an existing graph would just duplicate the whole thing up.
In my case, I have a dev graph with many vertices that I'd like to export to some other graph and use the same ID as in the previous graph so it is sort of like "static" ID. If I could set the ID or create using that ID would be awesome.

What I had to do was to create a "shadow" ID property to store that ID, so I'd traverse that shadow first, if exists I use that, otherwise just use the vertex.id() value.

I had to create my own GraphReader to traverse first, update if found, if not create and set the shadow so I could use it...

Now I have an overhead to traverse instead of just going straight to the ID itself using indexes.

@sjudeng
Copy link
Contributor

sjudeng commented Jun 17, 2017

#148 has been merged which restores support for custom Long vertex ids in JanusGraph. Note that only Long ids are supported and they must be converted to valid JanusGraph ids for use in g.addVertex(T.id, id). See recently updated method documentation.

@sjudeng sjudeng closed this as completed Jun 17, 2017
rwilcox referenced this issue in mpollmeier/gremlin-scala Feb 5, 2018
when using remote graphs, Graph is actually just an empty shell and
can't be used to e.g. add elements.

open problems:
* marshalled classes can use the @id annotation to specify
the ID of a vertex, but we cannot set the id of a vertex inside a traversal
* same needs to be applied for edges

re #223
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

No branches or pull requests

3 participants