@Override public void addStart(final Traverser.Admin<S> start) { if (!this.locked) this.applyStrategies(); if (!this.steps.isEmpty()) this.steps.get(0).addStart(start); }
@Override public void addStarts(final Iterator<Traverser.Admin<S>> starts) { if (!this.locked) this.applyStrategies(); if (!this.steps.isEmpty()) this.steps.get(0).addStarts(starts); }
@Override public boolean hasNext() { if (!this.locked) this.applyStrategies(); return this.lastTraverser.bulk() > 0L || this.finalEndStep.hasNext(); }
@Override public Traverser.Admin<E> nextTraverser() { try { if (!this.locked) this.applyStrategies(); if (this.lastTraverser.bulk() > 0L) { final Traverser.Admin<E> temp = this.lastTraverser; this.lastTraverser = EmptyTraverser.instance(); return temp; } else { return this.finalEndStep.next(); } } catch (final FastNoSuchElementException e) { throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; } }
@Override public E next() { try { if (!this.locked) this.applyStrategies(); if (this.lastTraverser.bulk() == 0L) this.lastTraverser = this.finalEndStep.next(); this.lastTraverser.setBulk(this.lastTraverser.bulk() - 1L); return this.lastTraverser.get(); } catch (final FastNoSuchElementException e) { throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; } }
@Override public void applyStrategies() throws IllegalStateException { try { assert 0 == this.getSteps().size(); final ScriptEngine engine = SingleGremlinScriptEngineManager.get(this.scriptEngine); final Bindings engineBindings = engine.createBindings(); final List<TraversalStrategy<?>> strategyList = this.getStrategies().toList(); engineBindings.put(this.alias, this.factory.createTraversalSource(this.graph).withStrategies(strategyList.toArray(new TraversalStrategy[strategyList.size()]))); engineBindings.put("graph", this.graph); // TODO: we don't need this as the traversalSource.getGraph() exists, but its now here and people might be using it (remove in 3.3.0) for (int i = 0; i < this.bindings.length; i = i + 2) { engineBindings.put((String) this.bindings[i], this.bindings[i + 1]); } final Traversal.Admin<S, E> traversal = (Traversal.Admin<S, E>) engine.eval(this.script, engineBindings); traversal.getSideEffects().mergeInto(this.sideEffects); traversal.getSteps().forEach(this::addStep); this.strategies = traversal.getStrategies(); super.applyStrategies(); } catch (final ScriptException e) { throw new IllegalStateException(e.getMessage(), e); } } }
this.result = result; super.applyStrategies(); } catch (ScriptException e) { throw new IllegalStateException(e.getMessage(), e);
@Override public void addStart(final Traverser.Admin<S> start) { if (!this.locked) this.applyStrategies(); if (!this.steps.isEmpty()) this.steps.get(0).addStart(start); }
@Override public void addStarts(final Iterator<Traverser.Admin<S>> starts) { if (!this.locked) this.applyStrategies(); if (!this.steps.isEmpty()) this.steps.get(0).addStarts(starts); }
@Override public boolean hasNext() { if (!this.locked) this.applyStrategies(); return this.lastTraverser.bulk() > 0L || this.finalEndStep.hasNext(); }
@Override public Traverser.Admin<E> nextTraverser() { try { if (!this.locked) this.applyStrategies(); if (this.lastTraverser.bulk() > 0L) { final Traverser.Admin<E> temp = this.lastTraverser; this.lastTraverser = EmptyTraverser.instance(); return temp; } else { return this.finalEndStep.next(); } } catch (final FastNoSuchElementException e) { throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; } }
@Override public E next() { try { if (!this.locked) this.applyStrategies(); if (this.lastTraverser.bulk() == 0L) this.lastTraverser = this.finalEndStep.next(); this.lastTraverser.setBulk(this.lastTraverser.bulk() - 1L); return this.lastTraverser.get(); } catch (final FastNoSuchElementException e) { throw this.parent instanceof EmptyStep ? new NoSuchElementException() : e; } }
@Override public void applyStrategies() throws IllegalStateException { try { assert 0 == this.getSteps().size(); final ScriptEngine engine = SingleGremlinScriptEngineManager.get(this.scriptEngine); final Bindings engineBindings = engine.createBindings(); final List<TraversalStrategy<?>> strategyList = this.getStrategies().toList(); engineBindings.put(this.alias, this.factory.createTraversalSource(this.graph).withStrategies(strategyList.toArray(new TraversalStrategy[strategyList.size()]))); engineBindings.put("graph", this.graph); // TODO: we don't need this as the traversalSource.getGraph() exists, but its now here and people might be using it (remove in 3.3.0) for (int i = 0; i < this.bindings.length; i = i + 2) { engineBindings.put((String) this.bindings[i], this.bindings[i + 1]); } final Traversal.Admin<S, E> traversal = (Traversal.Admin<S, E>) engine.eval(this.script, engineBindings); traversal.getSideEffects().mergeInto(this.sideEffects); traversal.getSteps().forEach(this::addStep); this.strategies = traversal.getStrategies(); super.applyStrategies(); } catch (final ScriptException e) { throw new IllegalStateException(e.getMessage(), e); } } }
this.result = result; super.applyStrategies(); } catch (ScriptException e) { throw new IllegalStateException(e.getMessage(), e);