Skip to content

Commit

Permalink
Used nextTraverser() in what was formerly TraversalIterator.
Browse files Browse the repository at this point in the history
This is now the preferred way rather than pulling the iterator out of getEndStep() CTR
  • Loading branch information
spmallette committed Sep 29, 2016
1 parent 465ae28 commit 850e159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.apache.tinkerpop.gremlin.server.op.OpProcessorException;
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
import org.apache.tinkerpop.gremlin.server.util.SideEffectIterator;
import org.apache.tinkerpop.gremlin.server.util.TraversalIterator;
import org.apache.tinkerpop.gremlin.server.util.TraverserIterator;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
Expand Down Expand Up @@ -366,7 +366,7 @@ private void iterateBytecodeTraversal(final Context context) throws OpProcessorE
try {
// compile the traversal - without it getEndStep() has nothing in it
traversal.applyStrategies();
handleIterator(context, new TraversalIterator(traversal));
handleIterator(context, new TraverserIterator(traversal));
} catch (TimeoutException ex) {
final String errorMessage = String.format("Response iteration exceeded the configured threshold for request [%s] - %s", msg.getRequestId(), ex.getMessage());
logger.warn(errorMessage);
Expand Down Expand Up @@ -399,8 +399,8 @@ private void iterateBytecodeTraversal(final Context context) throws OpProcessorE

@Override
protected void iterateComplete(final ChannelHandlerContext ctx, final RequestMessage msg, final Iterator itty) {
if (itty instanceof TraversalIterator) {
final Traversal.Admin traversal = ((TraversalIterator) itty).getTraversal();
if (itty instanceof TraverserIterator) {
final Traversal.Admin traversal = ((TraverserIterator) itty).getTraversal();
if (!traversal.getSideEffects().isEmpty()) {
cache.put(msg.getRequestId(), traversal.getSideEffects());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@
/**
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class TraversalIterator implements Iterator<Object> {
public class TraverserIterator implements Iterator<Object> {

private final Traversal.Admin traversal;
private final Iterator<Object> traversalIterator;
private final HaltedTraverserStrategy haltedTraverserStrategy;

public TraversalIterator(final Traversal.Admin traversal) {
public TraverserIterator(final Traversal.Admin traversal) {
this.traversal = traversal;
this.traversalIterator = traversal.getEndStep();
this.haltedTraverserStrategy = traversal.getStrategies().getStrategy(HaltedTraverserStrategy.class).orElse(
Boolean.valueOf(System.getProperty("is.testing", "false")) ?
HaltedTraverserStrategy.detached() :
Expand All @@ -49,12 +47,12 @@ public Traversal.Admin getTraversal() {

@Override
public boolean hasNext() {
return this.traversalIterator.hasNext();
return this.traversal.hasNext();
}

@Override
public Object next() {
final Traverser.Admin t = this.haltedTraverserStrategy.halt((Traverser.Admin) traversalIterator.next());
final Traverser.Admin t = this.haltedTraverserStrategy.halt(traversal.nextTraverser());
return new DefaultRemoteTraverser<>(t.get(), t.bulk());
}
}

0 comments on commit 850e159

Please sign in to comment.