You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/03/19 19:26:51 UTC
[33/40] incubator-tinkerpop git commit: the traversal steps provided
by TinkerPop are the foundation for all dsl. GraphTraversal is just a dsl of
traversal. Refactored the process API to reflect this concept. Fixed #592.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroupSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroupSideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroupSideEffectStep.java
deleted file mode 100644
index f135484..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/GroupSideEffectStep.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.TraversalEngine;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
-import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.VertexTraversalSideEffects;
-import org.apache.tinkerpop.gremlin.process.graph.traversal.step.SideEffectCapable;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalMatrix;
-import org.apache.tinkerpop.gremlin.process.traversal.step.EngineDependent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.MapReducer;
-import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.util.BulkSet;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.util.function.HashMapSupplier;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class GroupSideEffectStep<S, K, V, R> extends SideEffectStep<S> implements SideEffectCapable, TraversalParent, EngineDependent, MapReducer<K, Collection<V>, K, R, Map<K, R>> {
-
- private char state = 'k';
- private Traversal.Admin<S, K> keyTraversal = null;
- private Traversal.Admin<S, V> valueTraversal = null;
- private Traversal.Admin<Collection<V>, R> reduceTraversal = null;
- private String sideEffectKey;
- private boolean onGraphComputer = false;
- private Map<K, Collection<V>> tempGroupByMap;
-
- public GroupSideEffectStep(final Traversal.Admin traversal, final String sideEffectKey) {
- super(traversal);
- this.sideEffectKey = sideEffectKey;
- this.traversal.asAdmin().getSideEffects().registerSupplierIfAbsent(this.sideEffectKey, HashMapSupplier.instance());
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- final Map<K, Collection<V>> groupMap = null == this.tempGroupByMap ? traverser.sideEffects(this.sideEffectKey) : this.tempGroupByMap; // for nested traversals and not !starts.hasNext()
- final K key = TraversalUtil.applyNullable(traverser, keyTraversal);
- final V value = TraversalUtil.applyNullable(traverser, valueTraversal);
- Collection<V> values = groupMap.get(key);
- if (null == values) {
- values = new BulkSet<>();
- groupMap.put(key, values);
- }
- TraversalHelper.addToCollectionUnrollIterator(values, value, traverser.bulk());
- //////// reducer for OLTP
- if (!this.onGraphComputer && null != this.reduceTraversal && !this.starts.hasNext()) {
- this.tempGroupByMap = groupMap;
- final Map<K, R> reduceMap = new HashMap<>();
- groupMap.forEach((k, vv) -> reduceMap.put(k, TraversalUtil.applyNullable(vv, this.reduceTraversal)));
- traverser.sideEffects(this.sideEffectKey, reduceMap);
- }
- }
-
- @Override
- public String getSideEffectKey() {
- return this.sideEffectKey;
- }
-
- @Override
- public void onEngine(final TraversalEngine traversalEngine) {
- this.onGraphComputer = traversalEngine.isComputer();
- }
-
- @Override
- public MapReduce<K, Collection<V>, K, R, Map<K, R>> getMapReduce() {
- return new GroupSideEffectMapReduce<>(this);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKey, this.keyTraversal, this.valueTraversal, this.reduceTraversal);
- }
-
- @Override
- public <A, B> List<Traversal.Admin<A, B>> getLocalChildren() {
- final List<Traversal.Admin<A, B>> children = new ArrayList<>(3);
- if (null != this.keyTraversal)
- children.add((Traversal.Admin) this.keyTraversal);
- if (null != this.valueTraversal)
- children.add((Traversal.Admin) this.valueTraversal);
- if (null != this.reduceTraversal)
- children.add((Traversal.Admin) this.reduceTraversal);
- return children;
- }
-
- public Traversal.Admin<Collection<V>, R> getReduceTraversal() {
- return this.reduceTraversal;
- }
-
- @Override
- public void addLocalChild(final Traversal.Admin<?, ?> kvrTraversal) {
- if ('k' == this.state) {
- this.keyTraversal = this.integrateChild(kvrTraversal);
- this.state = 'v';
- } else if ('v' == this.state) {
- this.valueTraversal = this.integrateChild(kvrTraversal);
- this.state = 'r';
- } else if ('r' == this.state) {
- this.reduceTraversal = this.integrateChild(kvrTraversal);
- this.state = 'x';
- } else {
- throw new IllegalStateException("The key, value, and reduce functions for group()-step have already been set");
- }
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.SIDE_EFFECTS, TraverserRequirement.BULK);
- }
-
- @Override
- public GroupSideEffectStep<S, K, V, R> clone() {
- final GroupSideEffectStep<S, K, V, R> clone = (GroupSideEffectStep<S, K, V, R>) super.clone();
- if (null != this.keyTraversal)
- clone.keyTraversal = clone.integrateChild(this.keyTraversal.clone());
- if (null != this.valueTraversal)
- clone.valueTraversal = clone.integrateChild(this.valueTraversal.clone());
- if (null != this.reduceTraversal)
- clone.reduceTraversal = clone.integrateChild(this.reduceTraversal.clone());
- return clone;
- }
-
- ///////////
-
- public static final class GroupSideEffectMapReduce<K, V, R> implements MapReduce<K, Collection<V>, K, R, Map<K, R>> {
-
- public static final String GROUP_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY = "gremlin.groupSideEffectStep.sideEffectKey";
- public static final String GROUP_SIDE_EFFECT_STEP_STEP_ID = "gremlin.groupSideEffectStep.stepId";
-
- private String sideEffectKey;
- private String groupStepId;
- private Traversal.Admin<Collection<V>, R> reduceTraversal;
- private Supplier<Map<K, R>> mapSupplier;
-
- private GroupSideEffectMapReduce() {
-
- }
-
- public GroupSideEffectMapReduce(final GroupSideEffectStep step) {
- this.groupStepId = step.getId();
- this.sideEffectKey = step.getSideEffectKey();
- this.reduceTraversal = step.getReduceTraversal();
- this.mapSupplier = step.getTraversal().asAdmin().getSideEffects().<Map<K, R>>getRegisteredSupplier(this.sideEffectKey).orElse(HashMap::new);
- }
-
- @Override
- public void storeState(final Configuration configuration) {
- MapReduce.super.storeState(configuration);
- configuration.setProperty(GROUP_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY, this.sideEffectKey);
- configuration.setProperty(GROUP_SIDE_EFFECT_STEP_STEP_ID, this.groupStepId);
- }
-
- @Override
- public void loadState(final Configuration configuration) {
- this.sideEffectKey = configuration.getString(GROUP_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY);
- this.groupStepId = configuration.getString(GROUP_SIDE_EFFECT_STEP_STEP_ID);
- final Traversal.Admin<?, ?> traversal = TraversalVertexProgram.getTraversalSupplier(configuration).get();
- if (!traversal.isLocked())
- traversal.applyStrategies(); // TODO: this is a scary error prone requirement, but only a problem for GroupStep
- final GroupSideEffectStep groupSideEffectStep = new TraversalMatrix<>(traversal).getStepById(this.groupStepId);
- this.reduceTraversal = groupSideEffectStep.getReduceTraversal();
- this.mapSupplier = traversal.getSideEffects().<Map<K, R>>getRegisteredSupplier(this.sideEffectKey).orElse(HashMap::new);
- }
-
- @Override
- public boolean doStage(final Stage stage) {
- return !stage.equals(Stage.COMBINE);
- }
-
- @Override
- public void map(final Vertex vertex, final MapEmitter<K, Collection<V>> emitter) {
- VertexTraversalSideEffects.of(vertex).<Map<K, Collection<V>>>orElse(this.sideEffectKey, Collections.emptyMap()).forEach(emitter::emit);
- }
-
- @Override
- public void reduce(final K key, final Iterator<Collection<V>> values, final ReduceEmitter<K, R> emitter) {
- final Set<V> set = new BulkSet<>();
- values.forEachRemaining(set::addAll);
- emitter.emit(key, TraversalUtil.applyNullable(set, this.reduceTraversal));
- }
-
- @Override
- public Map<K, R> generateFinalResult(final Iterator<KeyValue<K, R>> keyValues) {
- final Map<K, R> map = this.mapSupplier.get();
- keyValues.forEachRemaining(keyValue -> map.put(keyValue.getKey(), keyValue.getValue()));
- return map;
- }
-
- @Override
- public String getMemoryKey() {
- return this.sideEffectKey;
- }
-
- @Override
- public GroupSideEffectMapReduce<K, V, R> clone() {
- try {
- final GroupSideEffectMapReduce<K, V, R> clone = (GroupSideEffectMapReduce<K, V, R>) super.clone();
- if (null != clone.reduceTraversal)
- clone.reduceTraversal = this.reduceTraversal.clone();
- return clone;
- } catch (final CloneNotSupportedException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- @Override
- public String toString() {
- return StringFactory.mapReduceString(this, this.getMemoryKey());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/IdentityStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/IdentityStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/IdentityStep.java
deleted file mode 100644
index d572bc2..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/IdentityStep.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-import java.util.NoSuchElementException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class IdentityStep<S> extends AbstractStep<S, S> {
-
- public IdentityStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- return this.starts.next();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/InjectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/InjectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/InjectStep.java
deleted file mode 100644
index 2b4a927..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/InjectStep.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class InjectStep<S> extends StartStep<S> {
-
- private final S[] injections;
-
- @SafeVarargs
- public InjectStep(final Traversal.Admin traversal, final S... injections) {
- super(traversal);
- this.injections = injections;
- this.start = new ArrayIterator<>(this.injections);
- }
-
- @Override
- public InjectStep<S> clone() {
- final InjectStep<S> clone = (InjectStep<S>) super.clone();
- clone.start = new ArrayIterator<>(clone.injections);
- return clone;
- }
-
- @Override
- public void reset() {
- super.reset();
- this.start = new ArrayIterator<>(this.injections);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/LambdaSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/LambdaSideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/LambdaSideEffectStep.java
deleted file mode 100644
index 556d8ca..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/LambdaSideEffectStep.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.function.Consumer;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class LambdaSideEffectStep<S> extends SideEffectStep<S> {
-
- private final Consumer<Traverser<S>> consumer;
-
- public LambdaSideEffectStep(final Traversal.Admin traversal, final Consumer<Traverser<S>> consumer) {
- super(traversal);
- this.consumer = consumer;
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- this.consumer.accept(traverser);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.consumer);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/ProfileStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/ProfileStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/ProfileStep.java
deleted file mode 100644
index 6f811d7..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/ProfileStep.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Step;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
-import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.VertexTraversalSideEffects;
-import org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.EmptyStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.MapReducer;
-import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.util.metric.DependantMutableMetrics;
-import org.apache.tinkerpop.gremlin.process.util.metric.MutableMetrics;
-import org.apache.tinkerpop.gremlin.process.util.metric.StandardTraversalMetrics;
-import org.apache.tinkerpop.gremlin.process.util.metric.TraversalMetrics;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * @author Bob Briody (http://bobbriody.com)
- */
-public final class ProfileStep<S> extends AbstractStep<S, S> implements MapReducer<MapReduce.NullObject, StandardTraversalMetrics, MapReduce.NullObject, StandardTraversalMetrics, StandardTraversalMetrics> {
-
- // Stored in the Traversal sideEffects but kept here as a reference for convenience.
- private StandardTraversalMetrics traversalMetrics;
-
- public ProfileStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
-
- @Override
- public MapReduce<MapReduce.NullObject, StandardTraversalMetrics, MapReduce.NullObject, StandardTraversalMetrics, StandardTraversalMetrics> getMapReduce() {
- return ProfileMapReduce.instance();
- }
-
- @Override
- public Traverser<S> next() {
- Traverser<S> ret = null;
- initializeIfNeeded();
- traversalMetrics.start(this.getId());
- try {
- ret = super.next();
- return ret;
- } finally {
- if (ret != null) {
- traversalMetrics.finish(this.getId(), ret.asAdmin().bulk());
- } else {
- traversalMetrics.stop(this.getId());
- }
- }
- }
-
- @Override
- public boolean hasNext() {
- initializeIfNeeded();
- traversalMetrics.start(this.getId());
- boolean ret = super.hasNext();
- traversalMetrics.stop(this.getId());
- return ret;
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- return this.starts.next();
- }
-
- private void initializeIfNeeded() {
- if (traversalMetrics != null) {
- return;
- }
-
- createTraversalMetricsSideEffectIfNecessary();
-
- // How can traversalMetrics still be null? When running on computer it may need to be re-initialized from
- // sideEffects after serialization.
- if (traversalMetrics == null) {
- // look up the TraversalMetrics in the root traversal's sideEffects
- Traversal t = this.getTraversal();
- while (!(t.asAdmin().getParent() instanceof EmptyStep)) {
- t = t.asAdmin().getParent().asStep().getTraversal();
- }
- traversalMetrics = t.asAdmin().getSideEffects().get(TraversalMetrics.METRICS_KEY);
- }
- }
-
- private void createTraversalMetricsSideEffectIfNecessary() {
- if (this.getTraversal().getSideEffects().exists(TraversalMetrics.METRICS_KEY)) {
- // Already initialized
- return;
- }
-
- if (!(this.getTraversal().getParent() instanceof EmptyStep)) {
- // Initialization is handled at the top-level of the traversal only.
- return;
- }
-
- // The following code is executed once per top-level (non-nested) Traversal for all Profile steps. (Technically,
- // once per thread if using Computer.)
-
- traversalMetrics = this.getTraversal().getSideEffects().getOrCreate(TraversalMetrics.METRICS_KEY, StandardTraversalMetrics::new);
- prepTraversalForProfiling(this.getTraversal().asAdmin(), null);
- }
-
- // Walk the traversal steps and initialize the Metrics timers.
- private void prepTraversalForProfiling(Traversal.Admin<?, ?> traversal, MutableMetrics parentMetrics) {
-
- DependantMutableMetrics prevMetrics = null;
- final List<Step> steps = traversal.getSteps();
- for (int ii = 0; ii + 1 < steps.size(); ii = ii + 2) {
- Step step = steps.get(ii);
- ProfileStep profileStep = (ProfileStep) steps.get(ii + 1);
-
- // Create metrics
- MutableMetrics metrics;
-
- // Computer metrics are "stand-alone" but Standard metrics handle double-counted upstream time.
- if (traversal.getEngine().isComputer()) {
- metrics = new MutableMetrics(step.getId(), step.toString());
- } else {
- metrics = new DependantMutableMetrics(step.getId(), step.toString(), prevMetrics);
- prevMetrics = (DependantMutableMetrics) metrics;
- }
-
- // Initialize counters (necessary because some steps might end up being 0)
- metrics.incrementCount(TraversalMetrics.ELEMENT_COUNT_ID, 0);
- metrics.incrementCount(TraversalMetrics.TRAVERSER_COUNT_ID, 0);
-
- // Add metrics to parent, if necessary
- if (parentMetrics != null) {
- parentMetrics.addNested(metrics);
- }
-
- // The TraversalMetrics sideEffect is shared across all the steps.
- profileStep.traversalMetrics = this.traversalMetrics;
-
- // Add root metrics to traversalMetrics
- this.traversalMetrics.addMetrics(metrics, step.getId(), ii / 2, parentMetrics == null, profileStep.getId());
-
- // Handle nested traversal
- if (step instanceof TraversalParent) {
- for (Traversal.Admin<?, ?> t : ((TraversalParent) step).getLocalChildren()) {
- prepTraversalForProfiling(t, metrics);
- }
- for (Traversal.Admin<?, ?> t : ((TraversalParent) step).getGlobalChildren()) {
- prepTraversalForProfiling(t, metrics);
- }
- }
- }
- }
-
- //////////////////
-
- public static final class ProfileMapReduce extends StaticMapReduce<MapReduce.NullObject, StandardTraversalMetrics, MapReduce.NullObject, StandardTraversalMetrics, StandardTraversalMetrics> {
-
- private static ProfileMapReduce INSTANCE = new ProfileMapReduce();
-
- private ProfileMapReduce() {
-
- }
-
- @Override
- public boolean doStage(final Stage stage) {
- return true;
- }
-
- @Override
- public String getMemoryKey() {
- return TraversalMetrics.METRICS_KEY;
- }
-
- @Override
- public void map(final Vertex vertex, final MapEmitter<NullObject, StandardTraversalMetrics> emitter) {
- VertexTraversalSideEffects.of(vertex).<StandardTraversalMetrics>ifPresent(TraversalMetrics.METRICS_KEY, emitter::emit);
- }
-
- @Override
- public void combine(final NullObject key, final Iterator<StandardTraversalMetrics> values, final ReduceEmitter<NullObject, StandardTraversalMetrics> emitter) {
- reduce(key, values, emitter);
- }
-
- @Override
- public void reduce(final NullObject key, final Iterator<StandardTraversalMetrics> values, final ReduceEmitter<NullObject, StandardTraversalMetrics> emitter) {
- emitter.emit(StandardTraversalMetrics.merge(values));
- }
-
- @Override
- public StandardTraversalMetrics generateFinalResult(final Iterator<KeyValue<NullObject, StandardTraversalMetrics>> keyValues) {
- return keyValues.next().getValue();
- }
-
- public static ProfileMapReduce instance() {
- return INSTANCE;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackElementValueStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackElementValueStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackElementValueStep.java
deleted file mode 100644
index 57ba41c..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackElementValueStep.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Element;
-
-import java.util.EnumSet;
-import java.util.Set;
-import java.util.function.BinaryOperator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SackElementValueStep<S extends Element, V> extends SideEffectStep<S> {
-
- private static final Set<TraverserRequirement> REQUIREMENTS = EnumSet.of(
- TraverserRequirement.SACK,
- TraverserRequirement.OBJECT
- );
-
- private BinaryOperator<V> operator;
- private final String propertyKey;
-
- public SackElementValueStep(final Traversal.Admin traversal, final BinaryOperator<V> operator, final String propertyKey) {
- super(traversal);
- this.operator = operator;
- this.propertyKey = propertyKey;
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- traverser.get().values(this.propertyKey).forEachRemaining(value -> {
- traverser.sack(this.operator.apply(traverser.sack(), (V) value));
- });
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.operator, this.propertyKey);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return REQUIREMENTS;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackObjectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackObjectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackObjectStep.java
deleted file mode 100644
index 3df89e8..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SackObjectStep.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.EnumSet;
-import java.util.Set;
-import java.util.function.BiFunction;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SackObjectStep<S, V> extends SideEffectStep<S> {
-
- private static final Set<TraverserRequirement> REQUIREMENTS = EnumSet.of(
- TraverserRequirement.SACK,
- TraverserRequirement.OBJECT
- );
-
- private final BiFunction<V, S, V> operator;
-
- public SackObjectStep(final Traversal.Admin traversal, final BiFunction<V, S, V> operator) {
- super(traversal);
- this.operator = operator;
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- traverser.sack(this.operator.apply(traverser.sack(), traverser.get()));
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return REQUIREMENTS;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectCapStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectCapStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectCapStep.java
deleted file mode 100644
index 800aa58..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectCapStep.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.graph.traversal.step.util.SupplyingBarrierStep;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SideEffectCapStep<S, E> extends SupplyingBarrierStep<S, E> {
-
- private static final Set<TraverserRequirement> REQUIREMENTS = EnumSet.of(
- TraverserRequirement.SIDE_EFFECTS,
- TraverserRequirement.OBJECT
- );
-
- private List<String> sideEffectKeys;
-
- public SideEffectCapStep(final Traversal.Admin traversal, final String... sideEffectKeys) {
- super(traversal);
- if (0 == sideEffectKeys.length)
- throw new IllegalArgumentException("At least one sideEffect key must be provided to " + this.getClass().getSimpleName());
- this.sideEffectKeys = Arrays.asList(sideEffectKeys);
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKeys);
- }
-
- public List<String> getSideEffectKeys() {
- return this.sideEffectKeys;
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return REQUIREMENTS;
- }
-
- @Override
- public E supply() {
- return this.sideEffectKeys.size() == 1 ?
- this.getTraversal().asAdmin().getSideEffects().get(this.sideEffectKeys.get(0)) :
- (E) this.getMapOfSideEffects();
- }
-
- public Map<String, Object> getMapOfSideEffects() {
- final Map<String, Object> sideEffects = new HashMap<>();
- for (final String sideEffectKey : this.sideEffectKeys) {
- sideEffects.put(sideEffectKey, this.getTraversal().asAdmin().getSideEffects().get(sideEffectKey));
- }
- return sideEffects;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectStep.java
deleted file mode 100644
index 3ec2aa1..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SideEffectStep.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class SideEffectStep<S> extends AbstractStep<S, S> {
-
- public SideEffectStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- protected abstract void sideEffect(final Traverser.Admin<S> traverser);
-
- @Override
- protected Traverser<S> processNextStart() {
- final Traverser.Admin<S> traverser = this.starts.next();
- this.sideEffect(traverser);
- return traverser;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StartStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StartStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StartStep.java
deleted file mode 100644
index e56a7e7..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StartStep.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Iterator;
-import java.util.stream.Stream;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class StartStep<S> extends AbstractStep<S, S> {
-
- protected Object start;
- protected boolean first = true;
-
- public StartStep(final Traversal.Admin traversal, final Object start) {
- super(traversal);
- this.start = start;
- }
-
- public StartStep(final Traversal.Admin traversal) {
- this(traversal, null);
- }
-
- public <T> T getStart() {
- return (T) this.start;
- }
-
- public boolean startAssignableTo(final Class... assignableClasses) {
- return Stream.of(assignableClasses).filter(check -> check.isAssignableFrom(this.start.getClass())).findAny().isPresent();
- }
-
- public String toString() {
- return TraversalHelper.makeStepString(this, this.start);
- }
-
- @Override
- protected Traverser<S> processNextStart() {
- if (this.first) {
- if (null != this.start) {
- if (this.start instanceof Iterator)
- this.starts.add(this.getTraversal().getTraverserGenerator().generateIterator((Iterator<S>) this.start, this, 1l));
- else
- this.starts.add(this.getTraversal().getTraverserGenerator().generate((S) this.start, this, 1l));
- }
- this.first = false;
- }
- return this.starts.next();
- }
-
- @Override
- public StartStep<S> clone() {
- final StartStep<S> clone = (StartStep<S>) super.clone();
- clone.first = true;
- clone.start = null;
- return clone;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StoreStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StoreStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StoreStep.java
deleted file mode 100644
index 71cc96c..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/StoreStep.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
-import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.VertexTraversalSideEffects;
-import org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce;
-import org.apache.tinkerpop.gremlin.process.graph.traversal.step.SideEffectCapable;
-import org.apache.tinkerpop.gremlin.process.traversal.step.MapReducer;
-import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.util.BulkSet;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.util.function.BulkSetSupplier;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class StoreStep<S> extends SideEffectStep<S> implements SideEffectCapable, TraversalParent, MapReducer<MapReduce.NullObject, Object, MapReduce.NullObject, Object, Collection> {
-
- private Traversal.Admin<S, Object> storeTraversal = null;
- private String sideEffectKey;
-
- public StoreStep(final Traversal.Admin traversal, final String sideEffectKey) {
- super(traversal);
- this.sideEffectKey = sideEffectKey;
- this.traversal.asAdmin().getSideEffects().registerSupplierIfAbsent(this.sideEffectKey, BulkSetSupplier.instance());
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- TraversalHelper.addToCollection(
- traverser.sideEffects(this.sideEffectKey),
- TraversalUtil.applyNullable(traverser.asAdmin(), this.storeTraversal),
- traverser.bulk());
- }
-
- @Override
- public String getSideEffectKey() {
- return this.sideEffectKey;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKey, this.storeTraversal);
- }
-
- @Override
- public MapReduce<MapReduce.NullObject, Object, MapReduce.NullObject, Object, Collection> getMapReduce() {
- return new StoreMapReduce(this);
- }
-
- @Override
- public List<Traversal.Admin<S, Object>> getLocalChildren() {
- return null == this.storeTraversal ? Collections.emptyList() : Collections.singletonList(this.storeTraversal);
- }
-
- @Override
- public void addLocalChild(final Traversal.Admin<?, ?> storeTraversal) {
- this.storeTraversal = this.integrateChild(storeTraversal);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.SIDE_EFFECTS, TraverserRequirement.BULK);
- }
-
- @Override
- public StoreStep<S> clone() {
- final StoreStep<S> clone = (StoreStep<S>) super.clone();
- if (null != this.storeTraversal)
- clone.storeTraversal = clone.integrateChild(this.storeTraversal.clone());
- return clone;
- }
-
- ///////////////
-
- public static final class StoreMapReduce extends StaticMapReduce<MapReduce.NullObject, Object, MapReduce.NullObject, Object, Collection> {
-
- public static final String STORE_STEP_SIDE_EFFECT_KEY = "gremlin.storeStep.sideEffectKey";
-
- private String sideEffectKey;
- private Supplier<Collection> collectionSupplier;
-
- private StoreMapReduce() {
-
- }
-
- public StoreMapReduce(final StoreStep step) {
- this.sideEffectKey = step.getSideEffectKey();
- this.collectionSupplier = step.getTraversal().asAdmin().getSideEffects().<Collection>getRegisteredSupplier(this.sideEffectKey).orElse(BulkSet::new);
- }
-
- @Override
- public void storeState(final Configuration configuration) {
- super.storeState(configuration);
- configuration.setProperty(STORE_STEP_SIDE_EFFECT_KEY, this.sideEffectKey);
- }
-
- @Override
- public void loadState(final Configuration configuration) {
- this.sideEffectKey = configuration.getString(STORE_STEP_SIDE_EFFECT_KEY);
- this.collectionSupplier = TraversalVertexProgram.getTraversalSupplier(configuration).get().getSideEffects().<Collection>getRegisteredSupplier(this.sideEffectKey).orElse(BulkSet::new);
- }
-
- @Override
- public boolean doStage(final Stage stage) {
- return stage.equals(Stage.MAP);
- }
-
- @Override
- public void map(final Vertex vertex, final MapEmitter<NullObject, Object> emitter) {
- VertexTraversalSideEffects.of(vertex).<Collection<?>>orElse(this.sideEffectKey, Collections.emptyList()).forEach(emitter::emit);
- }
-
- @Override
- public Collection generateFinalResult(final Iterator<KeyValue<NullObject, Object>> keyValues) {
- final Collection collection = this.collectionSupplier.get();
- keyValues.forEachRemaining(pair -> collection.add(pair.getValue()));
- return collection;
- }
-
- @Override
- public String getMemoryKey() {
- return this.sideEffectKey;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SubgraphStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SubgraphStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SubgraphStep.java
deleted file mode 100644
index 5d3b7b3..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/SubgraphStep.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.tinkerpop.gremlin.process.T;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.graph.traversal.step.SideEffectCapable;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A side-effect step that produces an edge induced subgraph.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class SubgraphStep extends SideEffectStep<Edge> implements SideEffectCapable {
-
- private static final Set<TraverserRequirement> REQUIREMENTS = EnumSet.of(
- TraverserRequirement.OBJECT,
- TraverserRequirement.SIDE_EFFECTS
- );
-
- private Graph subgraph;
- private String sideEffectKey;
-
- private static final Map<String, Object> DEFAULT_CONFIGURATION = new HashMap<String, Object>() {{
- put(Graph.GRAPH, "org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph"); // hard coded because TinkerGraph is not part of gremlin-core
- }};
-
- // TODO: add support for side-effecting out an edge list.
-
- public SubgraphStep(final Traversal.Admin traversal, final String sideEffectKey) {
- super(traversal);
- this.sideEffectKey = sideEffectKey;
- this.getTraversal().asAdmin().getSideEffects().registerSupplierIfAbsent(this.sideEffectKey, () -> GraphFactory.open(DEFAULT_CONFIGURATION));
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<Edge> traverser) {
- if (null == this.subgraph) {
- this.subgraph = traverser.sideEffects(this.sideEffectKey);
- if (!this.subgraph.features().vertex().supportsUserSuppliedIds() || !this.subgraph.features().edge().supportsUserSuppliedIds())
- throw new IllegalArgumentException("The provided subgraph must support user supplied ids for vertices and edges: " + this.subgraph);
- }
- SubgraphStep.addEdgeToSubgraph(this.subgraph, traverser.get());
- }
-
- @Override
- public String getSideEffectKey() {
- return this.sideEffectKey;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKey);
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return REQUIREMENTS;
- }
-
- @Override
- public SubgraphStep clone() {
- final SubgraphStep clone = (SubgraphStep) super.clone();
- this.subgraph = null;
- return clone;
- }
-
- ///
-
- private static Vertex getOrCreate(final Graph subgraph, final Vertex vertex) {
- final Iterator<Vertex> vertexIterator = subgraph.vertices(vertex.id());
- if (vertexIterator.hasNext()) return vertexIterator.next();
- final Vertex subgraphVertex = subgraph.addVertex(T.id, vertex.id(), T.label, vertex.label());
- vertex.properties().forEachRemaining(vertexProperty -> {
- final VertexProperty<?> subgraphVertexProperty = subgraphVertex.property(vertexProperty.key(), vertexProperty.value(), T.id, vertexProperty.id()); // TODO: demand vertex property id?
- vertexProperty.properties().forEachRemaining(property -> subgraphVertexProperty.<Object>property(property.key(), property.value()));
- });
- return subgraphVertex;
- }
-
- private static void addEdgeToSubgraph(final Graph subgraph, final Edge edge) {
- final Iterator<Edge> edgeIterator = subgraph.edges(edge.id());
- if (edgeIterator.hasNext()) return;
- final Iterator<Vertex> vertexIterator = edge.vertices(Direction.BOTH);
- final Vertex subGraphOutVertex = getOrCreate(subgraph, vertexIterator.next());
- final Vertex subGraphInVertex = getOrCreate(subgraph, vertexIterator.next());
- final Edge subGraphEdge = subGraphOutVertex.addEdge(edge.label(), subGraphInVertex, T.id, edge.id());
- edge.properties().forEachRemaining(property -> subGraphEdge.<Object>property(property.key(), property.value()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/TreeSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/TreeSideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/TreeSideEffectStep.java
deleted file mode 100644
index fbb3425..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/sideEffect/TreeSideEffectStep.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.sideEffect;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.Path;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
-import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.VertexTraversalSideEffects;
-import org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce;
-import org.apache.tinkerpop.gremlin.process.graph.traversal.step.SideEffectCapable;
-import org.apache.tinkerpop.gremlin.process.graph.util.Tree;
-import org.apache.tinkerpop.gremlin.process.traversal.step.MapReducer;
-import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalRing;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.util.function.TreeSupplier;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class TreeSideEffectStep<S> extends SideEffectStep<S> implements SideEffectCapable, TraversalParent, MapReducer<Object, Tree, Object, Tree, Tree> {
-
- private TraversalRing<Object, Object> traversalRing;
- private String sideEffectKey;
-
- public TreeSideEffectStep(final Traversal.Admin traversal, final String sideEffectKey) {
- super(traversal);
- this.sideEffectKey = sideEffectKey;
- this.traversalRing = new TraversalRing<>();
- this.traversal.asAdmin().getSideEffects().registerSupplierIfAbsent(this.sideEffectKey, TreeSupplier.instance());
- }
-
- @Override
- protected void sideEffect(final Traverser.Admin<S> traverser) {
- Tree depth = traverser.sideEffects(this.sideEffectKey);
- final Path path = traverser.path();
- for (int i = 0; i < path.size(); i++) {
- final Object object = TraversalUtil.apply(path.<Object>get(i), this.traversalRing.next());
- if (!depth.containsKey(object))
- depth.put(object, new Tree<>());
- depth = (Tree) depth.get(object);
- }
- this.traversalRing.reset();
- }
-
- @Override
- public String getSideEffectKey() {
- return this.sideEffectKey;
- }
-
- @Override
- public MapReduce<Object, Tree, Object, Tree, Tree> getMapReduce() {
- return new TreeSideEffectMapReduce(this);
- }
-
- @Override
- public void reset() {
- super.reset();
- this.traversalRing.reset();
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this, this.sideEffectKey, this.traversalRing);
- }
-
- @Override
- public TreeSideEffectStep<S> clone() {
- final TreeSideEffectStep<S> clone = (TreeSideEffectStep<S>) super.clone();
- clone.traversalRing = new TraversalRing<>();
- for (final Traversal.Admin<Object, Object> traversal : this.traversalRing.getTraversals()) {
- clone.traversalRing.addTraversal(clone.integrateChild(traversal.clone()));
- }
- return clone;
- }
-
- @Override
- public List<Traversal.Admin<Object, Object>> getLocalChildren() {
- return this.traversalRing.getTraversals();
- }
-
- @Override
- public void addLocalChild(final Traversal.Admin<?, ?> treeTraversal) {
- this.traversalRing.addTraversal(this.integrateChild(treeTraversal));
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return this.getSelfAndChildRequirements(TraverserRequirement.PATH, TraverserRequirement.SIDE_EFFECTS);
- }
-
- ////////////////
-
- public static final class TreeSideEffectMapReduce extends StaticMapReduce<Object, Tree, Object, Tree, Tree> {
-
- public static final String TREE_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY = "gremlin.treeSideEffectStep.sideEffectKey";
-
- private String sideEffectKey;
-
- private TreeSideEffectMapReduce() {
-
- }
-
- public TreeSideEffectMapReduce(final TreeSideEffectStep step) {
- this.sideEffectKey = step.getSideEffectKey();
- }
-
- @Override
- public void storeState(final Configuration configuration) {
- super.storeState(configuration);
- configuration.setProperty(TREE_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY, this.sideEffectKey);
- }
-
- @Override
- public void loadState(final Configuration configuration) {
- this.sideEffectKey = configuration.getString(TREE_SIDE_EFFECT_STEP_SIDE_EFFECT_KEY);
- }
-
- @Override
- public boolean doStage(final Stage stage) {
- return stage.equals(Stage.MAP);
- }
-
- @Override
- public void map(final Vertex vertex, final MapEmitter<Object, Tree> emitter) {
- VertexTraversalSideEffects.of(vertex).<Tree<?>>ifPresent(this.sideEffectKey, tree -> tree.splitParents().forEach(branches -> emitter.emit(branches.keySet().iterator().next(), branches)));
- }
-
- /*
- @Override
- public void combine(final NullObject key, final Iterator<Tree> values, final ReduceEmitter<NullObject, Tree> emitter) {
- this.reduce(key, values, emitter);
- }
-
- @Override
- public void reduce(final NullObject key, final Iterator<Tree> values, final ReduceEmitter<NullObject, Tree> emitter) {
- final Tree tree = new Tree();
- values.forEachRemaining(tree::addTree);
- emitter.emit(tree);
- }
- */
-
- @Override
- public Tree generateFinalResult(final Iterator<KeyValue<Object, Tree>> keyValues) {
- final Tree result = new Tree();
- keyValues.forEachRemaining(keyValue -> result.addTree(keyValue.getValue()));
- return result;
- }
-
- @Override
- public String getMemoryKey() {
- return this.sideEffectKey;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/CollectingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/CollectingBarrierStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/CollectingBarrierStep.java
deleted file mode 100644
index 9b401c4..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/CollectingBarrierStep.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.util.TraverserSet;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class CollectingBarrierStep<S> extends AbstractStep<S, S> {
- private TraverserSet<S> traverserSet = new TraverserSet<>();
-
- public CollectingBarrierStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- public abstract void barrierConsumer(final TraverserSet<S> traverserSet);
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.BULK);
- }
-
- @Override
- public Traverser<S> processNextStart() {
- if (this.starts.hasNext()) {
- this.starts.forEachRemaining(this.traverserSet::add);
- this.barrierConsumer(this.traverserSet);
- }
- return this.traverserSet.remove();
- }
-
- @Override
- public CollectingBarrierStep<S> clone() {
- final CollectingBarrierStep<S> clone = (CollectingBarrierStep<S>) super.clone();
- clone.traverserSet = new TraverserSet<>();
- return clone;
- }
-
- @Override
- public void reset() {
- super.reset();
- this.traverserSet.clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ComputerAwareStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ComputerAwareStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ComputerAwareStep.java
deleted file mode 100644
index 01ecfe0..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ComputerAwareStep.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.TraversalEngine;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.EngineDependent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class ComputerAwareStep<S, E> extends AbstractStep<S, E> implements EngineDependent {
-
- private Iterator<Traverser<E>> previousIterator = EmptyIterator.instance();
-
- public ComputerAwareStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<E> processNextStart() throws NoSuchElementException {
- while (true) {
- if (this.previousIterator.hasNext())
- return this.previousIterator.next();
- this.previousIterator = this.traverserStepIdSetByChild ? this.computerAlgorithm() : this.standardAlgorithm();
- }
- }
-
- @Override
- public void onEngine(final TraversalEngine engine) {
- this.traverserStepIdSetByChild = engine.isComputer();
- }
-
- @Override
- public ComputerAwareStep<S, E> clone() {
- final ComputerAwareStep<S, E> clone = (ComputerAwareStep<S, E>) super.clone();
- clone.previousIterator = Collections.emptyIterator();
- return clone;
- }
-
- protected abstract Iterator<Traverser<E>> standardAlgorithm() throws NoSuchElementException;
-
- protected abstract Iterator<Traverser<E>> computerAlgorithm() throws NoSuchElementException;
-
- //////
-
- public class EndStep extends AbstractStep<S, S> implements EngineDependent {
-
- public EndStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- final Traverser.Admin<S> start = this.starts.next();
- if (this.traverserStepIdSetByChild) start.setStepId(ComputerAwareStep.this.getNextStep().getId());
- return start;
- }
-
- @Override
- public String toString() {
- return TraversalHelper.makeStepString(this);
- }
-
- @Override
- public void onEngine(final TraversalEngine engine) {
- this.traverserStepIdSetByChild = engine.isComputer();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/MarkerIdentityStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/MarkerIdentityStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/MarkerIdentityStep.java
deleted file mode 100644
index 379fa4e..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/MarkerIdentityStep.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-import java.util.NoSuchElementException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class MarkerIdentityStep<S> extends AbstractStep<S, S> {
-
- public MarkerIdentityStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- return this.starts.next();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java
deleted file mode 100644
index 4b39aa6..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/PathIdentityStep.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-import java.util.Collections;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class PathIdentityStep<S> extends AbstractStep<S, S> {
-
- public PathIdentityStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- @Override
- protected Traverser<S> processNextStart() throws NoSuchElementException {
- return this.starts.next();
- }
-
- @Override
- public Set<TraverserRequirement> getRequirements() {
- return Collections.singleton(TraverserRequirement.PATH);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
deleted file mode 100644
index 1f48885..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/ReducingBarrierStep.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.process.Step;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.TraversalEngine;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.computer.KeyValue;
-import org.apache.tinkerpop.gremlin.process.computer.MapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
-import org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce;
-import org.apache.tinkerpop.gremlin.process.computer.util.VertexProgramHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.EngineDependent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.MapReducer;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.util.TraverserSet;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-import java.util.Iterator;
-import java.util.function.BiFunction;
-import java.util.function.Supplier;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class ReducingBarrierStep<S, E> extends AbstractStep<S, E> implements MapReducer, EngineDependent {
-
- public static final String REDUCING = Graph.Hidden.hide("reducing");
-
- protected Supplier<E> seedSupplier;
- protected BiFunction<E, Traverser<S>, E> reducingBiFunction;
- private boolean done = false;
- protected boolean byPass = false;
-
- public ReducingBarrierStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- public void setSeedSupplier(final Supplier<E> seedSupplier) {
- this.seedSupplier = seedSupplier;
- }
-
- public void setBiFunction(final BiFunction<E, Traverser<S>, E> reducingBiFunction) {
- this.reducingBiFunction = reducingBiFunction;
- }
-
- @Override
- public void onEngine(final TraversalEngine traversalEngine) {
- this.byPass = traversalEngine.isComputer();
- }
-
- @Override
- public void reset() {
- super.reset();
- this.done = false;
- }
-
- @Override
- public Traverser<E> processNextStart() {
- if (this.byPass) {
- return (Traverser<E>) this.starts.next();
- } else {
- if (this.done)
- throw FastNoSuchElementException.instance();
- E seed = this.seedSupplier.get();
- while (this.starts.hasNext())
- seed = this.reducingBiFunction.apply(seed, this.starts.next());
- this.done = true;
- return TraversalHelper.getRootTraversal(this.getTraversal()).getTraverserGenerator().generate(FinalGet.tryFinalGet(seed), (Step) this, 1l);
- }
- }
-
- @Override
- public ReducingBarrierStep<S, E> clone() {
- final ReducingBarrierStep<S, E> clone = (ReducingBarrierStep<S, E>) super.clone();
- clone.done = false;
- return clone;
- }
-
- @Override
- public MapReduce getMapReduce() {
- return new DefaultMapReduce(this.seedSupplier, this.reducingBiFunction);
- }
-
- ///////
-
- public static class DefaultMapReduce extends StaticMapReduce<MapReduce.NullObject, Object, MapReduce.NullObject, Object, Object> {
-
- private static final String REDUCING_BARRIER_STEP_SEED_SUPPLIER = "gremlin.reducingBarrierStep.seedSupplier";
- private static final String REDUCING_BARRIER_STEP_BI_FUNCTION = "gremlin.reducingBarrierStep.biFunction";
-
- private BiFunction biFunction;
- private Supplier seedSupplier;
-
- private DefaultMapReduce() {
- }
-
- public DefaultMapReduce(final Supplier seedSupplier, final BiFunction biFunction) {
- this.seedSupplier = seedSupplier;
- this.biFunction = biFunction;
-
- }
-
- @Override
- public void storeState(final Configuration configuration) {
- super.storeState(configuration);
- VertexProgramHelper.serialize(this.seedSupplier, configuration, REDUCING_BARRIER_STEP_SEED_SUPPLIER);
- VertexProgramHelper.serialize(this.biFunction, configuration, REDUCING_BARRIER_STEP_BI_FUNCTION);
-
- }
-
- public void loadState(final Configuration configuration) {
- this.seedSupplier = VertexProgramHelper.deserialize(configuration, REDUCING_BARRIER_STEP_SEED_SUPPLIER);
- this.biFunction = VertexProgramHelper.deserialize(configuration, REDUCING_BARRIER_STEP_BI_FUNCTION);
- }
-
- @Override
- public boolean doStage(final Stage stage) {
- return !stage.equals(Stage.COMBINE);
- }
-
- @Override
- public String getMemoryKey() {
- return REDUCING;
- }
-
- @Override
- public Object generateFinalResult(final Iterator keyValues) {
- return ((KeyValue) keyValues.next()).getValue();
-
- }
-
- @Override
- public void map(final Vertex vertex, final MapEmitter<NullObject, Object> emitter) {
- vertex.<TraverserSet<?>>property(TraversalVertexProgram.HALTED_TRAVERSERS).ifPresent(traverserSet -> traverserSet.forEach(emitter::emit));
- }
-
- @Override
- public void reduce(final NullObject key, final Iterator<Object> values, final ReduceEmitter<NullObject, Object> emitter) {
- Object mutatingSeed = this.seedSupplier.get();
- while (values.hasNext()) {
- mutatingSeed = this.biFunction.apply(mutatingSeed, values.next());
- }
- emitter.emit(FinalGet.tryFinalGet(mutatingSeed));
- }
- }
-
- /////
-
- public interface FinalGet<A> {
-
- public A getFinal();
-
- public static <A> A tryFinalGet(final Object object) {
- return object instanceof FinalGet ? ((FinalGet<A>) object).getFinal() : (A) object;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4c97e964/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
deleted file mode 100644
index 78d3830..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/graph/traversal/step/util/SupplyingBarrierStep.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.graph.traversal.step.util;
-
-import org.apache.tinkerpop.gremlin.process.FastNoSuchElementException;
-import org.apache.tinkerpop.gremlin.process.Step;
-import org.apache.tinkerpop.gremlin.process.Traversal;
-import org.apache.tinkerpop.gremlin.process.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.AbstractStep;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public abstract class SupplyingBarrierStep<S, E> extends AbstractStep<S, E> {
-
- private boolean done = false;
-
- public SupplyingBarrierStep(final Traversal.Admin traversal) {
- super(traversal);
- }
-
- public abstract E supply();
-
- @Override
- public void reset() {
- super.reset();
- this.done = false;
- }
-
- @Override
- public Traverser<E> processNextStart() {
- if (this.done)
- throw FastNoSuchElementException.instance();
- while (this.starts.hasNext())
- this.starts.next();
- this.done = true;
- return this.getTraversal().asAdmin().getTraverserGenerator().generate(this.supply(), (Step) this, 1l);
- }
-
- @Override
- public SupplyingBarrierStep<S, E> clone() {
- final SupplyingBarrierStep<S, E> clone = (SupplyingBarrierStep<S, E>) super.clone();
- clone.done = false;
- return clone;
- }
-
-
-}