This is an automated email from the ASF dual-hosted git repository.

okram pushed a commit to branch tp4
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit c26b7e8e4bb05e6d429eb75a6a5d2901fbafa035
Author: Marko A. Rodriguez <okramma...@gmail.com>
AuthorDate: Mon Mar 11 10:36:15 2019 -0600

    Strategy interface created and IdentityStrategy instance created. Bytecode 
sourceInstructions was stubbed along with the strategy application code.
---
 .../org/apache/tinkerpop/language/Symbols.java     |  4 +-
 .../org/apache/tinkerpop/language/Traversal.java   | 15 +++---
 .../apache/tinkerpop/language/TraversalSource.java | 37 +++++--------
 .../java/org/apache/tinkerpop/language/__.java     |  5 +-
 .../tinkerpop/machine/bytecode/Bytecode.java       | 16 +++---
 .../tinkerpop/machine/bytecode/BytecodeUtil.java   | 62 +++++++++++++++++++---
 .../machine/bytecode/SourceInstruction.java        |  7 +++
 .../machine/coefficients/LongCoefficient.java      |  3 +-
 .../IdentityStrategy.java}                         | 10 ++--
 .../machine/{compiler => strategies}/Strategy.java |  4 +-
 .../org/apache/tinkerpop/util/StringFactory.java   | 15 ++++++
 .../apache/tinkerpop/machine/TraversalTest.java    |  3 +-
 .../machine/compiler/BytecodeUtilTest.java         |  6 +--
 java/machine/beam/pom.xml                          |  2 +-
 .../org/apache/tinkerpop/machine/beam/Beam.java    |  2 +-
 .../apache/tinkerpop/machine/beam/ReduceFn.java    |  2 -
 .../apache/tinkerpop/machine/beam/BeamTest.java    |  7 ++-
 java/machine/pipes/pom.xml                         |  2 +-
 .../org/apache/tinkerpop/machine/pipes/Pipes.java  |  2 +-
 .../apache/tinkerpop/machine/pipes/PipesTest.java  |  9 ++--
 20 files changed, 143 insertions(+), 70 deletions(-)

diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java 
b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java
index 9ea778d..2912789 100644
--- a/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java
+++ b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java
@@ -24,7 +24,9 @@ package org.apache.tinkerpop.language;
 public final class Symbols {
 
     // SOURCE OPS
-    public static final String COEFFICIENT = "coefficient";
+    public static final String WITH_COEFFICIENT = "withCoefficient";
+    public static final String WITH_PROCESSOR = "withProcessor";
+    public static final String WITH_STRATEGY = "withStrategy";
 
 
     // INSTRUCTION OPS
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java 
b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java
index f8f446c..ba090d9 100644
--- a/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java
+++ b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java
@@ -19,7 +19,9 @@
 package org.apache.tinkerpop.language;
 
 import org.apache.tinkerpop.machine.bytecode.Bytecode;
+import org.apache.tinkerpop.machine.bytecode.BytecodeUtil;
 import org.apache.tinkerpop.machine.coefficients.Coefficient;
+import org.apache.tinkerpop.machine.coefficients.LongCoefficient;
 import org.apache.tinkerpop.machine.processor.Processor;
 import org.apache.tinkerpop.machine.processor.ProcessorFactory;
 import org.apache.tinkerpop.machine.traversers.Path;
@@ -36,15 +38,16 @@ public class Traversal<C, S, E> implements Iterator<E> {
 
     protected final Bytecode<C> bytecode;
     private Coefficient<C> currentCoefficient;
-    private final ProcessorFactory factory;
+    private final ProcessorFactory processorFactory;
     private Processor<C, S, E> processor;
+    //
     private long lastCount = 0L;
     private E lastObject = null;
 
-    public Traversal(final Coefficient<C> unity, final ProcessorFactory 
factory) {
-        this.currentCoefficient = unity;
-        this.bytecode = new Bytecode<>();
-        this.factory = factory;
+    public Traversal(final Bytecode<C> bytecode) {
+        this.bytecode = bytecode;
+        this.currentCoefficient = 
BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient<C>) 
LongCoefficient.create());
+        this.processorFactory = 
BytecodeUtil.getProcessorFactory(this.bytecode).orElse(null);
     }
 
     public Traversal<C, S, E> as(final String label) {
@@ -102,7 +105,7 @@ public class Traversal<C, S, E> implements Iterator<E> {
 
     private void setupProcessor() {
         if (null == this.processor)
-            this.processor = this.factory.mint(this.bytecode);
+            this.processor = this.processorFactory.mint(this.bytecode);
     }
 
     @Override
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java 
b/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java
index baf4069..91f59f9 100644
--- a/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java
+++ b/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java
@@ -20,50 +20,39 @@ package org.apache.tinkerpop.language;
 
 import org.apache.tinkerpop.machine.bytecode.Bytecode;
 import org.apache.tinkerpop.machine.coefficients.Coefficient;
-import org.apache.tinkerpop.machine.coefficients.LongCoefficient;
-import org.apache.tinkerpop.machine.compiler.Strategy;
 import org.apache.tinkerpop.machine.processor.ProcessorFactory;
-
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.tinkerpop.machine.strategies.Strategy;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public class TraversalSource<C> {
 
-    private Bytecode<C> bytecode = new Bytecode<>();
-    private Coefficient<C> coefficient;
-    private ProcessorFactory factory;
-    private List<Strategy> strategies = new ArrayList<>();
-
+    private Bytecode<C> bytecode;
 
     protected TraversalSource() {
-        this.coefficient = (Coefficient<C>) LongCoefficient.create();
+        this.bytecode = new Bytecode<>();
     }
 
-    public TraversalSource<C> coefficient(final Coefficient<C> coefficient) {
-        this.coefficient = coefficient.clone();
-        this.coefficient.unity();
+    public TraversalSource<C> withCoefficient(final Class<? extends 
Coefficient<C>> coefficient) {
+        this.bytecode = this.bytecode.clone();
+        this.bytecode.addSourceInstruction(Symbols.WITH_COEFFICIENT, 
coefficient.getCanonicalName());
         return this;
     }
 
-    public TraversalSource<C> processor(final Class<? extends 
ProcessorFactory> processor) {
-        try {
-            this.factory = processor.newInstance();
-        } catch (final Exception e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
+    public TraversalSource<C> withProcessor(final Class<? extends 
ProcessorFactory> processor) {
+        this.bytecode = this.bytecode.clone();
+        this.bytecode.addSourceInstruction(Symbols.WITH_PROCESSOR, 
processor.getCanonicalName());
         return this;
     }
 
-    public TraversalSource<C> strategy(final Strategy strategy) {
-        this.strategies.add(strategy);
+    public TraversalSource<C> withStrategy(final Class<? extends Strategy> 
strategy) {
+        this.bytecode = this.bytecode.clone();
+        this.bytecode.addSourceInstruction(Symbols.WITH_STRATEGY, 
strategy.getCanonicalName());
         return this;
     }
 
     public <S> Traversal<C, S, S> inject(final S... objects) {
-        final Traversal<C, S, S> traversal = new Traversal<>(this.coefficient, 
this.factory);
-        return traversal.inject(objects);
+        return (Traversal<C, S, S>) new 
Traversal<>(this.bytecode.clone()).inject(objects);
     }
 }
diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/__.java 
b/java/core/src/main/java/org/apache/tinkerpop/language/__.java
index 23fbb65..80bb253 100644
--- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java
+++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.language;
 
+import org.apache.tinkerpop.machine.bytecode.Bytecode;
 import org.apache.tinkerpop.machine.coefficients.LongCoefficient;
 import org.apache.tinkerpop.machine.processor.EmptyProcessorFactory;
 
@@ -27,7 +28,7 @@ import 
org.apache.tinkerpop.machine.processor.EmptyProcessorFactory;
 public class __ {
 
     public static <C> Traversal<C, Long, Long> incr() {
-        // this is bad -- it needs to know how to get the coefficient of the 
parent traversal
-        return (Traversal) new Traversal<>(LongCoefficient.create(), 
EmptyProcessorFactory.instance()).incr();
+        // this is bad -- it needs to know how to get the withCoefficient of 
the parent traversal
+        return (Traversal) new Traversal<>(new Bytecode<>()).incr();
     }
 }
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Bytecode.java 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Bytecode.java
index 74d4d3e..1529a5c 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Bytecode.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Bytecode.java
@@ -19,7 +19,6 @@
 package org.apache.tinkerpop.machine.bytecode;
 
 import org.apache.tinkerpop.machine.coefficients.Coefficient;
-import org.apache.tinkerpop.machine.compiler.Strategy;
 import org.apache.tinkerpop.machine.traversers.CompleteTraverserFactory;
 import org.apache.tinkerpop.machine.traversers.TraverserFactory;
 
@@ -31,16 +30,15 @@ import java.util.List;
  */
 public class Bytecode<C> implements Cloneable {
 
-    private List<Strategy> strategies = new ArrayList<>();
     private List<Instruction<C>> instructions = new ArrayList<>();
+    private List<SourceInstruction> sourceInstructions = new ArrayList<>();
 
-
-    public void addStrategy(final Strategy strategy) {
-        this.strategies.add(strategy);
+    public void addSourceInstruction(final String op, final Object... args) {
+        this.sourceInstructions.add(new SourceInstruction(op, args));
     }
 
-    public List<Strategy> getStrategies() {
-        return this.strategies;
+    public List<SourceInstruction> getSourceInstructions() {
+        return this.sourceInstructions;
     }
 
     ///
@@ -62,7 +60,7 @@ public class Bytecode<C> implements Cloneable {
         return this.instructions.get(this.instructions.size() - 1);
     }
 
-    // this should be part of processor!
+    // this should be part of withProcessor!
     public <S> TraverserFactory<C> getTraverserFactory() {
         return new CompleteTraverserFactory<>();
     }
@@ -76,7 +74,7 @@ public class Bytecode<C> implements Cloneable {
     public Bytecode<C> clone() {
         try {
             final Bytecode<C> clone = (Bytecode<C>) super.clone();
-            clone.strategies = new ArrayList<>(this.strategies);
+            clone.sourceInstructions = new 
ArrayList<>(this.sourceInstructions);
             clone.instructions = new ArrayList<>(this.instructions);
             return clone;
         } catch (final CloneNotSupportedException e) {
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java
 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java
index 2f29bba..538825a 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java
@@ -28,9 +28,13 @@ import org.apache.tinkerpop.machine.functions.map.IncrMap;
 import org.apache.tinkerpop.machine.functions.map.MapMap;
 import org.apache.tinkerpop.machine.functions.map.PathMap;
 import org.apache.tinkerpop.machine.functions.reduce.CountReduce;
+import org.apache.tinkerpop.machine.processor.ProcessorFactory;
+import org.apache.tinkerpop.machine.strategies.Strategy;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -38,13 +42,16 @@ import java.util.Set;
  */
 public final class BytecodeUtil {
 
-    public static <C> Bytecode<C> optimize(final Bytecode<C> bytecode) {
-        Instruction<C> toRemove = null;
-        for (Instruction<C> instruction : bytecode.getInstructions()) {
-            if (instruction.op().equals(Symbols.IDENTITY))
-                toRemove = instruction;
+    public static <C> Bytecode<C> strategize(final Bytecode<C> bytecode) {
+        for (final Strategy strategy : BytecodeUtil.getStrategies(bytecode)) {
+            strategy.apply(bytecode);
+            for (final Instruction<C> instruction : 
bytecode.getInstructions()) {
+                for (Object arg : instruction.args()) {
+                    if (arg instanceof Bytecode)
+                        strategy.apply((Bytecode<C>) arg);
+                }
+            }
         }
-        bytecode.removeInstruction(toRemove);
         return bytecode;
     }
 
@@ -56,6 +63,49 @@ public final class BytecodeUtil {
         return functions;
     }
 
+    public static <C> List<Strategy> getStrategies(final Bytecode<C> bytecode) 
{
+        try {
+            final List<Strategy> strategies = new ArrayList<>();
+            for (final SourceInstruction sourceInstruction : 
bytecode.getSourceInstructions()) {
+                if (sourceInstruction.op().equals(Symbols.WITH_STRATEGY))
+                    strategies.add((Strategy) 
Class.forName(sourceInstruction.args()[0].toString()).getConstructor().newInstance());
+            }
+            // sort strategies
+            return strategies;
+        } catch (final ClassNotFoundException | NoSuchMethodException | 
IllegalAccessException | InstantiationException | InvocationTargetException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    public static <C> Optional<Coefficient<C>> getCoefficient(final 
Bytecode<C> bytecode) {
+        try {
+            Coefficient<C> coefficient = null;
+            for (final SourceInstruction sourceInstruction : 
bytecode.getSourceInstructions()) {
+                if (sourceInstruction.op().equals(Symbols.WITH_COEFFICIENT)) {
+                    coefficient = (Coefficient<C>) 
Class.forName(sourceInstruction.args()[0].toString()).getConstructor().newInstance();
+                }
+            }
+
+            return Optional.ofNullable(coefficient);
+        } catch (final ClassNotFoundException | NoSuchMethodException | 
IllegalAccessException | InstantiationException | InvocationTargetException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    public static <C> Optional<ProcessorFactory> getProcessorFactory(final 
Bytecode<C> bytecode) {
+        try {
+            ProcessorFactory processor = null;
+            for (final SourceInstruction sourceInstruction : 
bytecode.getSourceInstructions()) {
+                if (sourceInstruction.op().equals(Symbols.WITH_PROCESSOR)) {
+                    processor = (ProcessorFactory) 
Class.forName(sourceInstruction.args()[0].toString()).getConstructor().newInstance();
+                }
+            }
+            return Optional.ofNullable(processor);
+        } catch (final ClassNotFoundException | NoSuchMethodException | 
IllegalAccessException | InstantiationException | InvocationTargetException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
     private static <C> CFunction<C> generateFunction(final Instruction<C> 
instruction) {
         final String op = instruction.op();
         final Coefficient<C> coefficient = instruction.coefficient();
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/SourceInstruction.java
 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/SourceInstruction.java
index 48fc0f0..50f460e 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/SourceInstruction.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/SourceInstruction.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tinkerpop.machine.bytecode;
 
+import org.apache.tinkerpop.util.StringFactory;
+
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
@@ -38,4 +40,9 @@ public final class SourceInstruction {
     public Object[] args() {
         return this.args;
     }
+
+    @Override
+    public String toString() {
+        return StringFactory.makeSourceInstructionString(this);
+    }
 }
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficients/LongCoefficient.java
 
b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficients/LongCoefficient.java
index f322383..0facb68 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficients/LongCoefficient.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficients/LongCoefficient.java
@@ -23,13 +23,14 @@ package org.apache.tinkerpop.machine.coefficients;
  */
 public class LongCoefficient implements Coefficient<Long> {
 
-    protected Long value;
+    private Long value;
 
     private LongCoefficient(final Long value) {
         this.value = value;
     }
 
     public LongCoefficient() {
+        this.value = 1L;
     }
 
     @Override
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java 
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java
similarity index 73%
copy from 
java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java
copy to 
java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java
index 895f94b..9b91e2c 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java
@@ -16,14 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.tinkerpop.machine.compiler;
+package org.apache.tinkerpop.machine.strategies;
 
+import org.apache.tinkerpop.language.Symbols;
 import org.apache.tinkerpop.machine.bytecode.Bytecode;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public interface Strategy {
+public final class IdentityStrategy implements Strategy {
 
-    public <C> void process(final Bytecode<C> bytecode);
+    @Override
+    public <C> void apply(final Bytecode<C> bytecode) {
+        bytecode.getInstructions().removeIf(instruction -> 
instruction.op().equals(Symbols.IDENTITY));
+    }
 }
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java 
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/Strategy.java
similarity index 90%
rename from 
java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java
rename to 
java/core/src/main/java/org/apache/tinkerpop/machine/strategies/Strategy.java
index 895f94b..8e27ebf 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Strategy.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/Strategy.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.tinkerpop.machine.compiler;
+package org.apache.tinkerpop.machine.strategies;
 
 import org.apache.tinkerpop.machine.bytecode.Bytecode;
 
@@ -25,5 +25,5 @@ import org.apache.tinkerpop.machine.bytecode.Bytecode;
  */
 public interface Strategy {
 
-    public <C> void process(final Bytecode<C> bytecode);
+    public <C> void apply(final Bytecode<C> bytecode);
 }
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/util/StringFactory.java 
b/java/core/src/main/java/org/apache/tinkerpop/util/StringFactory.java
index 9679e23..03a5d79 100644
--- a/java/core/src/main/java/org/apache/tinkerpop/util/StringFactory.java
+++ b/java/core/src/main/java/org/apache/tinkerpop/util/StringFactory.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.util;
 
 import org.apache.tinkerpop.machine.bytecode.Instruction;
+import org.apache.tinkerpop.machine.bytecode.SourceInstruction;
 import org.apache.tinkerpop.machine.functions.CFunction;
 
 /**
@@ -48,6 +49,20 @@ public final class StringFactory {
         return name;
     }
 
+    public static String makeSourceInstructionString(final SourceInstruction 
sourceInstruction) {
+        String name = sourceInstruction.op();
+        if (sourceInstruction.args().length > 0)
+            name = name + "(";
+        for (final Object object : sourceInstruction.args()) {
+            name = name + object + ",";
+        }
+        if (sourceInstruction.args().length > 0) {
+            name = name.substring(0, name.length() - 1);
+            name = name + ")";
+        }
+        return name;
+    }
+
     public static String makeFunctionString(final CFunction<?> function, final 
Object... args) {
         String name = function.getClass().getSimpleName();
         if (!function.coefficient().isUnity())
diff --git 
a/java/core/src/test/java/org/apache/tinkerpop/machine/TraversalTest.java 
b/java/core/src/test/java/org/apache/tinkerpop/machine/TraversalTest.java
index a82ac84..aeebfde 100644
--- a/java/core/src/test/java/org/apache/tinkerpop/machine/TraversalTest.java
+++ b/java/core/src/test/java/org/apache/tinkerpop/machine/TraversalTest.java
@@ -33,9 +33,8 @@ public class TraversalTest {
     @Test
     public void shouldHaveBytecode() throws Exception {
         TraversalSource<Long> g = Gremlin.traversal();
-        g = g.coefficient(LongCoefficient.create());
         final Traversal<Long, Long, Long> traversal = 
g.inject(7L).is(7L).incr().as("a").is(8L).by(__.incr());
         //System.out.println(traversal.bytecode);
-        //System.out.println(BytecodeUtil.compile(traversal.getBytecode()));
+        //System.out.println(BytecodeUtil.apply(traversal.getBytecode()));
     }
 }
diff --git 
a/java/core/src/test/java/org/apache/tinkerpop/machine/compiler/BytecodeUtilTest.java
 
b/java/core/src/test/java/org/apache/tinkerpop/machine/compiler/BytecodeUtilTest.java
index cc438f5..e1b025d 100644
--- 
a/java/core/src/test/java/org/apache/tinkerpop/machine/compiler/BytecodeUtilTest.java
+++ 
b/java/core/src/test/java/org/apache/tinkerpop/machine/compiler/BytecodeUtilTest.java
@@ -30,9 +30,9 @@ public class BytecodeUtilTest {
 
     @Test
     public void shouldHaveBytecode() throws Exception {
-        final Traversal<Long, Long, Long> traversal = new 
Traversal<>(LongCoefficient.create(), EmptyProcessorFactory.instance());
-        traversal.incr().is(2L);
+        //final Traversal<Long, Long, Long> traversal = new 
Traversal<>(LongCoefficient.create(), EmptyProcessorFactory.instance());
+        //traversal.incr().is(2L);
         //System.out.println(traversal.bytecode);
-        //System.out.println(BytecodeUtil.compile(traversal.getBytecode()));
+        //System.out.println(BytecodeUtil.apply(traversal.getBytecode()));
     }
 }
diff --git a/java/machine/beam/pom.xml b/java/machine/beam/pom.xml
index 24a9773..dc0d2da 100644
--- a/java/machine/beam/pom.xml
+++ b/java/machine/beam/pom.xml
@@ -27,7 +27,7 @@ limitations under the License.
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>core</artifactId>
-            <version>4.0.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.beam</groupId>
diff --git 
a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java 
b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java
index 0040bf7..bfe910e 100644
--- 
a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java
+++ 
b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java
@@ -87,7 +87,7 @@ public class Beam<C, S, E> implements Processor<C, S, E> {
     }
 
     public Beam(final Bytecode<C> bytecode) {
-        this(BytecodeUtil.compile(bytecode));
+        this(BytecodeUtil.compile(BytecodeUtil.strategize(bytecode)));
     }
 
     @Override
diff --git 
a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/ReduceFn.java
 
b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/ReduceFn.java
index 2e9353d..5a53d13 100644
--- 
a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/ReduceFn.java
+++ 
b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/ReduceFn.java
@@ -37,12 +37,10 @@ public class ReduceFn<C, S, E> extends 
Combine.CombineFn<Traverser<C, S>, BasicA
 
     public ReduceFn(final ReduceFunction<C, S, E> reduceFunction,
                     final TraverserFactory<C> traverserFactory) {
-        //super(reduceFunction);
         this.reduceFunction = reduceFunction;
         this.traverserFactory = traverserFactory;
     }
 
-
     @Override
     public void addStart(Traverser<C, S> traverser) {
 
diff --git 
a/java/machine/beam/src/test/java/org/apache/tinkerpop/machine/beam/BeamTest.java
 
b/java/machine/beam/src/test/java/org/apache/tinkerpop/machine/beam/BeamTest.java
index 39d3786..910b792 100644
--- 
a/java/machine/beam/src/test/java/org/apache/tinkerpop/machine/beam/BeamTest.java
+++ 
b/java/machine/beam/src/test/java/org/apache/tinkerpop/machine/beam/BeamTest.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.language.TraversalSource;
 import org.apache.tinkerpop.language.TraversalUtil;
 import org.apache.tinkerpop.language.__;
 import org.apache.tinkerpop.machine.coefficients.LongCoefficient;
+import org.apache.tinkerpop.machine.strategies.IdentityStrategy;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -33,8 +34,10 @@ public class BeamTest {
     @Test
     public void shouldWork() {
         final TraversalSource<Long> g = Gremlin.<Long>traversal()
-                .coefficient(LongCoefficient.create())
-                .processor(BeamProcessor.class);
+                .withCoefficient(LongCoefficient.class)
+                .withProcessor(BeamProcessor.class)
+                .withStrategy(IdentityStrategy.class);
+
         Traversal<Long, Long, Long> traversal = g.inject(7L, 10L, 
12L).as("a").c(3L).map(__.incr()).identity().incr();
         System.out.println(TraversalUtil.getBytecode(traversal));
         System.out.println(traversal);
diff --git a/java/machine/pipes/pom.xml b/java/machine/pipes/pom.xml
index 023b09a..3d40c2a 100644
--- a/java/machine/pipes/pom.xml
+++ b/java/machine/pipes/pom.xml
@@ -27,7 +27,7 @@ limitations under the License.
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>core</artifactId>
-            <version>4.0.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
     <build>
diff --git 
a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/Pipes.java
 
b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/Pipes.java
index 606e0ad..c335a92 100644
--- 
a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/Pipes.java
+++ 
b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/Pipes.java
@@ -71,7 +71,7 @@ public class Pipes<C, S, E> implements Processor<C, S, E> {
     }
 
     public Pipes(final Bytecode<C> bytecode) {
-        this(BytecodeUtil.compile(BytecodeUtil.optimize(bytecode)), 
bytecode.getTraverserFactory());
+        this(BytecodeUtil.compile(BytecodeUtil.strategize(bytecode)), 
bytecode.getTraverserFactory());
     }
 
     @Override
diff --git 
a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java
 
b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java
index 8a7fd48..e211a7e 100644
--- 
a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java
+++ 
b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.language.TraversalSource;
 import org.apache.tinkerpop.language.TraversalUtil;
 import org.apache.tinkerpop.language.__;
 import org.apache.tinkerpop.machine.coefficients.LongCoefficient;
+import org.apache.tinkerpop.machine.strategies.IdentityStrategy;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -34,9 +35,11 @@ public class PipesTest {
     @Test
     public void shouldWork() {
         final TraversalSource<Long> g = Gremlin.<Long>traversal()
-                .coefficient(LongCoefficient.create())
-                .processor(PipesProcessor.class);
-        Traversal<Long, Long, Long> traversal = g.inject(7L, 10L, 
12L).as("a").c(3L).map(__.incr()).identity().incr();
+                .withCoefficient(LongCoefficient.class)
+                .withProcessor(PipesProcessor.class)
+                .withStrategy(IdentityStrategy.class);
+
+        Traversal<Long, Long, Long> traversal = g.inject(7L, 10L, 
12L).as("a").c(3L).map(__.incr()).identity().incr().identity().identity();
         System.out.println(TraversalUtil.getBytecode(traversal));
         System.out.println(traversal);
         System.out.println(traversal.toList());

Reply via email to