Hi,
No I can not demonstrate a traversal failure. At least not using
TinkerGraph. The failure I get is while optimizing a step in Sqlg.
Previously I would look for CyclicPathStep or SimplePathStep both of
which are NOT a TraversalParent so TraversalHelper.anyStepRecursively
happen to work.
With the 3.2.5 refactor I am looking for PathFilterStep which is a
TraversalParent thus causing the bug to occur.
I can show that TraversalHelper.anyStepRecursively is incorrect.
@Test
public void test2() {
final TinkerGraph g = TinkerGraph.open();
Traversal.Admin<?, ?> traversal = (Traversal.Admin<?, ?>)
g.traversal()
.V()
.repeat(
__.out().simplePath()
);
Predicate p = s -> s.getClass().equals(PathFilterStep.class);
Assert.assertTrue(TraversalHelper.anyStepRecursively(p,
traversal));
traversal = (Traversal.Admin<?, ?>) g.traversal()
.V()
.optional(
__.out().path()
);
p = s -> s.getClass().equals(PathStep.class);
Assert.assertTrue(TraversalHelper.anyStepRecursively(p,
traversal));
}
The only place I see TraversalHelper.anyStepRecursively being used in
TinkerPop is in the PathRetractionStrategy. Its code is a bit too dense
for me to quickly understand the effect on it.
Thanks
Pieter
On 13/06/2017 21:32, Marko Rodriguez wrote:
Hello,
Can you provide a CyclicPathTest that demonstrates the failure?
Marko.
On Jun 13, 2017, at 10:34 AM, pieter gmail <pieter.mar...@gmail.com> wrote:
Hi,
With 3.2.5 CyclicPathStep and SimplePathStep has been replaced with
PathFilterStep.
This is fine but whilst doing the refactor I noticed what appears to be a bug
in TraversalHelper.anyStepRecursively
public static boolean anyStepRecursively(final Predicate<Step> predicate, final
Traversal.Admin<?, ?> traversal) {
for (final Step<?, ?> step : traversal.getSteps()) {
if (predicate.test(step)) {
return true;
}
if (step instanceof TraversalParent) anyStepRecursively(predicate,
((TraversalParent) step));
}
return false;
}
Surely the second if statement should return true if
anyStepRecursively(predicate, ((TraversalParent) step)); returns true?
i.e.
public static boolean anyStepRecursively(final Predicate<Step> predicate, final
Traversal.Admin<?, ?> traversal) {
for (final Step<?, ?> step : traversal.getSteps()) {
if (predicate.test(step)) {
return true;
}
if (step instanceof TraversalParent) {
if (anyStepRecursively(predicate, ((TraversalParent) step))) {
return true;
}
}
}
return false;
}
Cheers
Pieter