简体   繁体   中英

IndexableGraphHelper in Titan?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM