0
votes

I am wondering if there is an implementation of Blueprint's IndexableGraphHelper or equivalent work-around in Titan. During ETL, I want to ensure that I do not create duplicate vertices and my edges have are properly connected. So, I attempt to see if a vertex with the same key/value exists before creating as follows:

Iterable<Vertex> sampleVertices =graph.getVertices("MyKey", MyKevValue); 

if (!sampleVertices.iterator().hasNext())
{
    //create a new vertex here
}
else 
{
    for(Vertex v:sampleVertices)
    {
        sampleVertex=v;
        //System.out.println("sampleVertexID: " + sampleVertex.getId().toString());
        break;
    }
}

I am a Titan novice and have not used Java in several years. Any help would be greatly appreciated.

1

1 Answers

0
votes

There are no such "helper" methods for Titan. You have to write your own getOrCreate function to ensure uniqueness. This is a fairly common pattern in "bulk loading". You might consider using BatchGraph during your ETL process as it helps simplify the getOrCreate a bit and will help improve the performance of your load. You also might find this blog post series on batch loading to Titan useful: "Powers of Ten" - Part One and Part Two.