imriqwe
imriqwe

Reputation: 1455

Setting vertex ID in Titan 1.0.0

My app is currently using Titan 0.5.4 as its graph DB and does the following -

Parses a given raw data, then creates a vertex containing the parsed data, and also creates a unique identifier using a combination of the input data fields. Later on, when querying the graph, it re-creates the same unique identifier in order to check if data already exists (and fetching it).

I am currently working on a migration to Titan 1.0.0, and I cannot find a way to set vertex IDs as before.

How do you set a vertex ID on Titan 1.0.0?

A possible workaround is to create an indexed property (so-called id2), but it seems redundant to me.

Thanks

Upvotes: 0

Views: 532

Answers (3)

Sebastian Good
Sebastian Good

Reputation: 6360

Why not create a property which can be indexed to provide the same functionality?

Upvotes: 0

Micheal Kris
Micheal Kris

Reputation: 186

It seems the titan transaction still allowes you to provide an id when creating the vertex. Note, this might be a bug and might be removed in the next version. https://github.com/thinkaurelius/titan/blob/titan10/titan-core/src/main/java/com/thinkaurelius/titan/core/TitanTransaction.java

I think a reasonable way to solve this is to add a property key and composite index on each of your vertices and use that for your queries.

Upvotes: 1

Filipe Teixeira
Filipe Teixeira

Reputation: 3565

Sorry to say that you cannot set the vertex ID in Titan as it is generated on construction. This and this are questions which ask the same thing essentially.

In Titan's case I believe that the id refers to an actual location on the disk). As stated here:

The (64 bit) vertex id (which Titan uniquely assigns to every vertex) is the key which points to the row containing the vertex’s adjacency list

Upvotes: 2

Related Questions