Ducaz035
Ducaz035

Reputation: 3132

Querying total number of vertices fast in Titan

I have a way to find the total number of vertices in Titan.

Iterator iterator = g.getVertices().iterator();

while(iterator.hasNext()) {
    iterator.next();
    ++count;
}

However, this is so expensive operation basically it traverses all the vertices, i couldn't find a way to do it faster. I am using unique indexes and Hbase as back-end.

Cheers,

Upvotes: 0

Views: 79

Answers (1)

stephen mallette
stephen mallette

Reputation: 46206

Such is the nature of things I'm afraid. You could at least count in parallel if you used Faunus, but then you have hadoop in play which will be "slow" in its own right. You don't say how large your graph is, but if you're looking at billions of vertices then waiting for Faunus to complete the count is better than the result of iteration never returning.

Upvotes: 1

Related Questions