Open bdighe opened 7 years ago
t seems like a bug in titan-core/src/main/java/com/thinkaurelius/titan/graphdb/tinkerpop/optimize/HasStepFolder.java
When we use withPath(), the PathIdentityStep gets added to the Traverser before HasStep. But HasStepFolder.foldInHasContainer does not skip it, it does it for IdentityStep but not for PathIdentityStep. Since no HasContainer is added to translated TitanSteps, titan does not create index query.
I added highlighted code below and it resolves the issue.
It will be good if Titan experts can look at it and confirm if its a right fix.
Bharat
public static void foldInHasContainer(final HasStepFolder titanStep, final Traversal.Admin<?, ?> traversal) {
Step<?, ?> currentStep = titanStep.getNextStep();
while (true) {
if (currentStep instanceof HasContainerHolder) {
Iterable<HasContainer> containers = ((HasContainerHolder) currentStep).getHasContainers();
if (validTitanHas(containers)) {
titanStep.addAll(containers);
currentStep.getLabels().forEach(titanStep::addLabel);
traversal.removeStep(currentStep);
}
} else if (currentStep instanceof IdentityStep) {
// do nothing, has no impact
/** Start FIX **/
} else if (currentStep instanceof org.apache.tinkerpop.gremlin.process.traversal.step.util.PathIdentityStep) {
// do nothing, has no impact
/** End FIX **/
} else {
break;
}
currentStep = currentStep.getNextStep();
}
}
Should I create a pull request for this change? Would I need special permissions to push to this repository?
Thanks Bharat
Your contribution might get more attention at https://github.com/JanusGraph/janusgraph
I am observing, when withPath() is used, it does not make use of index. Anything I am missing here?
Output: Without withPath() .. 5 with withPath() .. 22:04:54,236 WARN StandardTitanTx:1262 - Query requires iterating over all vertices [()]. For better performance, use indexes 22:04:54,246 INFO ThriftKeyspaceImpl:745 - Detected partitioner org.apache.cassandra.dht.Murmur3Partitioner for keyspace my_ks 5