// Forward traversal
else if (null != subject && null == object) {
if (!(subject instanceof RippleSesameValue)) {
subject = (Resource) valueFactory.nativize(subject);
}
RippleList stack = ((RippleSesameValue) subject).getStack();
//System.out.println("\tstack = " + stack);
if (null == stack) {
stack = modelConnection.list().push(modelConnection.canonicalValue(new RDFValue(subject)));
// Note: this may or may not be worth the extra CPU cycles.
((RippleSesameValue) subject).setStack(stack);
}
stack = stack.push(modelConnection.canonicalValue(
new RDFValue(valueFactory.nativize(predicate)))).push(Operator.OP);
//System.out.println("\t\tstack (new) = " + stack);
CloseableIteration<RippleList, RippleException> solutions
= new LazyEvaluatingIterator(stack, modelConnection);
/*
Collector<StackContext, RippleException> solutions = new Collector<StackContext, RippleException>();
evaluator.apply(new StackContext(stack, modelConnection), solutions);
Collection<RippleList> stacks = new LinkedList<RippleList>();
for (StackContext c : solutions) {
//System.out.println("\tsolution: " + c);
RippleList s = c.getStack();
if (!s.isNil()) {
stacks.add(s);
}
}
return new SolutionIteration(stacks.iterator(), false, subject, predicate, object, contexts);
*/
return new SolutionIteration(solutions, false, subject, predicate, object, contexts);
}
// Backward traversal
else if (null == subject) {
if (!(object instanceof RippleSesameValue)) {
object = valueFactory.nativize(object);
}
RippleList stack = ((RippleSesameValue) object).getStack();
if (null == stack) {
stack = modelConnection.list().push(modelConnection.canonicalValue(new RDFValue(object)));
// Note: this may or may not be worth the extra CPU cycles.
((RippleSesameValue) object).setStack(stack);
}
stack = stack.push(modelConnection.canonicalValue(new RDFValue(predicate)))
.push(ControlLibrary.getInverseValue())
.push(Operator.OP)
.push(Operator.OP);
//System.out.println("stack = " + stack);