4

Came across a scenario where I need to write a titan query using GraphTraversal api which has various clauses like in, contains, within etc.

To form the required clauses I am utilising P.within(..), P.inside(..), P.test(..) etc. predicates. Following is an illustration of traversal instance

traversal.has("field1", P.within(new String[]{"value1", "value2"})).
            has("field2", P.test((r1, r2) -> {
                    return ((String)r1)).contains((String)r2));
                }, "someVal"));

I want to understand how Titan internally evaluates this query? Does it evaluates all predicates after loading all vertices in memory?

Filipe Teixeira
  • 3,565
  • 1
  • 25
  • 45
Bhavesh
  • 519
  • 6
  • 26

1 Answers1

1

Standard predicates like P.within will be optimized whenever possible (in your example, if you would have an index over field1, Titan would use it). Custom predicates on the other hand can't be optimized; as you say, Titan will load all vertices into memory and then apply the filter predicate.

Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34