[tinkerpop] branch tp4 updated: playing around with nested traversal typing and __. So ugly if its fully correct......
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 The following commit(s) were added to refs/heads/tp4 by this push: new 0f2dc52 playing around with nested traversal typing and __. So ugly if its fully correct.. 0f2dc52 is described below commit 0f2dc520d1eee7f1b397beb3c95b8deb469ee15e Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 13:56:29 2019 -0600 playing around with nested traversal typing and __. So ugly if its fully correct.. --- .../core/src/main/java/org/apache/tinkerpop/language/Traversal.java | 6 +++--- java/core/src/main/java/org/apache/tinkerpop/language/__.java | 4 ++-- .../src/test/java/org/apache/tinkerpop/machine/beam/BeamTest.java | 2 +- .../src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) 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 89a6dd4..59e24ea 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 @@ -99,7 +99,7 @@ public class Traversal implements Iterator { return this.emit(__.constant(true)); } -public Traversal emit(final Traversal emitTraversal) { +public Traversal emit(final Traversal emitTraversal) { final Instruction lastInstruction = this.bytecode.lastInstruction(); if (lastInstruction.op().equals(Symbols.REPEAT)) lastInstruction.addArgs('e', emitTraversal.bytecode); @@ -173,7 +173,7 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal> join(Symbols.Tokens joinType, final Traversal> joinTraversal) { +public Traversal> join(final Symbols.Tokens joinType, final Traversal> joinTraversal) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.JOIN, joinType, joinTraversal.bytecode); return (Traversal) this; } @@ -228,7 +228,7 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal until(final Traversal untilTraversal) { +public Traversal until(final Traversal untilTraversal) { final Instruction lastInstruction = this.bytecode.lastInstruction(); if (lastInstruction.op().equals(Symbols.REPEAT)) lastInstruction.addArgs('u', untilTraversal.bytecode); 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 c80580b..d20fe67 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -37,7 +37,7 @@ public class __ { return __.start().c(coefficient); } -public static Traversal constant(final R constant) { +public static Traversal constant(final S constant) { return __.start().constant(constant); } @@ -46,7 +46,7 @@ public class __ { } public static Traversal is(final S object) { -return __.start().is(object); +return object instanceof Traversal ? __.is((Traversal) object) : __.start().is(object); } public static Traversal is(final Traversal objectTraversal) { 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 24e5866..6b15bb6 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 @@ -42,7 +42,7 @@ public class BeamTest { .withProcessor(BeamProcessor.class) .withStrategy(IdentityStrategy.class); -Traversal traversal = g.inject(Arrays.asList(1L, 1L)).unfold().map(incr()).c(4L).repeat(incr()).until(__.is(__.constant(8L).incr().incr())).sum(); +Traversal traversal = g.inject(Arrays.asList(1L, 1L)).unfold().map(incr()).c(4L).repeat(incr()).until(__.is(__.constant(8L).incr().incr())).sum(); System.out.println(TraversalUtil.getBytecode(traversal)); System.out.println(traversal); System.out.println(traversal.toList()); 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 a0e04b5..50901ff 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 @@ -46,7 +46,7 @@ public class PipesTest { .withProcessor(PipesPro
[tinkerpop] branch tp4 updated: added Symbols.Tokens which has now inner, outer, full, etc. join tokens. May want to move it somewhere else later. More tweaks to JoinBarrier.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 8fcc6fb added Symbols.Tokens which has now inner, outer, full, etc. join tokens. May want to move it somewhere else later. More tweaks to JoinBarrier. 8fcc6fb is described below commit 8fcc6fbd329314b4db7842dee0404ff49a20b1ec Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 13:36:54 2019 -0600 added Symbols.Tokens which has now inner, outer, full, etc. join tokens. May want to move it somewhere else later. More tweaks to JoinBarrier. --- .../src/main/java/org/apache/tinkerpop/language/Traversal.java | 6 +++--- .../org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java| 2 +- .../java/org/apache/tinkerpop/machine/bytecode/Symbols.java| 4 .../apache/tinkerpop/machine/function/barrier/JoinBarrier.java | 10 -- .../java/org/apache/tinkerpop/machine/pipes/PipesTest.java | 3 ++- 5 files changed, 18 insertions(+), 7 deletions(-) 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 1c62b18..89a6dd4 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 @@ -173,8 +173,8 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal> join(final Traversal, Map> joinTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.JOIN, joinTraversal.bytecode); +public Traversal> join(Symbols.Tokens joinType, final Traversal> joinTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.JOIN, joinType, joinTraversal.bytecode); return (Traversal) this; } @@ -208,7 +208,7 @@ public class Traversal implements Iterator { } public Traversal times(final int times) { -return this.until(__.loops().is(times)); +return this.until(__.loops().is(times)); // TODO: make an int argument } public Traversal unfold() { 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 1898061..016eb30 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 @@ -181,7 +181,7 @@ public final class BytecodeUtil { case Symbols.INCR: return new IncrMap<>(coefficient, labels); case Symbols.JOIN: -return new JoinBarrier<>(coefficient, labels, Compilation.compileOne(instruction.args()[0]), Argument.create(instruction.args()[1])); +return new JoinBarrier<>(coefficient, labels, (Symbols.Tokens) instruction.args()[0], Compilation.compileOne(instruction.args()[1]), Argument.create(instruction.args()[2])); case Symbols.LOOPS: return new LoopsMap<>(coefficient, labels); case Symbols.MAP: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symbols.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symbols.java index 292a187..e36fe42 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symbols.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symbols.java @@ -31,6 +31,10 @@ public final class Symbols { BARRIER, INITIAL, MAP, FLATMAP, FILTER, REDUCE, BRANCH } +public static enum Tokens { +inner, left, right, full +} + // SOURCE OPS public static final String WITH_COEFFICIENT = "withCoefficient"; public static final String WITH_PROCESSOR = "withProcessor"; diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/barrier/JoinBarrier.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/barrier/JoinBarrier.java index 4f28b9d..b110f15 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/barrier/JoinBarrier.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/barrier/JoinBarrier.java @@ -20,6 +20,7 @@ package org.apache.tinkerpop.machine.function.barrier; import org.apache.tinkerpop.machine.bytecode.Argument; import org.apache.tinkerpop.machine.bytecode.Compilation; +import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.AbstractFunction; import org.apache.tinkerpop.machine.function.BarrierFunction; @@ -38,11 +39,16 @@ import java.util.Set; */ public class JoinBarrier e
[tinkerpop] branch tp4 updated: Implemented equijoin as JoinBarrier. Wow. Works great. You can now join in Pipes. Haven't tied it to Beam yet.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 75d722e Implemented equijoin as JoinBarrier. Wow. Works great. You can now join in Pipes. Haven't tied it to Beam yet. 75d722e is described below commit 75d722e3cb923e502d7992fa180a6ba00474c02d Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 13:21:38 2019 -0600 Implemented equijoin as JoinBarrier. Wow. Works great. You can now join in Pipes. Haven't tied it to Beam yet. --- .../org/apache/tinkerpop/language/Traversal.java | 10 +++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../tinkerpop/machine/bytecode/Compilation.java| 5 +- .../apache/tinkerpop/machine/bytecode/Symbols.java | 3 + .../machine/function/BarrierFunction.java | 4 +- .../machine/function/barrier/JoinBarrier.java | 88 ++ .../machine/function/barrier/StallBarrier.java | 7 +- .../tinkerpop/machine/pipes/BarrierStep.java | 15 +++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 31 +++- 10 files changed, 158 insertions(+), 10 deletions(-) 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 ce9b788..1c62b18 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 @@ -65,6 +65,11 @@ public class Traversal implements Iterator { return this; } +public Traversal by(final R byObject) { +this.bytecode.lastInstruction().addArg(byObject); +return this; +} + public Traversal c(final C coefficient) { this.currentCoefficient.set(coefficient); return this; @@ -168,6 +173,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal> join(final Traversal, Map> joinTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.JOIN, joinTraversal.bytecode); +return (Traversal) this; +} + public Traversal loops() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.LOOPS); return (Traversal) this; 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 4e9bc78..1898061 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 @@ -20,6 +20,7 @@ package org.apache.tinkerpop.machine.bytecode; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.CFunction; +import org.apache.tinkerpop.machine.function.barrier.JoinBarrier; import org.apache.tinkerpop.machine.function.barrier.StallBarrier; import org.apache.tinkerpop.machine.function.branch.ChooseBranch; import org.apache.tinkerpop.machine.function.branch.RepeatBranch; @@ -179,6 +180,8 @@ public final class BytecodeUtil { return new IsFilter<>(coefficient, labels, Argument.create(instruction.args()[0])); case Symbols.INCR: return new IncrMap<>(coefficient, labels); +case Symbols.JOIN: +return new JoinBarrier<>(coefficient, labels, Compilation.compileOne(instruction.args()[0]), Argument.create(instruction.args()[1])); case Symbols.LOOPS: return new LoopsMap<>(coefficient, labels); case Symbols.MAP: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index f7e460f..02c7221 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -27,6 +27,7 @@ import org.apache.tinkerpop.machine.traverser.TraverserFactory; import java.io.Serializable; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Optional; @@ -81,11 +82,11 @@ public final class Compilation implements Serializable { return this.processor.next(); } -/*public Iterator> flatMapTraverser(final Traverser traverser) { +public Iterator> flatMapTraverser(final Traverser traverser) { this.prepareProcessor(); this.processor.addStart(this.prepareTraverser(traverser)); return this.processor; -}*/ +} public boolean filterTraverser(final Traverser traverser) {
[tinkerpop] branch tp4 updated: minor optimizations and reorg.
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 The following commit(s) were added to refs/heads/tp4 by this push: new b708d11 minor optimizations and reorg. b708d11 is described below commit b708d11b74a622748246c51469e61556a45be420 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 10:18:20 2019 -0600 minor optimizations and reorg. --- .../tinkerpop/machine/bytecode/Compilation.java| 22 +++--- .../apache/tinkerpop/machine/pipes/FilterStep.java | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index a72bc1d..f7e460f 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -27,7 +27,6 @@ import org.apache.tinkerpop.machine.traverser.TraverserFactory; import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Optional; @@ -52,18 +51,16 @@ public final class Compilation implements Serializable { } public Processor getProcessor() { -this.prepareProcessor(); +if (null == this.processor) +this.processor = this.processorFactory.mint(this); return this.processor; } -public void reset() { -if (null != this.processor) -this.processor.reset(); -} - private void prepareProcessor() { if (null == this.processor) this.processor = this.processorFactory.mint(this); +else +this.processor.reset(); } private Traverser prepareTraverser(final Traverser traverser) { @@ -73,36 +70,31 @@ public final class Compilation implements Serializable { } public Traverser mapTraverser(final Traverser traverser) { -this.reset(); this.prepareProcessor(); this.processor.addStart(this.prepareTraverser(traverser)); return this.processor.next(); } public Traverser mapObject(final S object) { -this.reset(); this.prepareProcessor(); this.processor.addStart(this.traverserFactory.create(this.functions.get(0), object)); return this.processor.next(); } -public Iterator> flatMapTraverser(final Traverser traverser) { -this.reset(); +/*public Iterator> flatMapTraverser(final Traverser traverser) { this.prepareProcessor(); this.processor.addStart(this.prepareTraverser(traverser)); return this.processor; -} +}*/ public boolean filterTraverser(final Traverser traverser) { -this.reset(); this.prepareProcessor(); this.processor.addStart(this.prepareTraverser(traverser)); return this.processor.hasNext(); } public Processor addTraverser(final Traverser traverser) { -this.prepareProcessor(); -this.processor.addStart(traverser); +this.getProcessor().addStart(traverser); return this.processor; } diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/FilterStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/FilterStep.java index ee62460..b5d378b 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/FilterStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/FilterStep.java @@ -55,7 +55,7 @@ final class FilterStep extends AbstractStep { private void stageNextTraverser() { while (null == this.nextTraverser && this.previousStep.hasNext()) { -this.previousStep.next().filter(this.filterFunction).ifPresent(t -> this.nextTraverser = t); + this.previousStep.next().filter(this.filterFunction).ifPresent(traverser -> this.nextTraverser = traverser); } }
[tinkerpop] branch tp4 updated: removed InternalFunction and NestedFunction interfaces. We are not using them right now. We will probably need something like this later, but cleaning up what we aren't
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 The following commit(s) were added to refs/heads/tp4 by this push: new 2769868 removed InternalFunction and NestedFunction interfaces. We are not using them right now. We will probably need something like this later, but cleaning up what we aren't currently using. 2769868 is described below commit 2769868037d278445dcc06588fa26925be9649ce Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 10:13:17 2019 -0600 removed InternalFunction and NestedFunction interfaces. We are not using them right now. We will probably need something like this later, but cleaning up what we aren't currently using. --- .../tinkerpop/machine/function/BranchFunction.java | 2 +- .../machine/function/InternalFunction.java | 26 - .../tinkerpop/machine/function/NestedFunction.java | 27 -- .../machine/function/filter/FilterFilter.java | 4 ++-- .../tinkerpop/machine/function/map/MapMap.java | 3 +-- .../machine/function/reduce/GroupCountReduce.java | 3 +-- 6 files changed, 5 insertions(+), 60 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/BranchFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/BranchFunction.java index a58a6f8..73a7fb2 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/BranchFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/BranchFunction.java @@ -27,7 +27,7 @@ import java.util.Map; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface BranchFunction extends InternalFunction { +public interface BranchFunction extends CFunction { public Selector getBranchSelector(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/InternalFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/InternalFunction.java deleted file mode 100644 index 75809ca..000 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/InternalFunction.java +++ /dev/null @@ -1,26 +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.machine.function; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public interface InternalFunction extends CFunction { - -} diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/NestedFunction.java deleted file mode 100644 index b31045d..000 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/NestedFunction.java +++ /dev/null @@ -1,27 +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.machine.function; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public interface NestedFunction extends InternalFunction { - - -} diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/filter/FilterFilter.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/filter/FilterFilter.java index ec841e4..ba29b88 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/filter/FilterFilter.java +++ b/java/core/sr
[tinkerpop] branch tp4 updated: changed the Coefficient API to not return this. Thus, mult(), sum(), unity(), zero() means to mutate the current coefficient. The semantics are now obvious.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 95bca40 changed the Coefficient API to not return this. Thus, mult(), sum(), unity(), zero() means to mutate the current coefficient. The semantics are now obvious. 95bca40 is described below commit 95bca40fedacfbcf9623365e70723ccf8114eb90 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 10:09:42 2019 -0600 changed the Coefficient API to not return this. Thus, mult(), sum(), unity(), zero() means to mutate the current coefficient. The semantics are now obvious. --- .../org/apache/tinkerpop/machine/bytecode/Bytecode.java | 2 +- .../apache/tinkerpop/machine/bytecode/Compilation.java| 3 ++- .../apache/tinkerpop/machine/bytecode/Instruction.java| 2 +- .../apache/tinkerpop/machine/coefficient/Coefficient.java | 10 +- .../tinkerpop/machine/coefficient/LongCoefficient.java| 15 +-- 5 files changed, 14 insertions(+), 18 deletions(-) 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 6370911..2737b52 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 @@ -42,7 +42,7 @@ public final class Bytecode implements Cloneable { /// public void addInstruction(final Coefficient coefficient, final String op, final Object... args) { -this.instructions.add(new Instruction<>(coefficient.clone(), op, args)); +this.instructions.add(new Instruction<>(coefficient, op, args)); coefficient.unity(); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index c22bb15..a72bc1d 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -46,7 +46,8 @@ public final class Compilation implements Serializable { BytecodeUtil.strategize(bytecode); this.processorFactory = BytecodeUtil.getProcessorFactory(bytecode).get(); this.traverserFactory = BytecodeUtil.getTraverserFactory(bytecode).get(); -this.unity = BytecodeUtil.getCoefficient(bytecode).get().clone().unity(); +this.unity = BytecodeUtil.getCoefficient(bytecode).get().clone(); +this.unity.unity(); this.functions = BytecodeUtil.compile(bytecode); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Instruction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Instruction.java index b5fb297..d065768 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Instruction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Instruction.java @@ -36,7 +36,7 @@ public final class Instruction { private final Set labels = new HashSet<>(); public Instruction(final Coefficient coefficient, final String op, final Object... args) { -this.coefficient = coefficient; +this.coefficient = coefficient.clone(); this.op = op; this.args = args; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/Coefficient.java b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/Coefficient.java index 31484c7..cdcbfe7 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/Coefficient.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/Coefficient.java @@ -25,15 +25,15 @@ import java.io.Serializable; */ public interface Coefficient extends Cloneable, Serializable { -public Coefficient sum(final Coefficient other); +public void sum(final Coefficient other); -public Coefficient multiply(final Coefficient other); +public void multiply(final Coefficient other); -public Coefficient set(final C other); +public void set(final C other); -public Coefficient unity(); +public void unity(); -public Coefficient zero(); +public void zero(); public boolean isUnity(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/LongCoefficient.java b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/LongCoefficient.java index 44d41aa..1c8feb4 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/LongCoefficient.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/coefficient/LongCoefficient.java @@ -34,33 +34,28 @@ public class LongCoefficient implements Coefficient {
[tinkerpop] branch tp4 updated: Getting smart about where to clone() and how to deal with traverser creation.
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 The following commit(s) were added to refs/heads/tp4 by this push: new f603883 Getting smart about where to clone() and how to deal with traverser creation. f603883 is described below commit f60388327679fbdb4e994b8c4cab4deb1ed98b76 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 10:04:35 2019 -0600 Getting smart about where to clone() and how to deal with traverser creation. --- .../tinkerpop/machine/bytecode/Compilation.java | 14 ++ .../tinkerpop/machine/traverser/COPTraverser.java| 14 +- .../machine/traverser/COPTraverserFactory.java | 8 +--- .../tinkerpop/machine/traverser/CORTraverser.java| 5 ++--- .../machine/traverser/CORTraverserFactory.java | 6 +++--- .../tinkerpop/machine/traverser/COTraverser.java | 7 +-- .../machine/traverser/COTraverserFactory.java| 6 +++--- .../tinkerpop/machine/traverser/Traverser.java | 20 +--- .../machine/traverser/TraverserFactory.java | 4 ++-- .../org/apache/tinkerpop/machine/beam/FilterFn.java | 5 + .../org/apache/tinkerpop/machine/beam/InitialFn.java | 2 +- .../org/apache/tinkerpop/machine/beam/ReduceFn.java | 2 +- .../apache/tinkerpop/machine/beam/RepeatEndFn.java | 8 .../apache/tinkerpop/machine/beam/RepeatStartFn.java | 14 +++--- .../machine/beam/sideeffect/BasicReducer.java| 4 ++-- .../apache/tinkerpop/machine/pipes/BranchStep.java | 4 ++-- .../apache/tinkerpop/machine/pipes/FilterStep.java | 9 ++--- .../apache/tinkerpop/machine/pipes/InitialStep.java | 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 2 +- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 16 20 files changed, 74 insertions(+), 78 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index 98c86a4..c22bb15 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -65,31 +65,37 @@ public final class Compilation implements Serializable { this.processor = this.processorFactory.mint(this); } +private Traverser prepareTraverser(final Traverser traverser) { +final Traverser clone = traverser.clone(); +clone.coefficient().unity(); +return clone; +} + public Traverser mapTraverser(final Traverser traverser) { this.reset(); this.prepareProcessor(); -this.processor.addStart(traverser); +this.processor.addStart(this.prepareTraverser(traverser)); return this.processor.next(); } public Traverser mapObject(final S object) { this.reset(); this.prepareProcessor(); -this.processor.addStart(this.traverserFactory.create(this.unity, object)); + this.processor.addStart(this.traverserFactory.create(this.functions.get(0), object)); return this.processor.next(); } public Iterator> flatMapTraverser(final Traverser traverser) { this.reset(); this.prepareProcessor(); -this.processor.addStart(traverser); +this.processor.addStart(this.prepareTraverser(traverser)); return this.processor; } public boolean filterTraverser(final Traverser traverser) { this.reset(); this.prepareProcessor(); -this.processor.addStart(traverser); +this.processor.addStart(this.prepareTraverser(traverser)); return this.processor.hasNext(); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/COPTraverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/COPTraverser.java index 33e0933..af76943 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/COPTraverser.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/COPTraverser.java @@ -20,7 +20,6 @@ package org.apache.tinkerpop.machine.traverser; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.CFunction; -import org.apache.tinkerpop.machine.function.ReduceFunction; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -46,13 +45,10 @@ public class COPTraverser extends COTraverser { } @Override -public Traverser split(final CFunction function, final E newObject) { -final COPTraverser clone = new COPTraverser<>( -function instanceof ReduceFunction ? -function.coefficient().clone().unity() : - function.coefficient().clone()
[tinkerpop] branch tp4 updated: have repeat().times() working. Created a new Traverser named CORTraverser which has coefficient, object, and repeat. Also support for unparameterized emit(). Getting re
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 The following commit(s) were added to refs/heads/tp4 by this push: new e9b14e6 have repeat().times() working. Created a new Traverser named CORTraverser which has coefficient, object, and repeat. Also support for unparameterized emit(). Getting really close. e9b14e6 is described below commit e9b14e65bb5b5f89732582fe307abdfdcc704d52 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 09:14:14 2019 -0600 have repeat().times() working. Created a new Traverser named CORTraverser which has coefficient, object, and repeat. Also support for unparameterized emit(). Getting really close. --- .../org/apache/tinkerpop/language/Traversal.java | 13 +++ .../apache/tinkerpop/language/TraversalSource.java | 2 ++ .../java/org/apache/tinkerpop/language/__.java | 4 +++ .../tinkerpop/machine/bytecode/Argument.java | 6 ++-- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 7 .../apache/tinkerpop/machine/bytecode/Symbols.java | 9 - .../tinkerpop/machine/coefficient/Coefficient.java | 4 +-- .../machine/coefficient/LongCoefficient.java | 8 ++--- .../machine/function/filter/HasKeyFilter.java | 2 +- .../machine/function/filter/HasKeyValueFilter.java | 2 +- .../machine/function/filter/IsFilter.java | 2 +- .../{filter/IsFilter.java => map/LoopsMap.java}| 21 --- .../CoefficientVerificationStrategy.java} | 38 .../TraverserFactoryStrategy.java} | 31 ++-- .../tinkerpop/machine/traverser/COPTraverser.java | 28 +-- .../{COTraverser.java => CORTraverser.java}| 37 --- .../CORTraverserFactory.java} | 33 - .../tinkerpop/machine/traverser/COTraverser.java | 36 +-- .../machine/traverser/EmptyTraverser.java | 14 .../tinkerpop/machine/traverser/Traverser.java | 23 +--- .../tinkerpop/machine/traverser/TraverserSet.java | 8 ++--- .../org/apache/tinkerpop/util/StringFactory.java | 5 +++ .../org/apache/tinkerpop/machine/beam/Beam.java| 2 +- .../apache/tinkerpop/machine/beam/RepeatEndFn.java | 16 + .../tinkerpop/machine/beam/RepeatStartFn.java | 10 +++--- .../apache/tinkerpop/machine/beam/BeamTest.java| 7 +++- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 42 +++--- .../apache/tinkerpop/machine/pipes/PipesTest.java | 8 - 28 files changed, 240 insertions(+), 178 deletions(-) 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 01740c3..ce9b788 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 @@ -90,6 +90,10 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal emit() { +return this.emit(__.constant(true)); +} + public Traversal emit(final Traversal emitTraversal) { final Instruction lastInstruction = this.bytecode.lastInstruction(); if (lastInstruction.op().equals(Symbols.REPEAT)) @@ -164,6 +168,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal loops() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.LOOPS); +return (Traversal) this; +} + public Traversal map(final Traversal mapTraversal) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal.bytecode); return (Traversal) this; @@ -188,6 +197,10 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal times(final int times) { +return this.until(__.loops().is(times)); +} + public Traversal unfold() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNFOLD); return (Traversal) this; 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 04d558f..2e37fce 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 @@ -23,6 +23,7 @@ import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.strategy.CoefficientStrategy; +import org.apache.tinkerpop.machine.strategy.CoefficientVerificationStrategy; import org.apache.tinkerpop.machine.strategy.St
[tinkerpop] branch tp4 updated: Path is now an interface. BasicPath an implementation. Have started down the Traverser species route with COTraverser and COPTraverser.
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 The following commit(s) were added to refs/heads/tp4 by this push: new e0d74e3 Path is now an interface. BasicPath an implementation. Have started down the Traverser species route with COTraverser and COPTraverser. e0d74e3 is described below commit e0d74e3ec09379cdce425fc749a4d70e6e0d2195 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 07:49:55 2019 -0600 Path is now an interface. BasicPath an implementation. Have started down the Traverser species route with COTraverser and COPTraverser. --- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 8 +++- .../tinkerpop/machine/function/map/PathMap.java| 3 +- .../traverser/{Path.java => BasicPath.java}| 7 ++-- .../{CompleteTraverser.java => COPTraverser.java} | 26 ++--- ...verserFactory.java => COPTraverserFactory.java} | 14 ++- .../{CompleteTraverser.java => COTraverser.java} | 45 ++ ...averserFactory.java => COTraverserFactory.java} | 14 ++- .../tinkerpop/machine/traverser/EmptyPath.java}| 38 +++--- .../apache/tinkerpop/machine/traverser/Path.java | 44 +++-- .../tinkerpop/machine/traverser/Traverser.java | 4 +- .../tinkerpop/machine/traverser/TraverserSet.java | 6 +-- .../machine/traverser/TraverserSetTest.java| 6 +-- .../tinkerpop/machine/beam/util/TopologyUtil.java | 8 ++-- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 4 +- .../apache/tinkerpop/machine/pipes/SourceStep.java | 15 +--- 15 files changed, 113 insertions(+), 129 deletions(-) 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 f62cd4a..581fc9d 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 @@ -40,7 +40,7 @@ import org.apache.tinkerpop.machine.function.reduce.GroupCountReduce; import org.apache.tinkerpop.machine.function.reduce.SumReduce; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.strategy.Strategy; -import org.apache.tinkerpop.machine.traverser.CompleteTraverserFactory; +import org.apache.tinkerpop.machine.traverser.COPTraverserFactory; import org.apache.tinkerpop.machine.traverser.TraverserFactory; import java.lang.reflect.InvocationTargetException; @@ -122,7 +122,11 @@ public final class BytecodeUtil { } public static Optional> getTraverserFactory(final Bytecode bytecode) { -return Optional.of(new CompleteTraverserFactory()); +for (final Instruction instruction : bytecode.getInstructions()) { +if (instruction.op().equals(Symbols.PATH)) +return Optional.of(COPTraverserFactory.instance()); +} +return Optional.of(COPTraverserFactory.instance()); } public static List> compile(final Bytecode bytecode) { diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/map/PathMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/map/PathMap.java index 59f2a0e..39d7514 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/map/PathMap.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/map/PathMap.java @@ -23,6 +23,7 @@ import org.apache.tinkerpop.machine.bytecode.CompilationCircle; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.AbstractFunction; import org.apache.tinkerpop.machine.function.MapFunction; +import org.apache.tinkerpop.machine.traverser.BasicPath; import org.apache.tinkerpop.machine.traverser.Path; import org.apache.tinkerpop.machine.traverser.Traverser; @@ -45,7 +46,7 @@ public class PathMap extends AbstractFunction implements MapFunction traverser) { if (!this.compilationCircle.isEmpty()) { final Path oldPath = traverser.path(); -final Path newPath = new Path(); +final Path newPath = new BasicPath(); for (int i = 0; i < oldPath.size(); i++) { newPath.add(oldPath.labels(i), this.compilationCircle.next().mapObject(oldPath.object(i)).object()); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/Path.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/BasicPath.java similarity index 93% copy from java/core/src/main/java/org/apache/tinkerpop/machine/traverser/Path.java copy to java/core/src/main/java/org/apache/tinkerpop/machine/traverser/BasicPath.java index 263c63b..0413814 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traverser/Path.java +
[tinkerpop] branch tp4 updated: added RepeatDeadEnd in Beam so that if too many loops have occurred, then an exception is thrown. This is necessary since looping in Beam is accomplished with exponents
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 The following commit(s) were added to refs/heads/tp4 by this push: new 2cb5a83 added RepeatDeadEnd in Beam so that if too many loops have occurred, then an exception is thrown. This is necessary since looping in Beam is accomplished with exponents (concatenation) and thus, there is an upper limit to the amount of repititions possible. 2cb5a83 is described below commit 2cb5a838335d9eb6f179aa10fff6746422b42f50 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 07:20:40 2019 -0600 added RepeatDeadEnd in Beam so that if too many loops have occurred, then an exception is thrown. This is necessary since looping in Beam is accomplished with exponents (concatenation) and thus, there is an upper limit to the amount of repititions possible. --- .../machine/function/branch/RepeatBranch.java| 20 ++-- .../apache/tinkerpop/machine/beam/AbstractFn.java| 9 + .../java/org/apache/tinkerpop/machine/beam/Beam.java | 3 +-- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 6 +- .../org/apache/tinkerpop/machine/beam/InitialFn.java | 2 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 1 - .../org/apache/tinkerpop/machine/beam/ReduceFn.java | 8 +--- .../machine/beam/{Fn.java => RepeatDeadEndFn.java} | 11 +-- .../apache/tinkerpop/machine/beam/RepeatEndFn.java | 15 +-- .../apache/tinkerpop/machine/beam/RepeatStartFn.java | 15 +-- .../tinkerpop/machine/beam/util/TopologyUtil.java| 11 ++- .../org/apache/tinkerpop/machine/beam/BeamTest.java | 4 ++-- 12 files changed, 26 insertions(+), 79 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java index 07ba398..45fe3fe 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java @@ -21,8 +21,6 @@ package org.apache.tinkerpop.machine.function.branch; import org.apache.tinkerpop.machine.bytecode.Compilation; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.AbstractFunction; -import org.apache.tinkerpop.machine.function.BranchFunction; -import org.apache.tinkerpop.machine.function.branch.selector.Selector; import org.apache.tinkerpop.util.StringFactory; import java.util.LinkedHashMap; @@ -33,9 +31,9 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class RepeatBranch extends AbstractFunction implements BranchFunction { +public final class RepeatBranch extends AbstractFunction { -private final Map> compilations; +private final Map> compilations; // TODO: remove private Compilation repeatCompilation; private Compilation untilCompilation; private Compilation emitCompilation; @@ -105,18 +103,4 @@ public class RepeatBranch extends AbstractFunction implements BranchFun public boolean hasEndPredicates() { return this.hasEndPredicates; } - -public Map> getCompilations() { -return this.compilations; -} - -@Override -public Selector getBranchSelector() { -return null; -} - -@Override -public Map>> getBranches() { -return null; -} } diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java index 99fbcca..17a28f2 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java @@ -21,14 +21,12 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.transforms.DoFn; import org.apache.tinkerpop.machine.function.CFunction; import org.apache.tinkerpop.machine.traverser.Traverser; -import org.apache.tinkerpop.machine.traverser.TraverserSet; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public abstract class AbstractFn extends DoFn, Traverser> implements Fn { +public abstract class AbstractFn extends DoFn, Traverser> implements Fn { -protected final TraverserSet traverserSet = new TraverserSet<>(); protected final CFunction function; protected AbstractFn(final CFunction function) { @@ -36,11 +34,6 @@ public abstract class AbstractFn extends DoFn, Traverse } @Override -public void addStart(final Traverser traverser) { -this.traverserSet.add(traverser); -} - -@Override public String toString() { return this.function.toStrin
[tinkerpop] branch tp4 updated: added a repeat() optimization where if there are not start or end predicates, then certain data paths and functions can be ignored from the stream.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 744ae44 added a repeat() optimization where if there are not start or end predicates, then certain data paths and functions can be ignored from the stream. 744ae44 is described below commit 744ae448774c3ef6f9a20e2312348294eac4d43f Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 06:56:53 2019 -0600 added a repeat() optimization where if there are not start or end predicates, then certain data paths and functions can be ignored from the stream. --- .../machine/function/branch/RepeatBranch.java | 18 ++ .../tinkerpop/machine/beam/util/TopologyUtil.java | 24 +--- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 72 -- 3 files changed, 72 insertions(+), 42 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java index b60104a..07ba398 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java @@ -41,6 +41,8 @@ public class RepeatBranch extends AbstractFunction implements BranchFun private Compilation emitCompilation; private int untilLocation = 0; private int emitLocation = 0; +private boolean hasStartPredicates = false; +private boolean hasEndPredicates = false; public RepeatBranch(final Coefficient coefficient, final Set labels, final List arguments) { super(coefficient, labels); @@ -51,9 +53,17 @@ public class RepeatBranch extends AbstractFunction implements BranchFun if ('e' == type) { this.emitCompilation = (Compilation) arguments.get(i + 1); this.emitLocation = location++; +if (this.emitLocation < 3) +this.hasStartPredicates = true; +else +this.hasEndPredicates = true; } else if ('u' == type) { this.untilCompilation = (Compilation) arguments.get(i + 1); this.untilLocation = location++; +if (this.untilLocation < 3) +this.hasStartPredicates = true; +else +this.hasEndPredicates = true; } else { this.repeatCompilation = (Compilation) arguments.get(i + 1); location = 3; @@ -88,6 +98,14 @@ public class RepeatBranch extends AbstractFunction implements BranchFun return this.untilLocation; } +public boolean hasStartPredicates() { +return this.hasStartPredicates; +} + +public boolean hasEndPredicates() { +return this.hasEndPredicates; +} + public Map> getCompilations() { return this.compilations; } diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/util/TopologyUtil.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/util/TopologyUtil.java index a0d3a01..1c555a1 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/util/TopologyUtil.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/util/TopologyUtil.java @@ -86,19 +86,23 @@ public class TopologyUtil { final TupleTag> repeatLoop = new TupleTag<>(); sink = source; for (int i = 0; i < Beam.MAX_REPETIONS; i++) { -final RepeatStartFn startFn = new RepeatStartFn<>(repeatFunction, repeatDone, repeatLoop, i == Beam.MAX_REPETIONS - 1); -PCollectionTuple outputs = (PCollectionTuple) sink.apply(ParDo.of(startFn).withOutputTags(repeatLoop, TupleTagList.of(repeatDone))); -outputs.getAll().values().forEach(c -> c.setCoder(new TraverserCoder())); -repeatSinks.add(outputs.get(repeatDone)); -sink = outputs.get(repeatLoop); +if (repeatFunction.hasStartPredicates()) { +final RepeatStartFn startFn = new RepeatStartFn<>(repeatFunction, repeatDone, repeatLoop, i == Beam.MAX_REPETIONS - 1); +final PCollectionTuple outputs = (PCollectionTuple) sink.apply(ParDo.of(startFn).withOutputTags(repeatLoop, TupleTagList.of(repeatDone))); +outputs.getAll().values().forEach(c -> c.setCoder(new TraverserCoder())); +repeatSinks.add(outputs.get(repeatDone)); +sink = outputs.get(repeatLoop); +} for (final CFunction ff : repeatFunction.getRepeat().getFunctions()) { sink = Topolog
[tinkerpop] branch tp4 updated: added RepeatStartFn and RepeatEndFn to Beam to wrap the repeat-loop. This is necessary to handle the case when until() and emit() are split on opposite sides of repeat(
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 The following commit(s) were added to refs/heads/tp4 by this push: new 5784db0 added RepeatStartFn and RepeatEndFn to Beam to wrap the repeat-loop. This is necessary to handle the case when until() and emit() are split on opposite sides of repeat(). 5784db0 is described below commit 5784db039cc6ce882529de65165fc9e8ae54f84d Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 06:45:06 2019 -0600 added RepeatStartFn and RepeatEndFn to Beam to wrap the repeat-loop. This is necessary to handle the case when until() and emit() are split on opposite sides of repeat(). --- .../beam/{RepeatFn.java => RepeatEndFn.java} | 40 -- .../beam/{RepeatFn.java => RepeatStartFn.java} | 38 .../tinkerpop/machine/beam/util/TopologyUtil.java | 15 +--- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 +++ .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +++ 5 files changed, 34 insertions(+), 69 deletions(-) diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatFn.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatEndFn.java similarity index 69% copy from java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatFn.java copy to java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatEndFn.java index 90fdb3b..56e34d8 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatFn.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/RepeatEndFn.java @@ -27,7 +27,7 @@ import org.apache.tinkerpop.machine.traverser.Traverser; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class RepeatFn extends AbstractFn { +public class RepeatEndFn extends AbstractFn { private final int untilLocation; private final int emitLocation; @@ -36,13 +36,12 @@ public class RepeatFn extends AbstractFn { private final TupleTag> repeatDone; private final TupleTag> repeatLoop; private final boolean deadEnd; -private final boolean first; -public RepeatFn(final RepeatBranch repeatBranch, -final TupleTag> repeatDone, -final TupleTag> repeatLoop, -final boolean deadEnd, final boolean first) { +public RepeatEndFn(final RepeatBranch repeatBranch, + final TupleTag> repeatDone, + final TupleTag> repeatLoop, + final boolean deadEnd) { super(repeatBranch); this.untilLocation = repeatBranch.getUntilLocation(); this.untilCompilation = repeatBranch.getUntil(); @@ -51,43 +50,19 @@ public class RepeatFn extends AbstractFn { this.repeatDone = repeatDone; this.repeatLoop = repeatLoop; this.deadEnd = deadEnd; -this.first = first; } @ProcessElement public void processElement(final @DoFn.Element Traverser traverser, final MultiOutputReceiver out) { -if (1 == this.untilLocation) { -if (this.untilCompilation.filterTraverser(traverser.clone())) { -out.get(this.repeatDone).output(traverser.clone()); -} else if (2 == this.emitLocation && this.emitCompilation.filterTraverser(traverser.clone())) { -out.get(this.repeatDone).output(traverser.clone()); -out.get(this.repeatLoop).output(traverser.clone()); -} else { -out.get(this.repeatLoop).output(traverser.clone()); -} -return; -} else if (1 == this.emitLocation) { -if (this.emitCompilation.filterTraverser(traverser.clone())) -out.get(this.repeatDone).output(traverser.clone()); -if (2 == this.untilLocation && this.untilCompilation.filterTraverser(traverser.clone())) -out.get(this.repeatDone).output(traverser.clone()); -else -out.get(this.repeatLoop).output(traverser.clone()); -return; -} else if (this.first) { -out.get(this.repeatLoop).output(traverser.clone()); -return; -} - - if (3 == this.untilLocation) { if (this.untilCompilation.filterTraverser(traverser.clone())) { out.get(this.repeatDone).output(traverser.clone()); } else if (4 == this.emitLocation && this.emitCompilation.filterTraverser(traverser.clone())) { out.get(this.repeatDone).output(traverser.clone()); out.get(this.repeatLoop).output(traverser.clone()); -} else +} else { out.get(this.repeatLoop).output(traverser.clone()); +
[tinkerpop] branch tp4 updated: have emit().until().repeat() working in Pipes and Beam. I've generalized the semantics a bit from TP3. Basically, the order in which until() and emit() are provided det
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 The following commit(s) were added to refs/heads/tp4 by this push: new d4b0a27 have emit().until().repeat() working in Pipes and Beam. I've generalized the semantics a bit from TP3. Basically, the order in which until() and emit() are provided determines whether an emit can happen before an until break. d4b0a27 is described below commit d4b0a2791d1bdd075f54b6dcf57cceaaab331183 Author: Marko A. Rodriguez AuthorDate: Sun Mar 17 06:17:27 2019 -0600 have emit().until().repeat() working in Pipes and Beam. I've generalized the semantics a bit from TP3. Basically, the order in which until() and emit() are provided determines whether an emit can happen before an until break. --- .../java/org/apache/tinkerpop/language/__.java | 2 +- .../machine/function/branch/RepeatBranch.java | 39 +-- .../org/apache/tinkerpop/machine/beam/Beam.java| 2 +- .../apache/tinkerpop/machine/beam/RepeatFn.java| 76 +--- .../machine/beam/serialization/ObjectCoder.java| 62 - .../tinkerpop/machine/beam/util/TopologyUtil.java | 2 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 14 +++- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 80 -- .../apache/tinkerpop/machine/pipes/PipesTest.java | 14 +++- 9 files changed, 184 insertions(+), 107 deletions(-) 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 b874a57..baa1671 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -37,7 +37,7 @@ public class __ { return __.start().c(coefficient); } -public static Traversal constant(final S constant) { +public static Traversal constant(final R constant) { return __.start().constant(constant); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java index ff0026a..b60104a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/function/branch/RepeatBranch.java @@ -36,18 +36,31 @@ import java.util.Set; public class RepeatBranch extends AbstractFunction implements BranchFunction { private final Map> compilations; -private final Compilation repeat; -private final Compilation until; +private Compilation repeatCompilation; +private Compilation untilCompilation; +private Compilation emitCompilation; +private int untilLocation = 0; +private int emitLocation = 0; public RepeatBranch(final Coefficient coefficient, final Set labels, final List arguments) { super(coefficient, labels); +int location = 1; this.compilations = new LinkedHashMap<>(); for (int i = 0; i < arguments.size(); i = i + 2) { +final Character type = (Character) arguments.get(i); +if ('e' == type) { +this.emitCompilation = (Compilation) arguments.get(i + 1); +this.emitLocation = location++; +} else if ('u' == type) { +this.untilCompilation = (Compilation) arguments.get(i + 1); +this.untilLocation = location++; +} else { +this.repeatCompilation = (Compilation) arguments.get(i + 1); +location = 3; +} + this.compilations.put((Character) arguments.get(i), (Compilation) arguments.get(i + 1)); } - -this.repeat = this.compilations.get('r'); -this.until = this.compilations.get('u'); } @Override @@ -56,11 +69,23 @@ public class RepeatBranch extends AbstractFunction implements BranchFun } public Compilation getRepeat() { -return this.repeat; +return this.repeatCompilation; } public Compilation getUntil() { -return this.until; +return this.untilCompilation; +} + +public Compilation getEmit() { +return this.emitCompilation; +} + +public int getEmitLocation() { +return this.emitLocation; +} + +public int getUntilLocation() { +return this.untilLocation; } public Map> getCompilations() { 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 8512057..9c85597 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
[tinkerpop] branch tp4 updated: staged emit() and until() wrt repeat(). Trying to figure out the best way to represent the ordering for Pipes and Beam...
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 The following commit(s) were added to refs/heads/tp4 by this push: new d026ee8 staged emit() and until() wrt repeat(). Trying to figure out the best way to represent the ordering for Pipes and Beam... d026ee8 is described below commit d026ee8c40fd1e0d9d219018522474feb4786ce6 Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 16:07:05 2019 -0600 staged emit() and until() wrt repeat(). Trying to figure out the best way to represent the ordering for Pipes and Beam... --- .../org/apache/tinkerpop/language/Traversal.java | 22 +++-- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 2 +- .../tinkerpop/machine/bytecode/Compilation.java| 11 +++ .../tinkerpop/machine/bytecode/Instruction.java| 6 ++ .../machine/function/branch/RepeatBranch.java | 23 -- .../apache/tinkerpop/machine/beam/RepeatFn.java| 2 +- 6 files changed, 56 insertions(+), 10 deletions(-) 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 357c73d..01740c3 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.bytecode.Compilation; +import org.apache.tinkerpop.machine.bytecode.Instruction; import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.coefficient.LongCoefficient; @@ -89,6 +90,15 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal emit(final Traversal emitTraversal) { +final Instruction lastInstruction = this.bytecode.lastInstruction(); +if (lastInstruction.op().equals(Symbols.REPEAT)) +lastInstruction.addArgs('e', emitTraversal.bytecode); +else +this.bytecode.addInstruction(this.currentCoefficient, Symbols.REPEAT, 'e', emitTraversal.bytecode); +return this; +} + public Traversal filter(final Traversal filterTraversal) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal.bytecode); return this; @@ -165,7 +175,11 @@ public class Traversal implements Iterator { } public Traversal repeat(final Traversal repeatTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.REPEAT, repeatTraversal.bytecode); +final Instruction lastInstruction = this.bytecode.lastInstruction(); +if (lastInstruction.op().equals(Symbols.REPEAT)) +lastInstruction.addArgs('r', repeatTraversal.bytecode); +else +this.bytecode.addInstruction(this.currentCoefficient, Symbols.REPEAT, 'r', repeatTraversal.bytecode); return this; } @@ -192,7 +206,11 @@ public class Traversal implements Iterator { } public Traversal until(final Traversal untilTraversal) { -this.bytecode.lastInstruction().addArg(untilTraversal.bytecode); +final Instruction lastInstruction = this.bytecode.lastInstruction(); +if (lastInstruction.op().equals(Symbols.REPEAT)) +lastInstruction.addArgs('u', untilTraversal.bytecode); +else +this.bytecode.addInstruction(this.currentCoefficient, Symbols.REPEAT, 'u', untilTraversal.bytecode); return this; } 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 f4ad337..f62cd4a 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 @@ -175,7 +175,7 @@ public final class BytecodeUtil { case Symbols.PATH: return new PathMap<>(coefficient, labels, Compilation.compile(instruction.args())); case Symbols.REPEAT: -return new RepeatBranch(coefficient, labels, Compilation.compile(instruction.args())); +return new RepeatBranch<>(coefficient, labels, Compilation.repeatCompile(instruction.args())); case Symbols.SUM: return new SumReduce<>(coefficient, labels); case Symbols.UNFOLD: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index e1fa5
[tinkerpop] branch tp4 updated: fixed a naming bug in Traversal.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 7e49bb6 fixed a naming bug in Traversal. 7e49bb6 is described below commit 7e49bb6fa9ef0ec26226ce74c3e4efaf60ac38e7 Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 11:17:47 2019 -0600 fixed a naming bug in Traversal. --- java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java | 2 +- java/core/src/main/java/org/apache/tinkerpop/language/__.java| 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8949b4f..357c73d 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 @@ -79,7 +79,7 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal constance(final R constant) { +public Traversal constant(final R constant) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.CONSTANT, constant); return (Traversal) this; } 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 ef6099a..b874a57 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -38,7 +38,7 @@ public class __ { } public static Traversal constant(final S constant) { -return __.start().constance(constant); +return __.start().constant(constant); } public static Traversal incr() {
[tinkerpop] branch tp4 updated: Bytecode has no reference to Traversal. As it should be as Traversal is Gremlin specific.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 29d3f0f Bytecode has no reference to Traversal. As it should be as Traversal is Gremlin specific. 29d3f0f is described below commit 29d3f0fa34fe4f1d94be523143918b98a20176de Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 11:08:07 2019 -0600 Bytecode has no reference to Traversal. As it should be as Traversal is Gremlin specific. --- .../org/apache/tinkerpop/language/Traversal.java | 30 -- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 2 +- .../tinkerpop/machine/bytecode/Instruction.java| 8 +- 3 files changed, 18 insertions(+), 22 deletions(-) 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 a8dbe1a..8949b4f 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 @@ -60,7 +60,7 @@ public class Traversal implements Iterator { } public Traversal by(final Traversal byTraversal) { -this.bytecode.lastInstruction().addArg(byTraversal); +this.bytecode.lastInstruction().addArg(byTraversal.bytecode); return this; } @@ -70,12 +70,12 @@ public class Traversal implements Iterator { } public Traversal choose(final Traversal predicate, final Traversal trueTraversal, final Traversal falseTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN_ELSE, predicate, trueTraversal, falseTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN_ELSE, predicate.bytecode, trueTraversal.bytecode, falseTraversal.bytecode); return (Traversal) this; } public Traversal choose(final Traversal predicate, final Traversal trueTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN, predicate, trueTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN, predicate.bytecode, trueTraversal.bytecode); return (Traversal) this; } @@ -90,7 +90,7 @@ public class Traversal implements Iterator { } public Traversal filter(final Traversal filterTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal.bytecode); return this; } @@ -105,7 +105,7 @@ public class Traversal implements Iterator { } public Traversal> has(final Traversal, K> keyTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY, keyTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY, keyTraversal.bytecode); return (Traversal) this; } @@ -115,17 +115,17 @@ public class Traversal implements Iterator { } public Traversal> has(final Traversal, K> keyTraversal, final V value) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, keyTraversal, value); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, keyTraversal.bytecode, value); return (Traversal) this; } public Traversal> has(final K key, final Traversal, V> valueTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, key, valueTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, key, valueTraversal.bytecode); return (Traversal) this; } public Traversal> has(final Traversal, K> keyTraversal, final Traversal, V> valueTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, keyTraversal, valueTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.HAS_KEY_VALUE, keyTraversal.bytecode, valueTraversal.bytecode); return (Traversal) this; } @@ -140,7 +140,7 @@ public class Traversal implements Iterator { } public Traversal is(final Traversal objectTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, objectTraversal); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, objectTraversal.bytecode); return this; } @@ -155,7 +155,7 @@ public class Traversal implements Iterator { } public Traversal map(final Traversal mapTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal); +this.bytecode.addInstruction(this.curr
[tinkerpop] branch tp4 updated: added __.constant() and ConstantMap function. Tested whether is(traversal) works. It does.
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 The following commit(s) were added to refs/heads/tp4 by this push: new fa04dff added __.constant() and ConstantMap function. Tested whether is(traversal) works. It does. fa04dff is described below commit fa04dff29cf8cc0dc458608fa97f5aaf2d350792 Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 10:55:30 2019 -0600 added __.constant() and ConstantMap function. Tested whether is(traversal) works. It does. --- .../java/org/apache/tinkerpop/language/Traversal.java | 5 + .../main/java/org/apache/tinkerpop/language/__.java| 8 .../tinkerpop/machine/bytecode/BytecodeUtil.java | 5 - .../org/apache/tinkerpop/machine/bytecode/Symbols.java | 3 +++ .../tinkerpop/machine/coefficient/Coefficient.java | 2 ++ .../tinkerpop/machine/coefficient/LongCoefficient.java | 5 + .../tinkerpop/machine/function/filter/IsFilter.java| 11 ++- .../{filter/IsFilter.java => map/ConstantMap.java} | 18 +- .../org/apache/tinkerpop/machine/pipes/PipesTest.java | 3 ++- 9 files changed, 44 insertions(+), 16 deletions(-) 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 cc8c811..a8dbe1a 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 @@ -79,6 +79,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal constance(final R constant) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CONSTANT, constant); +return (Traversal) this; +} + public Traversal count() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); return (Traversal) this; 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 d0febb8..ef6099a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -37,6 +37,10 @@ public class __ { return __.start().c(coefficient); } +public static Traversal constant(final S constant) { +return __.start().constance(constant); +} + public static Traversal incr() { return __.start().incr(); } @@ -45,6 +49,10 @@ public class __ { return __.start().is(object); } +public static Traversal is(final Traversal objectTraversal) { +return __.start().is(objectTraversal); +} + public static Traversal sum() { return __.start().sum(); } 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 b508e24..1b4d0e7 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 @@ -31,6 +31,7 @@ import org.apache.tinkerpop.machine.function.filter.IdentityFilter; import org.apache.tinkerpop.machine.function.filter.IsFilter; import org.apache.tinkerpop.machine.function.flatmap.UnfoldFlatMap; import org.apache.tinkerpop.machine.function.initial.InjectInitial; +import org.apache.tinkerpop.machine.function.map.ConstantMap; import org.apache.tinkerpop.machine.function.map.IncrMap; import org.apache.tinkerpop.machine.function.map.MapMap; import org.apache.tinkerpop.machine.function.map.PathMap; @@ -149,6 +150,8 @@ public final class BytecodeUtil { Compilation.compileOne(instruction.args()[0]), Compilation.compileOne(instruction.args()[1]), Compilation.compileOne(instruction.args()[2])); +case Symbols.CONSTANT: +return new ConstantMap<>(coefficient, labels, instruction.args()[0]); case Symbols.COUNT: return new CountReduce<>(coefficient, labels); case Symbols.FILTER: @@ -164,7 +167,7 @@ public final class BytecodeUtil { case Symbols.INJECT: return new InjectInitial<>(coefficient, labels, instruction.args()); case Symbols.IS: -return new IsFilter<>(coefficient, labels, instruction.args()[0]); +return new IsFilter<>(coefficient, labels, Argument.create(instruction.args()[0])); case Symbols.INCR: return new IncrMap<>(coefficient, labels); case Symbols.MAP: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symb
[tinkerpop] branch tp4 updated: Moved Symbols to bytecode/ as this is language indepedent. private'd a bunch of classes. Renamed CompilationRing to CompilationCircle so as not to confuse people with t
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 The following commit(s) were added to refs/heads/tp4 by this push: new 15e13d9 Moved Symbols to bytecode/ as this is language indepedent. private'd a bunch of classes. Renamed CompilationRing to CompilationCircle so as not to confuse people with the other use of Ring in Coefficients. 15e13d9 is described below commit 15e13d95b7d85be97cc353ebf3f79d5b2d4aa64d Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 10:38:49 2019 -0600 Moved Symbols to bytecode/ as this is language indepedent. private'd a bunch of classes. Renamed CompilationRing to CompilationCircle so as not to confuse people with the other use of Ring in Coefficients. --- .../org/apache/tinkerpop/language/Traversal.java | 1 + .../apache/tinkerpop/language/TraversalSource.java | 1 + .../tinkerpop/machine/bytecode/BytecodeUtil.java | 1 - ...CompilationRing.java => CompilationCircle.java} | 9 +-- .../{language => machine/bytecode}/Symbols.java| 2 +- .../tinkerpop/machine/function/CFunction.java | 2 + .../tinkerpop/machine/function/map/PathMap.java| 10 +-- .../machine/strategy/CoefficientStrategy.java | 2 +- .../machine/strategy/IdentityStrategy.java | 2 +- .../tinkerpop/machine/traverser/TraverserSet.java | 17 +--- .../tinkerpop/util/FastNoSuchElementException.java | 2 +- .../machine/traverser/TraverserSetTest.java| 91 ++ .../machine/beam/strategy/BeamStrategy.java| 2 +- .../tinkerpop/machine/pipes/AbstractStep.java | 4 +- .../tinkerpop/machine/pipes/BarrierStep.java | 2 +- .../apache/tinkerpop/machine/pipes/BranchStep.java | 2 +- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 2 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 2 +- .../tinkerpop/machine/pipes/FlatMapStep.java | 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 2 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 2 +- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 2 +- .../apache/tinkerpop/machine/pipes/SourceStep.java | 2 +- .../org/apache/tinkerpop/machine/pipes/Step.java | 2 +- .../machine/pipes/strategy/PipesStrategy.java | 2 +- 26 files changed, 125 insertions(+), 45 deletions(-) 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 a4c51ba..cc8c811 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.bytecode.Compilation; +import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.coefficient.LongCoefficient; import org.apache.tinkerpop.machine.traverser.Path; 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 44d7b4a..04d558f 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 @@ -19,6 +19,7 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.strategy.CoefficientStrategy; 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 19c8a07..b508e24 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 @@ -18,7 +18,6 @@ */ package org.apache.tinkerpop.machine.bytecode; -import org.apache.tinkerpop.language.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.CFunction; import org.apache.tinkerpop.machine.function.barrier.StallBarrier; diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CompilationRing.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CompilationCircle.java similarity index 88% rename from java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CompilationRing.java rename to
[tinkerpop] branch tp4 updated: renamed all the packages to be singular -- not plural. E.g. functions is function. strategies is strategy. This is the pattern we used in TP3 and I just forgot to follo
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 The following commit(s) were added to refs/heads/tp4 by this push: new d4f0b8e renamed all the packages to be singular -- not plural. E.g. functions is function. strategies is strategy. This is the pattern we used in TP3 and I just forgot to follow it. d4f0b8e is described below commit d4f0b8e8ef7e70adcb3a512172fcaa0351e9ea5b Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 10:10:03 2019 -0600 renamed all the packages to be singular -- not plural. E.g. functions is function. strategies is strategy. This is the pattern we used in TP3 and I just forgot to follow it. --- .../org/apache/tinkerpop/language/Traversal.java | 8 ++-- .../apache/tinkerpop/language/TraversalSource.java | 6 +-- .../tinkerpop/machine/bytecode/Bytecode.java | 2 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 46 +++--- .../tinkerpop/machine/bytecode/Compilation.java| 8 ++-- .../tinkerpop/machine/bytecode/Instruction.java| 2 +- .../{coefficients => coefficient}/Coefficient.java | 2 +- .../LongCoefficient.java | 2 +- .../{functions => function}/AbstractFunction.java | 4 +- .../{functions => function}/BarrierFunction.java | 4 +- .../{functions => function}/BranchFunction.java| 4 +- .../machine/{functions => function}/CFunction.java | 4 +- .../{functions => function}/FilterFunction.java| 4 +- .../{functions => function}/FlatMapFunction.java | 4 +- .../{functions => function}/InitialFunction.java | 2 +- .../{functions => function}/InternalFunction.java | 2 +- .../{functions => function}/MapFunction.java | 5 +-- .../{functions => function}/NestedFunction.java| 2 +- .../{functions => function}/ReduceFunction.java| 4 +- .../barrier/StallBarrier.java | 12 +++--- .../branch/ChooseBranch.java | 12 +++--- .../branch/RepeatBranch.java | 10 ++--- .../branch/UnionBranch.java| 12 +++--- .../branch/selector/HasNextSelector.java | 4 +- .../branch/selector/Selector.java | 4 +- .../branch/selector/TrueSelector.java | 4 +- .../filter/FilterFilter.java | 12 +++--- .../filter/HasKeyFilter.java | 10 ++--- .../filter/HasKeyValueFilter.java | 10 ++--- .../filter/IdentityFilter.java | 10 ++--- .../{functions => function}/filter/IsFilter.java | 10 ++--- .../flatmap/UnfoldFlatMap.java | 10 ++--- .../initial/InjectInitial.java | 8 ++-- .../{functions => function}/map/IncrMap.java | 10 ++--- .../{functions => function}/map/MapMap.java| 14 +++ .../{functions => function}/map/PathMap.java | 12 +++--- .../reduce/CountReduce.java| 10 ++--- .../reduce/GroupCountReduce.java | 14 +++ .../{functions => function}/reduce/SumReduce.java | 10 ++--- .../machine/processor/EmptyProcessor.java | 2 +- .../machine/processor/EmptyProcessorFactory.java | 2 +- .../tinkerpop/machine/processor/Processor.java | 2 +- .../machine/processor/ProcessorFactory.java| 2 +- .../CoefficientStrategy.java | 6 +-- .../{strategies => strategy}/IdentityStrategy.java | 2 +- .../machine/{strategies => strategy}/Strategy.java | 2 +- .../CompleteTraverser.java | 8 ++-- .../CompleteTraverserFactory.java | 4 +- .../{traversers => traverser}/EmptyTraverser.java | 6 +-- .../machine/{traversers => traverser}/Path.java| 2 +- .../{traversers => traverser}/Traverser.java | 17 .../TraverserFactory.java | 4 +- .../{traversers => traverser}/TraverserSet.java| 2 +- .../org/apache/tinkerpop/util/EmptyIterator.java} | 23 +-- .../org/apache/tinkerpop/util/StringFactory.java | 2 +- .../apache/tinkerpop/machine/TraversalTest.java| 5 --- .../machine/compiler/BytecodeUtilTest.java | 3 -- .../apache/tinkerpop/machine/beam/AbstractFn.java | 6 +-- .../org/apache/tinkerpop/machine/beam/Beam.java| 6 +-- .../tinkerpop/machine/beam/BeamProcessor.java | 4 +- .../apache/tinkerpop/machine/beam/BranchFn.java| 6 +-- .../apache/tinkerpop/machine/beam/FilterFn.java| 4 +- .../apache/tinkerpop/machine/beam/FlatMapFn.java | 4 +- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 2 +- .../apache/tinkerpop/machine/beam/InitialFn.java | 6 +-- .../org/apache/tinkerpop/machine/beam/MapFn.java | 4 +- .../apache/tinkerpop/machine/beam/OutputStep.java | 2 +- .../apache/tinkerpop/machi
[tinkerpop] branch tp4 updated: simplified Pipes greatly. Now that Pipes is only for in-memory OLTP and no longer tied with GraphComputer and other execution models, the next()/hasNext() code of the v
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 The following commit(s) were added to refs/heads/tp4 by this push: new 9f7386c simplified Pipes greatly. Now that Pipes is only for in-memory OLTP and no longer tied with GraphComputer and other execution models, the next()/hasNext() code of the various steps can be extremely simple. This should greatly speed up Pipes in TP4 releative to TP3. 9f7386c is described below commit 9f7386c0ba1aa1b61b3cfa3dbf08001aac216b4e Author: Marko A. Rodriguez AuthorDate: Sat Mar 16 10:02:03 2019 -0600 simplified Pipes greatly. Now that Pipes is only for in-memory OLTP and no longer tied with GraphComputer and other execution models, the next()/hasNext() code of the various steps can be extremely simple. This should greatly speed up Pipes in TP4 releative to TP3. --- .../tinkerpop/machine/pipes/AbstractStep.java | 28 +-- .../tinkerpop/machine/pipes/BarrierStep.java | 9 +++--- .../apache/tinkerpop/machine/pipes/BranchStep.java | 8 -- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 5 .../apache/tinkerpop/machine/pipes/FilterStep.java | 5 ++-- .../tinkerpop/machine/pipes/FlatMapStep.java | 27 +++--- .../tinkerpop/machine/pipes/InitialStep.java | 7 +++-- .../apache/tinkerpop/machine/pipes/MapStep.java| 12 +++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 15 ++ .../apache/tinkerpop/machine/pipes/ReduceStep.java | 7 ++--- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 11 ++-- .../pipes/{AbstractStep.java => SourceStep.java} | 32 +++--- .../org/apache/tinkerpop/machine/pipes/Step.java | 2 -- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 +-- 14 files changed, 82 insertions(+), 90 deletions(-) diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java index 70c0f9c..3f8b0a3 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java @@ -19,8 +19,6 @@ package org.apache.tinkerpop.machine.pipes; import org.apache.tinkerpop.machine.functions.CFunction; -import org.apache.tinkerpop.machine.traversers.Traverser; -import org.apache.tinkerpop.machine.traversers.TraverserSet; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -28,37 +26,13 @@ import org.apache.tinkerpop.machine.traversers.TraverserSet; public abstract class AbstractStep implements Step { final CFunction function; -private final Step previousStep; -private TraverserSet traverserSet = new TraverserSet<>(); +protected final Step previousStep; public AbstractStep(final Step previousStep, final CFunction function) { this.previousStep = previousStep; this.function = function; } -public void addStart(final Traverser traverser) { -this.traverserSet.add(traverser); -} - -@Override -public boolean hasNext() { -return !this.traverserSet.isEmpty() || this.previousStep.hasNext(); -} - -@Override -public abstract Traverser next(); - -final Traverser getPreviousTraverser() { -return this.traverserSet.isEmpty() ? -this.previousStep.next() : -this.traverserSet.remove(); -} - -@Override -public void reset() { -this.traverserSet.clear(); -} - @Override public String toString() { return this.function.toString(); diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java index b0b7f02..063ac64 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java @@ -19,8 +19,8 @@ package org.apache.tinkerpop.machine.pipes; import org.apache.tinkerpop.machine.functions.BarrierFunction; -import org.apache.tinkerpop.machine.pipes.util.InMemoryBarrier; import org.apache.tinkerpop.machine.pipes.util.Barrier; +import org.apache.tinkerpop.machine.pipes.util.InMemoryBarrier; import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.Collections; @@ -45,8 +45,8 @@ public class BarrierStep extends AbstractStep { @Override public Traverser next() { if (!this.done) { -while (super.hasNext()) { - this.barrier.update(this.barrierFunction.apply(super.getPreviousTraverser(), this.barrier.get())); +while (this.previousStep.hasNext()) { + this.barri
[tinkerpop] branch tp4 updated: cleaned up Pipes codebase. It is nice that Pipes isn't so front and center with OLTP and OLAP necessary functionality. The code is so much simpler and --- so much less
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 The following commit(s) were added to refs/heads/tp4 by this push: new 5e48abc cleaned up Pipes codebase. It is nice that Pipes isn't so front and center with OLTP and OLAP necessary functionality. The code is so much simpler and --- so much less code at that. 5e48abc is described below commit 5e48abc8b0454770ec862f894671d58eacf3 Author: Marko A. Rodriguez AuthorDate: Thu Mar 14 13:22:49 2019 -0600 cleaned up Pipes codebase. It is nice that Pipes isn't so front and center with OLTP and OLAP necessary functionality. The code is so much simpler and --- so much less code at that. --- .../tinkerpop/machine/pipes/AbstractStep.java | 17 +-- .../tinkerpop/machine/pipes/BarrierStep.java | 4 +-- .../apache/tinkerpop/machine/pipes/BranchStep.java | 16 +- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 2 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 35 ++ .../tinkerpop/machine/pipes/FlatMapStep.java | 4 +-- .../tinkerpop/machine/pipes/InitialStep.java | 2 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 10 +++ .../apache/tinkerpop/machine/pipes/RepeatStep.java | 12 10 files changed, 50 insertions(+), 54 deletions(-) diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java index ac6f73e..70c0f9c 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/AbstractStep.java @@ -27,11 +27,11 @@ import org.apache.tinkerpop.machine.traversers.TraverserSet; */ public abstract class AbstractStep implements Step { -protected final CFunction function; -protected final AbstractStep previousStep; -protected TraverserSet traverserSet = new TraverserSet<>(); +final CFunction function; +private final Step previousStep; +private TraverserSet traverserSet = new TraverserSet<>(); -public AbstractStep(final AbstractStep previousStep, final CFunction function) { +public AbstractStep(final Step previousStep, final CFunction function) { this.previousStep = previousStep; this.function = function; } @@ -48,11 +48,10 @@ public abstract class AbstractStep implements Step { @Override public abstract Traverser next(); -protected Traverser getPreviousTraverser() { -if (!this.traverserSet.isEmpty()) -return this.traverserSet.remove(); -else -return this.previousStep.next(); +final Traverser getPreviousTraverser() { +return this.traverserSet.isEmpty() ? +this.previousStep.next() : +this.traverserSet.remove(); } @Override diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java index 09c60e0..b0b7f02 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java @@ -36,9 +36,9 @@ public class BarrierStep extends AbstractStep { private boolean done = false; private Iterator output = Collections.emptyIterator(); -public BarrierStep(final AbstractStep previousStep, final BarrierFunction barrierFunction) { +BarrierStep(final Step previousStep, final BarrierFunction barrierFunction) { super(previousStep, barrierFunction); -this.barrier = new InMemoryBarrier<>(barrierFunction.getInitialValue()); // move to strategy determination +this.barrier = new InMemoryBarrier<>(barrierFunction.getInitialValue()); // TODO: move to strategy determination this.barrierFunction = barrierFunction; } diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BranchStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BranchStep.java index 93ede4b..a850f5c 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BranchStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BranchStep.java @@ -37,9 +37,9 @@ public final class BranchStep extends AbstractStep { private final Selector branchSelector; private final Map>> branches; -private Iterator> output = Collections.emptyIterator(); +private Iterator> nextTraversers = Collections.emptyIterator(); -public BranchStep(final AbstractStep previousStep, final BranchFuncti
[tinkerpop] 39/41: BranchFuncions are no longer Java functions. Given that the implementation of branching is heavily dependent on processing engine semantics, BranchFunctions simply expose a branch s
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 bfa48cbe9cdcaa53faa2925128039e0917fca53d Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 11:35:06 2019 -0600 BranchFuncions are no longer Java functions. Given that the implementation of branching is heavily dependent on processing engine semantics, BranchFunctions simply expose a branch selector and a Map of selector/traversal pairs. It is up to the processor provider to use that information to construct a branching topology. For Pipes, its pull-based. For Beam, its push-based. --- .../org/apache/tinkerpop/language/Symbols.java | 5 ++ .../org/apache/tinkerpop/language/Traversal.java | 5 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 5 ++ .../machine/functions/AbstractFunction.java| 2 +- .../machine/functions/BranchFunction.java | 5 +- .../machine/functions/branch/ChooseBranch.java | 14 + .../machine/functions/branch/RepeatBranch.java | 19 +- .../machine/functions/branch/UnionBranch.java | 15 + .../machine/functions/filter/FilterFilter.java | 4 +- .../machine/functions/filter/HasKeyFilter.java | 2 +- .../functions/filter/HasKeyValueFilter.java| 2 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 2 +- .../machine/functions/flatmap/UnfoldFlatMap.java | 2 +- .../machine/functions/initial/InjectInitial.java | 2 +- .../tinkerpop/machine/functions/map/IncrMap.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../tinkerpop/machine/functions/map/PathMap.java | 2 +- .../machine/functions/reduce/CountReduce.java | 2 +- .../machine/functions/reduce/GroupCountReduce.java | 2 +- .../machine/functions/reduce/SumReduce.java| 2 +- .../tinkerpop/machine/traversers/Traverser.java| 4 -- .../apache/tinkerpop/machine/beam/BranchFn.java| 11 ++-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 ++ .../apache/tinkerpop/machine/pipes/BranchStep.java | 43 - .../org/apache/tinkerpop/machine/pipes/Pipes.java | 7 ++- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 70 ++ .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 28 files changed, 152 insertions(+), 88 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 efeeaad..5ec8eea 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 @@ -34,6 +34,7 @@ public final class Symbols { // INSTRUCTION OPS +public static final String CHOOSE_IF_THEN = "chooseIfThen"; public static final String CHOOSE_IF_THEN_ELSE = "chooseIfThenElse"; public static final String COUNT = "count"; public static final String FILTER = "filter"; @@ -53,6 +54,10 @@ public final class Symbols { public Type getOpType(final String op) { switch (op) { +case CHOOSE_IF_THEN: +return Type.BRANCH; +case CHOOSE_IF_THEN_ELSE: +return Type.BRANCH; case COUNT: return Type.REDUCE; case FILTER: 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 9a17bc5..5ba6f68 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 @@ -68,6 +68,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal choose(final Traversal predicate, final Traversal trueTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN, predicate, trueTraversal); +return (Traversal) this; +} + public Traversal count() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); return (Traversal) this; 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 b7110a3..6959063 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 @@ -137,6 +137,11 @@ public final class BytecodeUtil { final Coefficient coefficient = instruction.coefficient(); final Set labels = instruction.labels(); switch (op) { +case Symbols.CHOOSE_IF_THEN: +retur
[tinkerpop] 41/41: playing around with Reducers and Barriers. Trying to merge them into one. Had it working for Pipes, but Beam requires that a Combiner return a single object -- not an iterator of ob
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 fb4930bad2e8d816f217ef83d7fedb283d57f3b9 Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 13:56:14 2019 -0600 playing around with Reducers and Barriers. Trying to merge them into one. Had it working for Pipes, but Beam requires that a Combiner return a single object -- not an iterator of objects. Still playing. --- .../tinkerpop/machine/pipes/BarrierStep.java | 14 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 4 +-- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 12 +++-- .../pipes/util/{Reducer.java => Barrier.java} | 2 +- .../{BasicReducer.java => InMemoryBarrier.java}| 4 +-- .../{BasicReducer.java => InMemoryReducer.java}| 31 -- .../tinkerpop/machine/pipes/util/Reducer.java | 10 --- .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java index a61a0b9..09c60e0 100644 --- a/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java +++ b/java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java @@ -19,8 +19,8 @@ package org.apache.tinkerpop.machine.pipes; import org.apache.tinkerpop.machine.functions.BarrierFunction; -import org.apache.tinkerpop.machine.pipes.util.BasicReducer; -import org.apache.tinkerpop.machine.pipes.util.Reducer; +import org.apache.tinkerpop.machine.pipes.util.InMemoryBarrier; +import org.apache.tinkerpop.machine.pipes.util.Barrier; import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.Collections; @@ -31,14 +31,14 @@ import java.util.Iterator; */ public class BarrierStep extends AbstractStep { -private final Reducer reducer; +private final Barrier barrier; private final BarrierFunction barrierFunction; private boolean done = false; private Iterator output = Collections.emptyIterator(); public BarrierStep(final AbstractStep previousStep, final BarrierFunction barrierFunction) { super(previousStep, barrierFunction); -this.reducer = new BasicReducer<>(barrierFunction.getInitialValue()); +this.barrier = new InMemoryBarrier<>(barrierFunction.getInitialValue()); // move to strategy determination this.barrierFunction = barrierFunction; } @@ -46,10 +46,10 @@ public class BarrierStep extends AbstractStep { public Traverser next() { if (!this.done) { while (super.hasNext()) { - this.reducer.update(this.barrierFunction.apply(super.getPreviousTraverser(), this.reducer.get())); + this.barrier.update(this.barrierFunction.apply(super.getPreviousTraverser(), this.barrier.get())); } this.done = true; -this.output = (Iterator) this.barrierFunction.createIterator(this.reducer.get()); +this.output = (Iterator) this.barrierFunction.createIterator(this.barrier.get()); } return (Traverser) this.output.next(); } @@ -62,7 +62,7 @@ public class BarrierStep extends AbstractStep { @Override public void reset() { super.reset(); -this.reducer.reset(); +this.barrier.reset(); this.done = false; } } 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 a54d9f6..8dc493c 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 @@ -28,7 +28,7 @@ import org.apache.tinkerpop.machine.functions.InitialFunction; import org.apache.tinkerpop.machine.functions.MapFunction; import org.apache.tinkerpop.machine.functions.ReduceFunction; import org.apache.tinkerpop.machine.functions.branch.RepeatBranch; -import org.apache.tinkerpop.machine.pipes.util.BasicReducer; +import org.apache.tinkerpop.machine.pipes.util.InMemoryReducer; import org.apache.tinkerpop.machine.processor.Processor; import org.apache.tinkerpop.machine.traversers.Traverser; @@ -64,7 +64,7 @@ public final class Pipes implements Processor { nextStep = new BarrierStep(previousStep, (BarrierFunction) function); else if (function instanceof ReduceFunction) nextStep = new ReduceStep(previousStep, (ReduceFunction) function, -new BasicReducer<>(((ReduceFunction) function).getInitialValue()), compilation.getTraverserFactory()); +new InMemoryReducer
[tinkerpop] 29/41: add CoefficientStrategy which knows how to propagate the unity coefficient to all child bytecode. Also, it assumes LongCoefficient (95 percent of cases) if no withCoefficient() is p
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 d4e4503c342efd2e9fb4aff885b10f07bb823079 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 07:57:36 2019 -0600 add CoefficientStrategy which knows how to propagate the unity coefficient to all child bytecode. Also, it assumes LongCoefficient (95 percent of cases) if no withCoefficient() is provided to the TraversalSource. Added our first by() modulation support to path()-step. CompilationRing is used in an analagous fashion to FunctionRing in TP3. Finally cleaned up ProcessorFactory to now take a Compilation. There is a hard line where Bytecode is no longer the currency of the machine, but a C [...] --- .../org/apache/tinkerpop/language/Traversal.java | 4 +- .../apache/tinkerpop/language/TraversalSource.java | 2 + .../tinkerpop/machine/bytecode/BytecodeUtil.java | 5 +-- .../tinkerpop/machine/bytecode/Compilation.java| 17 - .../CompilationRing.java} | 44 +- .../tinkerpop/machine/functions/map/PathMap.java | 18 - .../machine/processor/EmptyProcessorFactory.java | 5 +-- .../machine/processor/ProcessorFactory.java| 11 +- .../machine/strategies/CoefficientStrategy.java| 21 ++- .../org/apache/tinkerpop/machine/beam/Beam.java| 29 ++ .../tinkerpop/machine/beam/BeamProcessor.java | 7 ++-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 ++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 11 +++--- .../tinkerpop/machine/pipes/PipesProcessor.java| 10 ++--- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 7 .../tinkerpop/machine/pipes/util/BasicReducer.java | 7 .../tinkerpop/machine/pipes/util/Reducer.java | 2 + .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 18 files changed, 133 insertions(+), 74 deletions(-) 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 e620314..92ae122 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 @@ -52,7 +52,7 @@ public class Traversal implements Iterator { return this; } -public Traversal by(final Traversal byTraversal) { +public Traversal by(final Traversal byTraversal) { this.bytecode.lastInstruction().addArg(byTraversal); return this; } @@ -120,7 +120,7 @@ public class Traversal implements Iterator { private final void prepareTraversal() { if (null == this.compilation) -this.compilation = Compilation.compile(bytecode); +this.compilation = Compilation.compile(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 355ab61..e42c8dd 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.processor.ProcessorFactory; +import org.apache.tinkerpop.machine.strategies.CoefficientStrategy; import org.apache.tinkerpop.machine.strategies.Strategy; /** @@ -32,6 +33,7 @@ public class TraversalSource { protected TraversalSource() { this.bytecode = new Bytecode<>(); +this.bytecode.addSourceInstruction(Symbols.WITH_STRATEGY, CoefficientStrategy.class); } public TraversalSource withCoefficient(final Class> coefficient) { 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 635e787..0f129f2 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 @@ -47,11 +47,10 @@ import java.util.Set; */ public final class BytecodeUtil { -public static Bytecode strategize(final Bytecode bytecode) { +public static void strategize(final Bytecode bytecode) { for (final Strategy strategy : BytecodeUtil.getStrategies(bytecode)) { BytecodeUtil.strategize(bytecode, strategy); } -return bytecode; } private static void strategize(final Bytecode bytecode, Strategy strategy) { @@ -147,7 +146,7 @@ public final class BytecodeUtil { case Symbols.MAP: return new MapMap<>(coef
[tinkerpop] 28/41: InternalFunctions is a super interface to BranchFunction and NestedFunction. getInternals() (crappy name for now) allow access to Function compilations.
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 e26ca81c52474cc491c77b6f12171399053f154e Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 07:03:23 2019 -0600 InternalFunctions is a super interface to BranchFunction and NestedFunction. getInternals() (crappy name for now) allow access to Function compilations. --- .../org/apache/tinkerpop/machine/functions/BranchFunction.java | 3 --- .../apache/tinkerpop/machine/functions/InternalFunction.java | 7 +-- .../apache/tinkerpop/machine/functions/branch/UnionBranch.java | 10 ++ .../tinkerpop/machine/functions/filter/FilterFilter.java | 7 +++ .../org/apache/tinkerpop/machine/functions/map/MapMap.java | 7 +++ .../src/main/java/org/apache/tinkerpop/machine/beam/Beam.java | 7 --- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java index 8092095..8f7965f 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java @@ -21,7 +21,6 @@ package org.apache.tinkerpop.machine.functions; import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.Iterator; -import java.util.List; import java.util.function.Function; /** @@ -29,6 +28,4 @@ import java.util.function.Function; */ public interface BranchFunction extends Function, Iterator>>, InternalFunction { -public List>> getBranches(); - } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java index a2ce8e1..9481137 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java @@ -18,12 +18,15 @@ */ package org.apache.tinkerpop.machine.functions; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; +import org.apache.tinkerpop.machine.bytecode.Compilation; + +import java.util.List; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ public interface InternalFunction extends CFunction { +public List> getInternals(); + } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java index c2f7a21..6f72b48 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java @@ -22,12 +22,10 @@ import org.apache.tinkerpop.machine.bytecode.Compilation; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.AbstractFunction; import org.apache.tinkerpop.machine.functions.BranchFunction; -import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.traversers.Traverser; import org.apache.tinkerpop.util.MultiIterator; import org.apache.tinkerpop.util.StringFactory; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -60,11 +58,7 @@ public final class UnionBranch extends AbstractFunction>> getBranches() { -final List>> branches = new ArrayList<>(); -for (final Compilation compilation : this.branches) { -branches.add(compilation.getFunctions()); -} -return branches; +public List> getInternals() { +return (List) this.branches; } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java index b7b25bd..f9e86d4 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java @@ -26,6 +26,8 @@ import org.apache.tinkerpop.machine.functions.NestedFunction; import org.apache.tinkerpop.machine.traversers.Traverser; import org.apache.tinkerpop.util.StringFactory; +import java.util.Collections; +import java.util.List; import java.util.Set; /** @@ -49,4 +51,9 @@ public final class FilterFilter extends AbstractFunction implemen public String toString() { return StringFactory.makeFunctionString(this, this.internalFilter); } + +@Override +public List> getInternals() { +
[tinkerpop] 33/41: repeat() implemented in Apache Beam. Its not pretty, but it works. I'm not that confident with the Beam API. Once I fully grock it, I will do a massive cleanup of the Beam compiler.
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 e21924fcd2cba64e1e8c88e70c092c72cfd053c4 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 15:28:59 2019 -0600 repeat() implemented in Apache Beam. Its not pretty, but it works. I'm not that confident with the Beam API. Once I fully grock it, I will do a massive cleanup of the Beam compiler. --- .../org/apache/tinkerpop/language/Symbols.java | 3 + .../org/apache/tinkerpop/language/Traversal.java | 5 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../machine/functions/branch/RepeatBranch.java | 18 -- .../machine/functions/flatmap/UnfoldFlatMap.java | 68 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 27 +++-- .../apache/tinkerpop/machine/beam/BranchFn.java| 2 +- .../machine/beam/{BranchFn.java => RepeatFn.java} | 28 ++--- .../apache/tinkerpop/machine/beam/BeamTest.java| 10 ++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 +- 10 files changed, 147 insertions(+), 21 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 8b4ebef..a11321f 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 @@ -47,6 +47,7 @@ public final class Symbols { public static final String PATH = "path"; public static final String REPEAT = "repeat"; public static final String SUM = "sum"; +public static final String UNFOLD = "unfold"; public static final String UNION = "union"; public Type getOpType(final String op) { @@ -77,6 +78,8 @@ public final class Symbols { return Type.BRANCH; case SUM: return Type.REDUCE; +case UNFOLD: +return Type.FLATMAP; case UNION: return Type.BRANCH; default: 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 cf90d24..fdcc8d4 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 @@ -153,6 +153,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal unfold() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNFOLD); +return (Traversal) this; +} + public Traversal union(final Traversal traversal, Traversal... traversals) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversal, traversals); return (Traversal) this; 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 42922b7..eea1df5 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,6 +28,7 @@ import org.apache.tinkerpop.machine.functions.filter.HasKeyFilter; import org.apache.tinkerpop.machine.functions.filter.HasKeyValueFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; +import org.apache.tinkerpop.machine.functions.flatmap.UnfoldFlatMap; import org.apache.tinkerpop.machine.functions.initial.InjectInitial; import org.apache.tinkerpop.machine.functions.map.IncrMap; import org.apache.tinkerpop.machine.functions.map.MapMap; @@ -161,6 +162,8 @@ public final class BytecodeUtil { return new RepeatBranch(coefficient, labels, Compilation.compile(instruction.args())); case Symbols.SUM: return new SumReduce<>(coefficient, labels); +case Symbols.UNFOLD: +return new UnfoldFlatMap<>(coefficient, labels); case Symbols.UNION: return new UnionBranch<>(coefficient, labels, Compilation.compile(instruction.args())); default: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java index f8ec403..c31b7c1 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java @@ -22,6 +22,7 @@ import org.apache.tinkerpop.machine.bytecode.Compilation;
[tinkerpop] 22/41: found a mutation bug in Apache Beam. Even when you filter, you have to make sure that its a new object being added to the output. Thus, you have to clone the object.
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 0af118912b2d55f0b9c88fccd1eb3693133e86f1 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 14:02:47 2019 -0600 found a mutation bug in Apache Beam. Even when you filter, you have to make sure that its a new object being added to the output. Thus, you have to clone the object. --- .../apache/tinkerpop/machine/strategies/IdentityStrategy.java | 5 - .../tinkerpop/machine/traversers/CompleteTraverser.java | 10 -- .../java/org/apache/tinkerpop/machine/traversers/Path.java| 4 ++-- .../org/apache/tinkerpop/machine/traversers/Traverser.java| 11 +-- .../org/apache/tinkerpop/machine/traversers/TraverserSet.java | 2 +- .../main/java/org/apache/tinkerpop/machine/beam/FilterFn.java | 5 +++-- .../main/java/org/apache/tinkerpop/machine/beam/MapFn.java| 11 ++- .../test/java/org/apache/tinkerpop/machine/beam/BeamTest.java | 2 +- 8 files changed, 14 insertions(+), 36 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java index 9b91e2c..92ef157 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java @@ -28,6 +28,9 @@ public final class IdentityStrategy implements Strategy { @Override public void apply(final Bytecode bytecode) { -bytecode.getInstructions().removeIf(instruction -> instruction.op().equals(Symbols.IDENTITY)); +bytecode.getInstructions().removeIf(instruction -> +instruction.op().equals(Symbols.IDENTITY) && +instruction.labels().isEmpty()); +//!instruction.coefficient().equals(unity)); } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java index b6c471e..b605da2 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java @@ -22,8 +22,6 @@ import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.functions.ReduceFunction; -import java.util.Collections; - /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ @@ -33,10 +31,6 @@ public class CompleteTraverser implements Traverser { private S object; private Path path = new Path(); -public CompleteTraverser() { - -} - public CompleteTraverser(final Coefficient coefficient, final S object) { this.coefficient = coefficient; this.object = object; @@ -54,10 +48,6 @@ public class CompleteTraverser implements Traverser { return this.path; } -public void addLabel(final String label) { -this.path.addLabels(Collections.singleton(label)); -} - @Override public Traverser split(final CFunction function, final E eObject) { final CompleteTraverser clone = new CompleteTraverser<>( diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java index 7509824..9f5b997 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java @@ -35,8 +35,8 @@ public class Path implements Serializable { } public Path(final Path path) { -path.objects.forEach(o -> objects.add(o)); -path.labels.forEach(l -> labels.add(l)); +this.objects.addAll(path.objects); +this.labels.addAll(path.labels); } public void add(final Set labels, final Object object) { diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java index 4164fe6..6484d18 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java @@ -28,7 +28,6 @@ import org.apache.tinkerpop.util.IteratorUtils; import java.io.Serializable; import java.util.Iterator; -import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -41,17 +40,9 @@ public interface Traverser extends Serializable, Cloneable { public Path path(); -public void addLabel(final String label); - -public default void addLabels(final Set lab
[tinkerpop] 25/41: small tweak.
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 bd06d2aa0f2eb0af71a0f07fa616f9b9f00dd82a Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 15:43:01 2019 -0600 small tweak. --- .../java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java | 3 +-- .../apache/tinkerpop/machine/functions/filters/IdentityTest.java| 6 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java index 88b833d..13dd6b2 100644 --- a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java +++ b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java @@ -30,10 +30,9 @@ import org.junit.jupiter.api.Test; public class PipesIdentityTest { private TraversalSource g = Gremlin.traversal().withProcessor(PipesProcessor.class).withCoefficient(LongCoefficient.class); -private IdentityTest test = new IdentityTest(); @Test public void g_injectX2X_identity() { -test.g_injectX2X_identity(g.inject(2L).identity()); +IdentityTest.g_injectX2X_identity(g.inject(2L).identity()); } } diff --git a/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java b/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java index 45d0515..4699eb7 100644 --- a/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java +++ b/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java @@ -29,7 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ public class IdentityTest { -public void g_injectX2X_identity(final Traversal traversal) { +private IdentityTest() { +// static class +} + +public static void g_injectX2X_identity(final Traversal traversal) { final List list = traversal.toList(); assertEquals(1, list.size()); assertEquals(2L, list.get(0));
[tinkerpop] 40/41: added BarrierFunction which is a generalization of Reduce. This was mentioned in the Stream Ring Theory paper and I decided to flush it out so we can do barrier() in this way. Going
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 955a9467ff4ffa113cede696dd79fff5fcb3 Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 12:52:34 2019 -0600 added BarrierFunction which is a generalization of Reduce. This was mentioned in the Stream Ring Theory paper and I decided to flush it out so we can do barrier() in this way. Going to have to generalize the concept of a Reducer. --- .../org/apache/tinkerpop/language/Symbols.java | 5 +- .../org/apache/tinkerpop/language/Traversal.java | 10 +++ .../tinkerpop/machine/bytecode/Bytecode.java | 6 -- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../machine/functions/BarrierFunction.java | 34 ++ .../machine/functions/barrier/StallBarrier.java| 58 + .../machine/functions/branch/ChooseBranch.java | 9 +-- .../machine/traversers/CompleteTraverser.java | 5 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 10 ++- .../machine/beam/util/PrimitiveVisitor.java| 72 ++ .../tinkerpop/machine/pipes/BarrierStep.java | 68 .../apache/tinkerpop/machine/pipes/BranchStep.java | 11 +++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 3 + .../apache/tinkerpop/machine/pipes/PipesTest.java | 11 +++- 14 files changed, 284 insertions(+), 21 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 5ec8eea..f86185b 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,7 @@ package org.apache.tinkerpop.language; public final class Symbols { public static enum Type { -INITIAL, MAP, FLATMAP, FILTER, REDUCE, BRANCH +BARRIER, INITIAL, MAP, FLATMAP, FILTER, REDUCE, BRANCH } // SOURCE OPS @@ -34,6 +34,7 @@ public final class Symbols { // INSTRUCTION OPS +public static final String BARRIER = "barrier"; public static final String CHOOSE_IF_THEN = "chooseIfThen"; public static final String CHOOSE_IF_THEN_ELSE = "chooseIfThenElse"; public static final String COUNT = "count"; @@ -54,6 +55,8 @@ public final class Symbols { public Type getOpType(final String op) { switch (op) { +case BARRIER: +return Type.BARRIER; case CHOOSE_IF_THEN: return Type.BRANCH; case CHOOSE_IF_THEN_ELSE: 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 5ba6f68..851b4ea 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 @@ -53,6 +53,11 @@ public class Traversal implements Iterator { return this; } +public Traversal barrier() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.BARRIER); +return this; +} + public Traversal by(final Traversal byTraversal) { this.bytecode.lastInstruction().addArg(byTraversal); return this; @@ -190,6 +195,11 @@ public class Traversal implements Iterator { this.compilation = Compilation.compile(this.bytecode); } +public Traverser nextTraverser() { +this.prepareTraversal(); +return this.compilation.getProcessor().next(); // TODO: interaction with hasNext/next and counts +} + @Override public boolean hasNext() { this.prepareTraversal(); 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 8716b7b..103bfb5 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 @@ -18,8 +18,6 @@ */ package org.apache.tinkerpop.machine.bytecode; -import org.apache.tinkerpop.language.Traversal; -import org.apache.tinkerpop.language.TraversalUtil; import org.apache.tinkerpop.machine.coefficients.Coefficient; import java.util.ArrayList; @@ -52,10 +50,6 @@ public final class Bytecode implements Cloneable { return this.instructions; } -public void removeInstruction(final Instruction instruction) { -this.instructions.remove(instruction); -} - public Instruction lastInstruction() { return this.instructions.get(this.instructions.size() - 1); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/BytecodeUtil.java b/java/core/src/main/java/org/apache/tink
[tinkerpop] 36/41: Hide .idea folder
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 f8c3ef07b0bca1109cb3cea3d2a5a091a318501b Author: Stephen Mallette AuthorDate: Wed Mar 13 11:02:21 2019 -0400 Hide .idea folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ad8c63c..ce14a15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.iml *.ipr *.iws +.idea/ target/ fileTemplates/
[tinkerpop] 08/41: updated README.
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 d8e5b4030b815782684cefd9589e6b076684 Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 08:22:49 2019 -0700 updated README. --- README.asciidoc | 44 +++- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index e791fb1..363b7c7 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -16,24 +16,26 @@ limitations under the License. == TinkerPop4 -* *gremlin-core*: A collection of Gremlin machine and language components -* *gremlin-data* -** *gremlin-graph*: Operators for processing property graph data. -*** *gremlin-neo4j*: A Neo4j implementation of the Gremlin graph primitives -*** *gremlin-tinkergraph*: A TinkerGraph implementation of the Gremlin graph primitives -* *gremlin-machines* -** *gremlin-pipes*: Java iterator implementation of the Gremlin traversal machine -** *gremlin-rxjava*: RxJava implementation of the Gremlin traversal machine -** *gremlin-beam*: Apache Beam implementation of the Gremlin traversal machine -** *gremlin-akka*: Akka implementation of the Gremlin traversal machine -* *gremlin-languages* -** *gremlin-variants* -*** *gremlin-groovy*: Groovy implementation of the Gremlin traversal language -*** *gremlin-python*: Python implementation of the Gremlin traversal language -*** *gremlin-javascript*: JavaScript implementation of the Gremlin traversal language -*** *gremlin-dotnet*: C# implementation of the Gremlin traversal language -** *gremlin-uniques* -*** *gremlin-sparql*: A SPARQL to Gremlin bytecode compiler -*** *gremlin-sql*: An SQL to Gremlin bytecode compiler -*** *gremlin-cypher*: A Cypher to Gremlin bytecode compiler -* *gremlin-test*: language test suite \ No newline at end of file +* *java*: Apache TinkerPop for Java +** *core*: A collection of machine and language components +** *data* +*** *graph*: Operators for processing property graph data. + *neo4j*: A Neo4j implementation of the graph primitives + *tinkergraph*: A TinkerGraph implementation of the graph primitives +** *machine* +*** *pipes*: Java iterator implementation of the traversal machine +*** *rxjava*: RxJava implementation of the traversal machine +*** *beam*: Apache Beam implementation of the traversal machine +*** *akka*: Akka implementation of the traversal machine +** *language* +*** *variant* + *groovy*: Groovy implementation of the Gremlin language + *scala*: Python implementation of the Gremlin language +*** *distinct* + *sparql*: A SPARQL to Gremlin bytecode compiler + *sql*: An SQL to Gremlin bytecode compiler + *cypher*: A Cypher to Gremlin bytecode compiler +* *test*: language test suite +* *python*: Apache TinkerPop for Python +* *dotnet*: Apache TinkerPop for C# +* *javascript*: Apache TinkerPop for JavaScript \ No newline at end of file
[tinkerpop] 14/41: have the first stub of Apache Beam working in TP4. I was in the most nightmarish hell for the longest time --- I didn't have the machine pom.xml have beam as a submodule so changes
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 49c7d208b85955b2f4906b21007da25b338f0b6c Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 05:42:27 2019 -0600 have the first stub of Apache Beam working in TP4. I was in the most nightmarish hell for the longest time --- I didn't have the machine pom.xml have beam as a submodule so changes I did to core did nothing. Had this serialization error and I spent a good 2 hours to ultimately realize that my code changes werent taking effect. So bad. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 + .../apache/tinkerpop/language/TraversalSource.java | 2 + .../tinkerpop/machine/bytecode/Bytecode.java | 36 ++- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../SourceInstruction.java}| 23 +++-- .../machine/coefficients/Coefficient.java | 4 +- .../machine/coefficients/LongCoefficient.java | 5 +- .../machine/functions/AbstractFunction.java| 12 +-- .../tinkerpop/machine/functions/CFunction.java | 3 +- .../machine/functions/InitialFunction.java | 4 +- .../tinkerpop/machine/functions/MapFunction.java | 3 +- .../{MapFunction.java => ReduceFunction.java} | 6 +- .../machine/functions/filter/IdentityFilter.java | 3 +- .../machine/functions/filter/IsFilter.java | 4 +- .../machine/functions/initial/InjectInitial.java | 5 +- .../tinkerpop/machine/functions/map/IncrMap.java | 5 +- .../tinkerpop/machine/functions/map/MapMap.java| 5 +- .../tinkerpop/machine/functions/map/PathMap.java | 4 +- .../{CFunction.java => reduce/BasicReducer.java} | 23 +++-- .../{map/IncrMap.java => reduce/CountReduce.java} | 17 ++-- .../{CFunction.java => reduce/Reducer.java}| 13 +-- .../{Traverser.java => CompleteTraverser.java} | 28 +++--- .../CompleteTraverserFactory.java} | 15 ++- .../apache/tinkerpop/machine/traversers/Path.java | 3 +- .../tinkerpop/machine/traversers/Traverser.java| 67 +++-- .../TraverserFactory.java} | 11 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 6 +- java/machine/beam/pom.xml | 103 .../org/apache/tinkerpop/machine/beam/Beam.java| 106 + .../tinkerpop/machine/beam/BeamProcessor.java} | 14 ++- .../apache/tinkerpop/machine/beam/FilterFn.java} | 25 +++-- .../org/apache/tinkerpop/machine/beam/MapFn.java} | 18 ++-- .../apache/tinkerpop/machine/beam/OutputStep.java} | 18 +++- .../tinkerpop/machine/beam/TraverserCoder.java | 65 + .../apache/tinkerpop/machine/beam/BeamTest.java} | 15 +-- .../tinkerpop/machine/pipes/AbstractStep.java | 2 +- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 4 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 37 ++- .../tinkerpop/machine/pipes/InitialStep.java | 9 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 14 ++- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 63 .../apache/tinkerpop/machine/pipes/PipesTest.java | 7 +- java/machine/pom.xml | 1 + java/pom.xml | 3 +- 46 files changed, 642 insertions(+), 183 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 681e26e..b302b88 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 @@ -25,6 +25,7 @@ public final class Symbols { public static final String AS = "as"; public static final String C = "c"; +public static final String COUNT = "count"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 7acdd75..f8f446c 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 @@ -62,6 +62,11 @@ public class Traversal implements Iterator { return this; } +public Traversal count() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); +return (Traversal) this; +} + public Traversal identity() { this.bytecode.addInstruction(this.curre
[tinkerpop] 38/41: Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just work without a
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 58e761de63ab5c2f89343ed2a5f70fd7a257ed4f Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 10:09:01 2019 -0600 Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just work without any special consideration in Beam. I need to get repeat() to be general -- but that is tricky given its recrussive nature. For now, a special repeat()-case exists. --- .../machine/functions/branch/UnionBranch.java | 3 +- .../machine/traversers/EmptyTraverser.java | 63 +++ .../org/apache/tinkerpop/machine/beam/Beam.java| 108 ++- .../apache/tinkerpop/machine/beam/BranchFn.java| 6 +- .../apache/tinkerpop/machine/beam/RepeatFn.java| 10 +- .../tinkerpop/machine/beam/util/TopologyUtil.java | 120 + .../apache/tinkerpop/machine/beam/BeamTest.java| 13 ++- 7 files changed, 212 insertions(+), 111 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java index f10e22c..3195a40 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java @@ -52,8 +52,7 @@ public final class UnionBranch extends AbstractFunction> apply(final Traverser traverser) { final MultiIterator> iterator = new MultiIterator<>(); for (final Compilation branch : this.branches.get(Boolean.TRUE)) { -branch.getProcessor().addStart(traverser.clone()); -iterator.addIterator(branch.getProcessor()); +iterator.addIterator(branch.addTraverser(traverser)); } return iterator; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java new file mode 100644 index 000..b2eefb8 --- /dev/null +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java @@ -0,0 +1,63 @@ +/* + * 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.machine.traversers; + +import org.apache.tinkerpop.machine.coefficients.Coefficient; +import org.apache.tinkerpop.machine.functions.CFunction; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class EmptyTraverser implements Traverser { + +private static final EmptyTraverser INSTANCE = new EmptyTraverser(); + +private EmptyTraverser() { +// for static instances +} + +@Override +public Coefficient coefficient() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain a coefficient"); +} + +@Override +public S object() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain an object"); +} + +@Override +public Path path() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain a path"); +} + +@Override +public Traverser split(CFunction function, E object) { +return INSTANCE; +} + +@Override +public Traverser clone() { +return INSTANCE; +} + +public static final EmptyTraverser instance() { +return INSTANCE; +} +} 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 c24f26f..9981082 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 @@ -20,134 +20,44 @@ package org.apache.tinkerpop
[tinkerpop] 32/41: have a much cleaner implementation of RepeatBranch. Simplified Compilation a bit.
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 1c3c607e2df1531606494cb0dd9e19d736569f3c Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 12:25:09 2019 -0600 have a much cleaner implementation of RepeatBranch. Simplified Compilation a bit. --- .../tinkerpop/machine/bytecode/Compilation.java | 5 - .../machine/functions/branch/RepeatBranch.java | 20 +--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index a3d9b6c..f973a8f 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -55,11 +55,6 @@ public final class Compilation implements Serializable { return this.processor; } -public void addTraverser(final Traverser traverser) { -this.prepareProcessor(); -this.processor.addStart(traverser); -} - public void reset() { if (null != this.processor) this.processor.reset(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java index c879373..f8ec403 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java @@ -23,9 +23,9 @@ import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.AbstractFunction; import org.apache.tinkerpop.machine.functions.BranchFunction; import org.apache.tinkerpop.machine.traversers.Traverser; +import org.apache.tinkerpop.util.IteratorUtils; import org.apache.tinkerpop.util.StringFactory; -import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -47,17 +47,15 @@ public class RepeatBranch extends AbstractFunction> apply(final Traverser traverser) { -this.repeat.addTraverser(traverser); -final List> toGo = new ArrayList<>(); -while (this.repeat.getProcessor().hasNext()) { -Traverser t = this.repeat.getProcessor().next(); -boolean loop = !this.until.filterTraverser(t); -if (loop) +this.repeat.getProcessor().addStart(traverser); +return IteratorUtils.filter(this.repeat.getProcessor(), t -> { +if (!this.until.filterTraverser(t)) { this.repeat.getProcessor().addStart(t); -else -toGo.add(t); -} -return toGo.iterator(); +return false; +} else +return true; + +}); } @Override
[tinkerpop] 17/41: have ReducerFn working in Apache Beam. Now we have count(). This means that both Pipes and Beam machines are at the same level of completition.
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 4ee2c36b57d1f1fdb888d6c32ffdf5c3fedb4ac1 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 09:15:37 2019 -0600 have ReducerFn working in Apache Beam. Now we have count(). This means that both Pipes and Beam machines are at the same level of completition. --- .../tinkerpop/machine/bytecode/Bytecode.java | 6 +- .../machine/functions/ReduceFunction.java | 2 + .../machine/functions/reduce/CountReduce.java | 5 ++ .../machine/functions/reduce/Reducer.java | 4 +- .../traversers/CompleteTraverserFactory.java | 5 +- .../machine/traversers/TraverserFactory.java | 6 +- .../tinkerpop/machine/beam/BasicAccumulator.java} | 51 .../org/apache/tinkerpop/machine/beam/Beam.java| 20 +-- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 2 + .../apache/tinkerpop/machine/beam/ReduceFn.java| 68 +++--- .../tinkerpop/machine/beam/ReducerCoder.java | 62 .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 4 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 4 +- 15 files changed, 191 insertions(+), 52 deletions(-) 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 3310070..74d4d3e 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 @@ -31,8 +31,8 @@ import java.util.List; */ public class Bytecode implements Cloneable { -public List strategies = new ArrayList<>(); -public List> instructions = new ArrayList<>(); +private List strategies = new ArrayList<>(); +private List> instructions = new ArrayList<>(); public void addStrategy(final Strategy strategy) { @@ -63,7 +63,7 @@ public class Bytecode implements Cloneable { } // this should be part of processor! -public TraverserFactory getTraverserFactory() { +public TraverserFactory getTraverserFactory() { return new CompleteTraverserFactory<>(); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java index c2ceb0d..eac368d 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java @@ -28,5 +28,7 @@ import java.util.function.BiFunction; public interface ReduceFunction extends BiFunction, E, E>, CFunction { public E getInitialValue(); + +public E merge(final E valueA, final E valueB); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java index 8c674c3..65dde8e 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java @@ -40,6 +40,11 @@ public class CountReduce extends AbstractFunction implements R } @Override +public Long merge(final Long valueA, final Long valueB) { +return valueA + valueB; +} + +@Override public Long getInitialValue() { return 0L; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java index 8434ca7..8103459 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java @@ -18,10 +18,12 @@ */ package org.apache.tinkerpop.machine.functions.reduce; +import java.io.Serializable; + /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface Reducer { +public interface Reducer extends Serializable { public S get(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java index 7d9356f..59ed747 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java @@ -23,9 +23,10 @@ import org.apache.tinkerpop.machine.coefficie
[tinkerpop] 27/41: really cleaned up the compilation process. We have a new super cool class called Compilation. It represents a strategized and function compiled Bytecode. It also enables Processor i
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 eb05677bd53d9be682399727d6169d9a6db06e7e Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 06:57:59 2019 -0600 really cleaned up the compilation process. We have a new super cool class called Compilation. It represents a strategized and function compiled Bytecode. It also enables Processor interaction. Sorta like TraversalHelper in TP3. This really cleaned up the function code and will allow us to now do nested traversal processing with ease. --- .../org/apache/tinkerpop/language/Traversal.java | 28 ++--- .../apache/tinkerpop/language/TraversalSource.java | 9 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 50 + .../tinkerpop/machine/bytecode/Compilation.java| 113 + .../machine/coefficients/LongCoefficient.java | 2 +- .../machine/functions/BranchFunction.java | 1 + .../machine/functions/InternalFunction.java| 1 - .../machine/functions/NestedFunction.java | 3 - .../machine/functions/branch/UnionBranch.java | 41 +++- .../machine/functions/filter/FilterFilter.java | 37 ++- .../tinkerpop/machine/functions/map/MapMap.java| 37 ++- .../machine/processor/EmptyProcessor.java | 2 +- .../machine/processor/EmptyProcessorFactory.java | 9 +- .../machine/processor/ProcessorFactory.java| 12 +++ .../CoefficientStrategy.java} | 13 +-- .../apache/tinkerpop/machine/traversers/Path.java | 12 +++ .../apache/tinkerpop/machine/TraversalTest.java| 4 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 5 - .../tinkerpop/machine/beam/BeamProcessor.java | 11 +- .../BeamStrategy.java} | 20 ++-- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 3 - .../tinkerpop/machine/pipes/PipesProcessor.java| 12 ++- .../machine/pipes/strategies/PipesStrategy.java} | 20 ++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 24 files changed, 268 insertions(+), 179 deletions(-) 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 f072712..e620314 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 @@ -20,11 +20,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.bytecode.Compilation; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.coefficients.LongCoefficient; -import org.apache.tinkerpop.machine.processor.EmptyProcessorFactory; -import org.apache.tinkerpop.machine.processor.Processor; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; import org.apache.tinkerpop.machine.traversers.Traverser; @@ -39,8 +37,7 @@ public class Traversal implements Iterator { protected final Bytecode bytecode; private Coefficient currentCoefficient; -private final ProcessorFactory processorFactory; -private Processor processor; +private Compilation compilation; // private long lastCount = 0L; private E lastObject = null; @@ -48,7 +45,6 @@ public class Traversal implements Iterator { protected Traversal(final Bytecode bytecode) { this.bytecode = bytecode; this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); -this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(EmptyProcessorFactory.instance()); } public Traversal as(final String label) { @@ -122,26 +118,25 @@ public class Traversal implements Iterator { /// - -private void setupProcessor() { -if (null == this.processor) -this.processor = this.processorFactory.mint(this.bytecode); +private final void prepareTraversal() { +if (null == this.compilation) +this.compilation = Compilation.compile(bytecode); } @Override public boolean hasNext() { -this.setupProcessor(); -return this.lastCount > 0 || this.processor.hasNext(); +this.prepareTraversal(); +return this.lastCount > 0 || this.compilation.getProcessor().hasNext(); } @Override public E next() { -this.setupProcessor(); +this.prepareTraversal(); if (this.lastCount > 0) { this.lastCount--; return this.lastObject; } else { -final Traverser traverser = this.processor.next(); +final
[tinkerpop] 19/41: got SumReduce working easily. Lots of Traverser tweaks. Added @dkuppitz NumberHelper class from TP3.
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 3e72077ba8a418cf36fdbbe0ae691d662056be41 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 11:32:16 2019 -0600 got SumReduce working easily. Lots of Traverser tweaks. Added @dkuppitz NumberHelper class from TP3. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 + .../tinkerpop/machine/bytecode/Bytecode.java | 7 - .../tinkerpop/machine/bytecode/BytecodeUtil.java | 9 + .../machine/functions/reduce/SumReduce.java} | 32 +- .../machine/traversers/CompleteTraverser.java | 13 +- .../tinkerpop/machine/traversers/Traverser.java| 17 +- .../machine/traversers/TraverserFactory.java | 1 + .../org/apache/tinkerpop/util/NumberHelper.java| 445 + .../apache/tinkerpop/machine/beam/AbstractFn.java | 4 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 17 +- .../apache/tinkerpop/machine/beam/InitialFn.java | 9 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 4 +- .../apache/tinkerpop/machine/beam/ReduceFn.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 4 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 8 +- .../machine/pipes/util}/BasicReducer.java | 2 +- .../tinkerpop/machine/pipes/util}/Reducer.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +- 19 files changed, 525 insertions(+), 65 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 2912789..4f5ed5f 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 @@ -39,4 +39,5 @@ public final class Symbols { public static final String INJECT = "inject"; public static final String MAP = "map"; public static final String PATH = "path"; +public static final String SUM = "sum"; } 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 ba090d9..e9ebb85 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 @@ -100,6 +100,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal sum() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.SUM); +return (Traversal) this; +} + /// 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 1529a5c..ddc1cf9 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,8 +19,6 @@ package org.apache.tinkerpop.machine.bytecode; import org.apache.tinkerpop.machine.coefficients.Coefficient; -import org.apache.tinkerpop.machine.traversers.CompleteTraverserFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; import java.util.ArrayList; import java.util.List; @@ -60,11 +58,6 @@ public class Bytecode implements Cloneable { return this.instructions.get(this.instructions.size() - 1); } -// this should be part of withProcessor! -public TraverserFactory getTraverserFactory() { -return new CompleteTraverserFactory<>(); -} - @Override public String toString() { return this.instructions.toString(); 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 538825a..61882b7 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,8 +28,11 @@ 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.functions.reduce.SumReduce; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.strategies.Strategy; +import org.apache.tinkerpop.machine.traversers.CompleteTraverserFactory; +import org.apache.tinkerpop.machine.traversers.TraverserFactory; import java.lang.reflect.InvocationTargetException; import java.util.Arra
[tinkerpop] 07/41: removed the pom.xml from the root tinkerpop directory. the parent pom is now in java/. Added a stub of documentation.
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 69551513260705860cebe05101ce0357a33d15b2 Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 08:18:58 2019 -0700 removed the pom.xml from the root tinkerpop directory. the parent pom is now in java/. Added a stub of documentation. --- docs/README.asciidoc | 1 + java/pom.xml | 203 +-- pom.xml | 217 --- 3 files changed, 196 insertions(+), 225 deletions(-) diff --git a/docs/README.asciidoc b/docs/README.asciidoc new file mode 100644 index 000..c0f7435 --- /dev/null +++ b/docs/README.asciidoc @@ -0,0 +1 @@ +This is a stub of documentation. \ No newline at end of file diff --git a/java/pom.xml b/java/pom.xml index f8f31ab..6ee5dd1 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -14,18 +14,205 @@ limitations under the License. --> http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd;> 4.0.0 + +org.apache +apache +21 + +org.apache.tinkerpop +tinkerpop +4.0.0-SNAPSHOT pom +Apache TinkerPop +A Virtual Machine and Language +http://tinkerpop.apache.org/ + + +Users +http://groups.google.com/group/gremlin-users + http://groups.google.com/group/gremlin-users + http://groups.google.com/group/gremlin-users/topics + + +Developers +dev-subscr...@tinkerpop.apache.org +dev-unsubscr...@tinkerpop.apache.org +dev-digest-subscr...@tinkerpop.apache.org + + +2019 + + +Apache 2 +http://www.opensource.org/licenses/Apache-2.0 + + + +Apache Software Foundation +http://www.apache.org/ + + + +Marko A. Rodriguez +ok...@apache.org +http://markorodriguez.com + + + +3.2.5 + core machine - -tinkerpop -org.apache.tinkerpop -4.0.0-SNAPSHOT - -Apache TinkerPop :: Java -java + +scm:git:g...@github.com:apache/tinkerpop.git + scm:git:g...@github.com:apache/tinkerpop.git +https://github.com/apache/tinkerpop + + +5.4.0 + + + + +org.junit.jupiter +junit-jupiter-api +${junit.version} +test + + +org.junit.jupiter +junit-jupiter-engine +${junit.version} +test + + + +${basedir}/target + + +org.apache.maven.plugins +maven-compiler-plugin + + +maven-enforcer-plugin +1.4.1 + + +enforce-all + +enforce + + + + + +[11.0,) + + +[3.2.5,) + + + + + + + +org.apache.rat +apache-rat-plugin +0.12 + + +rat-checks +validate + +check + + + + +false + +fileTemplates/ +**/*.iml +**/target/** + + + + + + + + + + +org.apache.maven.plugins +maven-compiler-plugin +3.8.0 + +11 +11 + +-parameters + + + + +org.apache.maven.plugins +
[tinkerpop] 20/41: got FlatMapFunctions working. Added __.union(). Added all the Iterator utilities from TP3.
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 193f012802014532c18860ac4e7483ab5e54244e Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 12:54:19 2019 -0600 got FlatMapFunctions working. Added __.union(). Added all the Iterator utilities from TP3. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 12 +- .../java/org/apache/tinkerpop/language/__.java | 21 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 23 +- .../machine/functions/FlatMapFunction.java | 2 +- .../machine/functions/NestedFunction.java | 7 +- .../machine/functions/flatMap/UnionFlatMap.java| 85 .../tinkerpop/machine/functions/map/MapMap.java| 25 +- .../machine/processor/EmptyProcessorFactory.java | 7 +- .../machine/processor/ProcessorFactory.java| 14 +- .../machine/traversers/CompleteTraverser.java | 12 + .../tinkerpop/machine/traversers/Traverser.java| 8 +- .../ArrayIterator.java}| 34 +- .../org/apache/tinkerpop/util/DoubleIterator.java | 65 .../org/apache/tinkerpop/util/IteratorUtils.java | 433 + .../org/apache/tinkerpop/util/MultiIterator.java | 104 + .../SingleIterator.java} | 33 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 12 +- .../tinkerpop/machine/beam/BeamProcessor.java | 8 +- .../apache/tinkerpop/machine/beam/FlatMapFn.java} | 22 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 16 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 7 +- .../tinkerpop/machine/pipes/FlatMapStep.java} | 30 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 15 +- .../tinkerpop/machine/pipes/PipesProcessor.java| 9 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 6 +- 26 files changed, 920 insertions(+), 91 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 4f5ed5f..7964d07 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 @@ -40,4 +40,5 @@ public final class Symbols { public static final String MAP = "map"; public static final String PATH = "path"; public static final String SUM = "sum"; +public static final String UNION = "union"; } 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 e9ebb85..4eef5cd 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 @@ -22,6 +22,7 @@ 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.EmptyProcessorFactory; import org.apache.tinkerpop.machine.processor.Processor; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; @@ -47,7 +48,7 @@ public class Traversal implements Iterator { public Traversal(final Bytecode bytecode) { this.bytecode = bytecode; this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); -this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(null); +this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(EmptyProcessorFactory.instance()); } public Traversal as(final String label) { @@ -105,6 +106,15 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal union(final Traversal... traversals) { +final Bytecode[] bytecodes = new Bytecode[traversals.length]; +for (int i = 0; i < traversals.length; i++) { +bytecodes[i] = traversals[i].bytecode; +} +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, bytecodes); +return (Traversal) this; +} + /// 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 80bb253..4c2b4ba 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -19,16 +19,29 @@ package org.apache.tinkerpop.language; import org.apache.t
[tinkerpop] 01/41: Apache TinkerPop 4.x all starts with a README
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 4463a8343834812ab617a15c8f0cf1538caa3b63 Author: Stephen Mallette AuthorDate: Fri Mar 1 15:19:43 2019 -0500 Apache TinkerPop 4.x all starts with a README --- README.asciidoc | 17 + 1 file changed, 17 insertions(+) diff --git a/README.asciidoc b/README.asciidoc new file mode 100644 index 000..1eaec1a --- /dev/null +++ b/README.asciidoc @@ -0,0 +1,17 @@ + +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. + +== TinkerPop4
[tinkerpop] 13/41: Coefficients are now wrapped in Coefficient objects and passed around through functions and traversers. This was the only way to make it clean. Added StringFactory which gives By
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 d56b089fc2b7bdaa2d535858647c731e765cb694 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 14:33:33 2019 -0700 Coefficients are now wrapped in Coefficient objects and passed around through functions and traversers. This was the only way to make it clean. Added StringFactory which gives Bytecode and Traversals standard toString() representations. Stubbed the strategy/ package and interface. Processors now implement Iterator. This makes sense as its up to the Traversal to get traversers from the processor and stream them out (unpack them) to the user. The processor is now completel [...] --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 36 +++- .../apache/tinkerpop/language/TraversalSource.java | 24 -- .../java/org/apache/tinkerpop/language/__.java | 4 +- .../tinkerpop/machine/bytecode/Bytecode.java | 7 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 +- .../tinkerpop/machine/bytecode/Instruction.java| 10 ++- .../{Coefficients.java => Coefficient.java}| 19 +++-- .../machine/coefficients/LongCoefficient.java | 98 ++ .../machine/coefficients/LongCoefficients.java | 56 - .../Coefficients.java => compiler/Strategy.java} | 17 ++-- .../machine/functions/AbstractFunction.java| 13 +-- .../tinkerpop/machine/functions/CFunction.java | 4 +- .../machine/functions/filter/IdentityFilter.java | 4 +- .../machine/functions/filter/IsFilter.java | 7 +- .../machine/functions/initial/InjectInitial.java | 9 +- .../tinkerpop/machine/functions/map/IncrMap.java | 5 +- .../tinkerpop/machine/functions/map/MapMap.java| 12 +-- .../tinkerpop/machine/functions/map/PathMap.java | 5 +- .../machine/processor/EmptyProcessor.java | 6 +- .../tinkerpop/machine/processor/Processor.java | 8 +- .../tinkerpop/machine/traversers/Traverser.java| 12 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 13 ++- .../util/FastNoSuchElementException.java | 2 +- .../org/apache/tinkerpop/util/StringFactory.java | 68 +++ .../apache/tinkerpop/machine/TraversalTest.java| 4 +- .../machine/compiler/BytecodeUtilTest.java | 4 +- .../tinkerpop/machine/pipes/AbstractStep.java | 12 +-- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 9 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 36 ++-- .../org/apache/tinkerpop/machine/pipes/Step.java | 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 11 ++- 33 files changed, 348 insertions(+), 177 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 387a209..681e26e 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,6 +24,7 @@ package org.apache.tinkerpop.language; public final class Symbols { public static final String AS = "as"; +public static final String C = "c"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 4021d08..7acdd75 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,9 +19,11 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.processor.Processor; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; +import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.ArrayList; import java.util.Iterator; @@ -33,11 +35,13 @@ import java.util.List; public class Traversal implements Iterator { protected final Bytecode bytecode; -private C currentCoefficient; +private Coefficient currentCoefficient; private final ProcessorFactory factory; private Processor processor; +private long lastCount = 0L; +private E lastObject = null; -public Traversal(final C unity, final ProcessorFactory factory) { +public Traversal(final Coefficient unity, final ProcessorFactory factory) { this.currentCoefficient = unity; this.bytecode = new Byteco
[tinkerpop] 37/41: Added License/Notice
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 9a591aec9bd955cea1b708f6b3d1090cf672124d Author: Stephen Mallette AuthorDate: Wed Mar 13 11:03:41 2019 -0400 Added License/Notice --- LICENSE | 202 NOTICE | 5 ++ 2 files changed, 207 insertions(+) diff --git a/LICENSE b/LICENSE new file mode 100644 index 000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 +http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have m
[tinkerpop] 03/41: starting to spec out the gremlin-machines submodule which includes gremlin-pipes which is what we currently think of Traversal as. gremlin-pipes will be a local traversal engine.
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 c6033cbb9aee0f91f7de0878c0ef40d72c98eb4e Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 10:56:06 2019 -0700 starting to spec out the gremlin-machines submodule which includes gremlin-pipes which is what we currently think of Traversal as. gremlin-pipes will be a local traversal engine. --- gremlin-core/pom.xml | 2 +- .../tinkerpop/gremlin/machine/Instruction.java | 2 +- .../tinkerpop/gremlin/machine/Traverser.java | 5 + .../{Traverser.java => functions/GFunction.java} | 29 +--- .../gremlin/machine/functions/MapFunction.java | 2 +- .../gremlin/machine/traversers/TraverserSet.java | 160 + .../FastNoSuchElementException.java} | 32 ++--- .../gremlin-pipes}/pom.xml | 15 +- .../org/apache/tinkerpop/machines/pipes/Pipe.java | 29 ++-- .../org/apache/tinkerpop/machines/pipes/Step.java | 35 +++-- .../apache/tinkerpop/machines/pipes/PipeTest.java | 24 +--- {gremlin-core => gremlin-machines}/pom.xml | 30 +--- pom.xml| 3 +- 13 files changed, 247 insertions(+), 121 deletions(-) diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml index b92f8fd..c921791 100644 --- a/gremlin-core/pom.xml +++ b/gremlin-core/pom.xml @@ -19,7 +19,7 @@ limitations under the License. tinkerpop org.apache.tinkerpop -4.0-SNAPSHOT +4.0.0-SNAPSHOT Apache TinkerPop :: Gremlin Core gremlin-core diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java index dfc9d0a..b46462e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java @@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.machine; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Instruction { +public final class Instruction { private final C coefficient; private final String op; diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java index 6c0712c..d0c321f 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java @@ -42,4 +42,9 @@ public class Traverser { public Traverser split(final C coefficient, final B object) { return new Traverser<>(coefficient, object); } + +@Override +public boolean equals(final Object other) { +return other instanceof Traverser && ((Traverser) other).object.equals(this.object); +} } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java similarity index 61% copy from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java copy to gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java index 6c0712c..48a3b7c 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java @@ -16,30 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.machine; +package org.apache.tinkerpop.gremlin.machine.functions; + +import org.apache.tinkerpop.gremlin.machine.Traverser; + +import java.util.Iterator; +import java.util.function.Function; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Traverser { - -private final C coefficient; -private final A object; - -public Traverser(final C coefficient, final A object) { -this.coefficient = coefficient; -this.object = object; -} - -public C getCoefficient() { -return this.coefficient; -} - -public A getObject() { -return this.object; -} - -public Traverser split(final C coefficient, final B object) { -return new Traverser<>(coefficient, object); -} +public interface GFunction extends Function, Traverser> { } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/MapFunction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/MapFunction.java index 35d5b12..4491414 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/func
[tinkerpop] 02/41: first organizational push on tp4. basic structure, pom.xmls up and running, and some basic code for play.
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 08be42f34b3e5068a08363e18a78e90aff3288e2 Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 08:37:10 2019 -0700 first organizational push on tp4. basic structure, pom.xmls up and running, and some basic code for play. --- .gitignore | 5 + README.asciidoc| 21 ++ gremlin-core/pom.xml | 46 + .../tinkerpop/gremlin/language/GremlinCore.java| 29 +++ .../apache/tinkerpop/gremlin/machine/Bytecode.java | 42 .../tinkerpop/gremlin/machine/Instruction.java | 47 + .../tinkerpop/gremlin/machine/Traversal.java | 45 + .../tinkerpop/gremlin/machine/Traverser.java | 45 + .../gremlin/machine/coefficients/Coefficients.java | 36 .../machine/coefficients/LongCoefficients.java | 50 + .../gremlin/machine/functions/MapFunction.java | 45 + .../tinkerpop/gremlin/machine/TraversalTest.java | 36 pom.xml| 217 + 13 files changed, 664 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 000..ad8c63c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.iml +*.ipr +*.iws +target/ +fileTemplates/ diff --git a/README.asciidoc b/README.asciidoc index 1eaec1a..aba1b44 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -15,3 +15,24 @@ See the License for the specific language governing permissions and limitations under the License. == TinkerPop4 + +* gremlin-core: A collection of Gremlin machine and language components +* gremlin-data +** gremlin-graphs +*** gremlin-neo4j: A Neo4j implementation of the Gremlin graph primitives +*** gremlin-tinkergraph: A TinkerGraph implementation of the Gremlin graph primitives +* gremlin-machines +** gremlin-beam: Apache Beam implementation of the Gremlin traversal machine +** gremlin-akka: Akka implementation of the Gremlin traversal machine +** gremlin-pipes: Java iterator implementation of the Gremlin traversal machine +* gremlin-languages +** gremlin-variants +*** gremlin-groovy: Groovy implementation of the Gremlin traversal language +*** gremlin-python: Python implementation of the Gremlin traversal language +*** gremlin-javascript: JavaScript implementation of the Gremlin traversal language +*** gremlin-dotnet: C# implementation of the Gremlin traversal language +** gremlin-uniques +*** gremlin-sparql: A SPARQL to Gremlin bytecode compiler +*** gremlin-sql: An SQL to Gremlin bytecode compiler +*** gremlin-cypher: A Cypher to Gremlin bytecode compiler +* gremlin-test: language test suite \ No newline at end of file diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml new file mode 100644 index 000..b92f8fd --- /dev/null +++ b/gremlin-core/pom.xml @@ -0,0 +1,46 @@ + +http://maven.apache.org/POM/4.0.0; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> +4.0.0 + +tinkerpop +org.apache.tinkerpop +4.0-SNAPSHOT + +Apache TinkerPop :: Gremlin Core +gremlin-core + +${basedir}/target +${project.artifactId}-${project.version} + + +${basedir}/src/test/resources + + + + + +org.apache.maven.plugins +maven-surefire-plugin + + +org.apache.maven.plugins +maven-failsafe-plugin + + + + \ No newline at end of file diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java new file mode 100644 index 000..f876aaa --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java @@ -0,0 +1,29 @@ +/* + * 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 perm
[tinkerpop] 11/41: awesome push. we have nested traversals working, we have a micro-stub of Bytecode optimization (basically, just removes identity instructions for now), we have a Processor API which
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 5f24a29461ba4368102ac1c14d79bf27728c0998 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 09:33:10 2019 -0700 awesome push. we have nested traversals working, we have a micro-stub of Bytecode optimization (basically, just removes identity instructions for now), we have a Processor API which is THE CONCEPT. A nested function requires a Processor in order to execute its nested functions. Pipes implements Processor. However, you can imagine having Akka going and if the nested functions are simple, just use Pipes as the processor for that. Thus, you can mix and match processors at the nesting lev [...] --- .../org/apache/tinkerpop/language/Symbols.java | 2 + .../org/apache/tinkerpop/language/Traversal.java | 33 +++--- .../tinkerpop/language/{Symbols.java => __.java} | 10 ++- .../Symbols.java => machine/Processor.java}| 18 -- .../tinkerpop/machine/bytecode/Bytecode.java | 4 ++ .../BytecodeUtil.java} | 32 +++--- .../tinkerpop/machine/bytecode/Instruction.java| 9 ++- .../machine/functions/AbstractFunction.java| 2 +- .../functions/NestedFunction.java} | 16 +++-- .../{PathMap.java => filter/IdentityFilter.java} | 13 ++-- .../machine/functions/{ => filter}/IsFilter.java | 4 +- .../functions/{ => initial}/InjectInitial.java | 4 +- .../machine/functions/{ => map}/IncrMap.java | 4 +- .../tinkerpop/machine/functions/map/MapMap.java| 63 ++ .../machine/functions/{ => map}/PathMap.java | 4 +- .../tinkerpop/machine/traversers/TraverserSet.java | 4 +- .../apache/tinkerpop/machine/TraversalTest.java| 7 +- ...deToFunctionTest.java => BytecodeUtilTest.java} | 5 +- .../tinkerpop/machine/pipes/AbstractStep.java | 69 .../apache/tinkerpop/machine/pipes/EmptyStep.java} | 27 +--- .../tinkerpop/machine/pipes/FilterStep.java} | 21 +++--- .../tinkerpop/machine/pipes/InitialStep.java} | 24 +++ .../apache/tinkerpop/machine/pipes/MapStep.java} | 15 ++--- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 73 ++--- .../org/apache/tinkerpop/machine/pipes/Step.java | 74 -- .../apache/tinkerpop/machine/pipes/PipesTest.java | 15 +++-- 26 files changed, 368 insertions(+), 184 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 fdaf642..387a209 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,8 +24,10 @@ package org.apache.tinkerpop.language; public final class Symbols { public static final String AS = "as"; +public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String MAP = "map"; public static final String PATH = "path"; } 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 f363342f..06b93bf 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,13 +19,12 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; - -import java.util.Map; +import org.apache.tinkerpop.machine.traversers.Path; /** - * @author Marko A. Rodriguez (http://markorodriguez.com) + * @author Marko S. Rodriguez (http://markorodriguez.com) */ -public class Traversal { +public class Traversal { private final Bytecode bytecode; private C currentCoefficient; @@ -35,32 +34,48 @@ public class Traversal { this.bytecode = new Bytecode<>(); } -public Traversal as(final String label) { +public Traversal as(final String label) { this.bytecode.lastInstruction().addLabel(label); return this; } -public Traversal is(final B object) { +public Traversal by(final Traversal byTraversal) { +this.bytecode.lastInstruction().addArg(byTraversal); +return this; +} + +public Traversal identity() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.IDENTITY); +return this; +} + +public Traversal is(final E object) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); return this; } -public Traversal incr() { +p
[tinkerpop] 10/41: trucking along. got as() and path() working. Really neat -- as() is a pop/push on the Bytecode. Just as specified in the TP4 article. as(), by(), and all other step-modulators will
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 32c5caefe24e470f811da1505a860d2b0d647a10 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 06:25:02 2019 -0700 trucking along. got as() and path() working. Really neat -- as() is a pop/push on the Bytecode. Just as specified in the TP4 article. as(), by(), and all other step-modulators will pop/push the instruction stack. --- .../{machine/compiler => language}/Symbols.java| 4 +++- .../org/apache/tinkerpop/language/Traversal.java | 14 ++- .../tinkerpop/machine/bytecode/Bytecode.java | 4 .../tinkerpop/machine/bytecode/Instruction.java| 13 ++- .../machine/compiler/BytecodeToFunction.java | 21 +++-- .../{GFunction.java => AbstractFunction.java} | 26 ++--- .../{FilterFunction.java => CFunction.java}| 11 + .../machine/functions/FilterFunction.java | 2 +- .../machine/functions/FlatMapFunction.java | 2 +- .../tinkerpop/machine/functions/IncrMap.java | 10 .../machine/functions/InitialFunction.java | 2 +- .../tinkerpop/machine/functions/InjectInitial.java | 7 +++--- .../tinkerpop/machine/functions/IsFilter.java | 8 --- .../tinkerpop/machine/functions/MapFunction.java | 2 +- .../functions/{IncrMap.java => PathMap.java} | 13 +++ .../Bytecode.java => traversers/Path.java} | 27 ++ .../tinkerpop/machine/traversers/Traverser.java| 22 +- .../apache/tinkerpop/machine/TraversalTest.java| 2 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 8 +++ .../org/apache/tinkerpop/machine/pipes/Step.java | 8 +++ .../apache/tinkerpop/machine/pipes/PipesTest.java | 1 + 21 files changed, 151 insertions(+), 56 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java similarity index 89% rename from java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java rename to java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java index 7de197f..fdaf642 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java @@ -16,14 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.machine.compiler; +package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ public final class Symbols { +public static final String AS = "as"; public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String PATH = "path"; } 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 86d307a..f363342f 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,8 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; -import org.apache.tinkerpop.machine.compiler.Symbols; + +import java.util.Map; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -34,6 +35,11 @@ public class Traversal { this.bytecode = new Bytecode<>(); } +public Traversal as(final String label) { +this.bytecode.lastInstruction().addLabel(label); +return this; +} + public Traversal is(final B object) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); return this; @@ -49,6 +55,12 @@ public class Traversal { return (Traversal) this; } +public Traversal> path() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.PATH); +return (Traversal) this; +} + + public Bytecode getBytecode() { return this.bytecode; } 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 f58f719..e1ef154 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 @@ -40,6 +40,10 @@ public class Bytecode { return this.instructions; } +public Instruction lastInstruction() { +return this.instructions.get(this.instructions.size() - 1); +} + @Override public St
[tinkerpop] 35/41: Finally figured out the generalized branch model. Its a little different than TP3 and it accounts for stream ring theory stuff. However, what makes it really special is that it lend
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 4c141f6a39a4a04875f0b23748a7d7d6fab6e480 Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 07:28:06 2019 -0600 Finally figured out the generalized branch model. Its a little different than TP3 and it accounts for stream ring theory stuff. However, what makes it really special is that it lends itself easily to either a pull-based processor (Pipes) or a push-based processor (Beam). Beam is now generalized where it can take a BranchFunction (regardless of instance) and create an appropriate split/merge topology. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 14 +++- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 6 ++ .../tinkerpop/machine/bytecode/Compilation.java| 6 ++ .../machine/functions/BranchFunction.java | 9 ++- .../machine/functions/InternalFunction.java| 6 -- .../machine/functions/branch/ChooseBranch.java | 86 ++ .../machine/functions/branch/RepeatBranch.java | 19 +++-- .../machine/functions/branch/UnionBranch.java | 27 +-- .../branch/selector/HasNextSelector.java} | 22 +++--- .../selector/Selector.java}| 9 ++- .../selector/TrueSelector.java}| 17 - .../machine/functions/filter/FilterFilter.java | 4 - .../tinkerpop/machine/functions/map/MapMap.java| 5 -- .../machine/functions/reduce/GroupCountReduce.java | 4 - .../tinkerpop/machine/traversers/Traverser.java| 2 +- .../org/apache/tinkerpop/util/NumberHelper.java| 2 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 30 +--- .../apache/tinkerpop/machine/beam/BranchFn.java| 21 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 4 +- .../apache/tinkerpop/machine/pipes/BranchStep.java | 6 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 9 +-- 23 files changed, 229 insertions(+), 82 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 a11321f..efeeaad 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 @@ -34,6 +34,7 @@ public final class Symbols { // INSTRUCTION OPS +public static final String CHOOSE_IF_THEN_ELSE = "chooseIfThenElse"; public static final String COUNT = "count"; public static final String FILTER = "filter"; public static final String GROUP_COUNT = "groupCount"; 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 fdcc8d4..9a17bc5 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 @@ -63,6 +63,11 @@ public class Traversal implements Iterator { return this; } +public Traversal choose(final Traversal predicate, final Traversal trueTraversal, final Traversal falseTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN_ELSE, predicate, trueTraversal, falseTraversal); +return (Traversal) this; +} + public Traversal count() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); return (Traversal) this; @@ -158,8 +163,13 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal union(final Traversal traversal, Traversal... traversals) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversal, traversals); +public Traversal union(final Traversal traversalA, final Traversal traversalB) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversalA, traversalB); +return (Traversal) this; +} + +public Traversal union(final Traversal traversalA, final Traversal traversalB, final Traversal traversalC) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversalA, traversalB, traversalC); return (Traversal) this; } 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 eea1df5..b7110a3 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 @@ -21,6 +21,7 @@ package org.ap
[tinkerpop] branch tp4 updated (58e761d -> fb4930b)
This is an automated email from the ASF dual-hosted git repository. okram pushed a change to branch tp4 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git. from 58e761d Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just work without any special consideration in Beam. I need to get repeat() to be general -- but that is tricky given its recrussive nature. For now, a special repeat()-case exists. new bfa48cb BranchFuncions are no longer Java functions. Given that the implementation of branching is heavily dependent on processing engine semantics, BranchFunctions simply expose a branch selector and a Map of selector/traversal pairs. It is up to the processor provider to use that information to construct a branching topology. For Pipes, its pull-based. For Beam, its push-based. new 955a946 added BarrierFunction which is a generalization of Reduce. This was mentioned in the Stream Ring Theory paper and I decided to flush it out so we can do barrier() in this way. Going to have to generalize the concept of a Reducer. new fb4930b playing around with Reducers and Barriers. Trying to merge them into one. Had it working for Pipes, but Beam requires that a Combiner return a single object -- not an iterator of objects. Still playing. The 41 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../org/apache/tinkerpop/language/Symbols.java | 10 ++- .../org/apache/tinkerpop/language/Traversal.java | 15 + .../tinkerpop/machine/bytecode/Bytecode.java | 6 -- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 8 +++ .../machine/functions/AbstractFunction.java| 2 +- .../{ReduceFunction.java => BarrierFunction.java} | 8 +-- .../machine/functions/BranchFunction.java | 5 +- .../CountReduce.java => barrier/StallBarrier.java} | 27 +--- .../machine/functions/branch/ChooseBranch.java | 21 ++- .../machine/functions/branch/RepeatBranch.java | 19 +- .../machine/functions/branch/UnionBranch.java | 15 + .../machine/functions/filter/FilterFilter.java | 4 +- .../machine/functions/filter/HasKeyFilter.java | 2 +- .../functions/filter/HasKeyValueFilter.java| 2 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 2 +- .../machine/functions/flatmap/UnfoldFlatMap.java | 2 +- .../machine/functions/initial/InjectInitial.java | 2 +- .../tinkerpop/machine/functions/map/IncrMap.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../tinkerpop/machine/functions/map/PathMap.java | 2 +- .../machine/functions/reduce/CountReduce.java | 2 +- .../machine/functions/reduce/GroupCountReduce.java | 2 +- .../machine/functions/reduce/SumReduce.java| 2 +- .../machine/traversers/CompleteTraverser.java | 5 ++ .../tinkerpop/machine/traversers/Traverser.java| 4 -- .../org/apache/tinkerpop/machine/beam/Beam.java| 10 ++- .../apache/tinkerpop/machine/beam/BranchFn.java| 11 ++-- .../machine/beam/util/PrimitiveVisitor.java| 72 ++ .../apache/tinkerpop/machine/beam/BeamTest.java| 5 ++ .../tinkerpop/machine/pipes/BarrierStep.java | 68 .../apache/tinkerpop/machine/pipes/BranchStep.java | 48 ++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 14 +++-- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 12 ++-- .../apache/tinkerpop/machine/pipes/RepeatStep.java | 70 + .../pipes/util/{Reducer.java => Barrier.java} | 2 +- .../{BasicReducer.java => InMemoryBarrier.java}| 4 +- .../machine/pipes/util/InMemoryReducer.java} | 32 -- .../tinkerpop/machine/pipes/util/Reducer.java | 10 ++- .../apache/tinkerpop/machine/pipes/PipesTest.java | 13 +++- 40 files changed, 390 insertions(+), 154 deletions(-) copy java/core/src/main/java/org/apache/tinkerpop/machine/functions/{ReduceFunction.java => BarrierFunction.java} (81%) copy java/core/src/main/java/org/apache/tinkerpop/machine/functions/{reduce/CountReduce.java => barrier/StallBarrier.java} (56%) create mode 100644 java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/util/PrimitiveVisitor.java create mode 100644 java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/BarrierStep.java create mode 100644 java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/RepeatStep.java copy java/machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/util/{Reducer.java => Barrier.java} (95%) rename java/machine
[tinkerpop] 21/41: NestedFunctions.Branching are now split/merged PCollections in Beam. This is equivalent to GlobalChildren in TP3 where you want these individual nested traversals to be independent
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 30a12669d04f2ecffca4a1b51b976eac88eca10f Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 13:38:02 2019 -0600 NestedFunctions.Branching are now split/merged PCollections in Beam. This is equivalent to GlobalChildren in TP3 where you want these individual nested traversals to be independent of one another. Starting to get the hang of the Apache Beam API. --- .../machine/functions/NestedFunction.java | 7 ++ .../machine/functions/flatMap/UnionFlatMap.java| 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 83 +- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 4 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- 6 files changed, 62 insertions(+), 38 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java index a63f226..2119f54 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java @@ -31,4 +31,11 @@ public interface NestedFunction extends CFunction { public void setProcessor(final TraverserFactory traverserFactory, final ProcessorFactory processorFactory); public List>> getFunctions(); + +public interface Branching extends NestedFunction { +} + +public interface Internal extends NestedFunction { + +} } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java index 7544580..cb5502a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java @@ -39,7 +39,7 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class UnionFlatMap extends AbstractFunction> implements FlatMapFunction, NestedFunction { +public class UnionFlatMap extends AbstractFunction> implements FlatMapFunction, NestedFunction.Branching { private final List>> branchFunctions; private transient List> processors; diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java index 08d4961..63d64c0 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java @@ -36,7 +36,7 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class MapMap extends AbstractFunction implements MapFunction, NestedFunction { +public class MapMap extends AbstractFunction implements MapFunction, NestedFunction.Internal { private final List> mapFunctions; private TraverserFactory traverserFactory; 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 fa06730..6531693 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 @@ -23,8 +23,10 @@ import org.apache.beam.sdk.options.PipelineOptions; import org.apache.beam.sdk.transforms.Combine; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.Flatten; import org.apache.beam.sdk.transforms.ParDo; import org.apache.beam.sdk.values.PCollection; +import org.apache.beam.sdk.values.PCollectionList; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.coefficients.Coefficient; @@ -54,54 +56,71 @@ public class Beam implements Processor { private final Pipeline pipeline; public static List OUTPUT = new ArrayList<>(); // FIX THIS! private final List functions = new ArrayList<>(); -Iterator iterator = null; +Iterator> iterator = null; +private TraverserFactory traverserFactory; public Beam(final TraverserFactory traverserFactory, final List> functions) { +this.traverserFactory = traverserFactory; this.pipeline = Pipeline.create(); this.pipeline.getCoderRegistry().registerCoderForClass(Traverser.class, new TraverserCoder<>()); -PCollection collection = this.pipeline.appl
[tinkerpop] 09/41: got TraversalSource, Traversal, and a basic implementation of Pipes/Steps working. Bytecode compilation no longer requires Java reflection -- big ass switch statement.
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 a472603dcaa9a50e6cd77d4bbd5049b56ccc22c3 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 05:34:22 2019 -0700 got TraversalSource, Traversal, and a basic implementation of Pipes/Steps working. Bytecode compilation no longer requires Java reflection -- big ass switch statement. --- .../language/{GremlinCore.java => Gremlin.java}| 6 +-- .../tinkerpop/{machine => language}/Traversal.java | 19 ++-- .../{GremlinCore.java => TraversalSource.java} | 20 ++-- .../tinkerpop/machine/{ => bytecode}/Bytecode.java | 7 ++- .../machine/{ => bytecode}/Instruction.java| 15 -- .../machine/coefficients/LongCoefficients.java | 6 +++ .../machine/compiler/BytecodeToFunction.java | 57 ++ .../compiler/Symbols.java} | 10 ++-- .../{GFunction.java => FilterFunction.java}| 7 ++- .../machine/functions/FlatMapFunction.java}| 26 ++ .../tinkerpop/machine/functions/GFunction.java | 22 ++--- .../functions/{GFunction.java => IncrMap.java} | 16 -- .../{GFunction.java => InitialFunction.java} | 8 +-- .../machine/functions/InjectInitial.java} | 24 + .../functions/{GFunction.java => IsFilter.java}| 24 +++-- .../tinkerpop/machine/functions/MapFunction.java | 19 +--- .../machine/{ => traversers}/Traverser.java| 6 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 1 - .../apache/tinkerpop/machine/TraversalTest.java| 17 --- .../BytecodeToFunctionTest.java} | 16 +++--- .../machine/pipes/{Pipe.java => Pipes.java}| 30 +--- .../org/apache/tinkerpop/machine/pipes/Step.java | 46 - .../apache/tinkerpop/machine/pipes/PipesTest.java} | 21 +--- 23 files changed, 287 insertions(+), 136 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java similarity index 88% copy from java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java copy to java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java index 59c4f69..2f29245 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java @@ -21,9 +21,9 @@ package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface GremlinCore { +public final class Gremlin { -public default GremlinCore select() { -return null; +public static TraversalSource traversal() { +return new TraversalSource<>(); } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java similarity index 66% rename from java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java rename to java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java index 964143f..86d307a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.machine; +package org.apache.tinkerpop.language; -import java.util.function.Function; +import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.compiler.Symbols; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -33,8 +34,18 @@ public class Traversal { this.bytecode = new Bytecode<>(); } -public Traversal map(final Function mapFunction) { -this.bytecode.addInstruction(this.currentCoefficient, "map", mapFunction); +public Traversal is(final B object) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); +return this; +} + +public Traversal incr() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.INCR); +return (Traversal) this; +} + +public Traversal inject(final D... objects) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.INJECT, objects); return (Traversal) this; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java similarity index 59% copy from java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java copy to java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java index 59c4f69..01c145a 100644 --- a/java/core/src/m
[tinkerpop] 05/41: small pom tweak.
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 a69ea2f621d2e1547c713af0e9403155bfb684f3 Author: Marko A. Rodriguez AuthorDate: Mon Mar 4 10:28:54 2019 -0700 small pom tweak. --- gremlin-machines/gremlin-pipes/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-machines/gremlin-pipes/pom.xml b/gremlin-machines/gremlin-pipes/pom.xml index 783bada..91ea4f1 100644 --- a/gremlin-machines/gremlin-pipes/pom.xml +++ b/gremlin-machines/gremlin-pipes/pom.xml @@ -21,7 +21,7 @@ limitations under the License. org.apache.tinkerpop 4.0.0-SNAPSHOT -Apache TinkerPop :: Gremlin Pipes +Apache TinkerPop :: Gremlin Machines :: Gremlin Pipes gremlin-pipes
[tinkerpop] 06/41: reorganized tp4 based on languages and removed all the gremlin- naming.
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 2493711487946a4d9750ba2ed1b2b4af52b22acf Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 07:59:18 2019 -0700 reorganized tp4 based on languages and removed all the gremlin- naming. --- .../apache/tinkerpop/machines/pipes/PipeTest.java | 25 -- {gremlin-core => java/core}/pom.xml| 6 +++--- .../apache/tinkerpop}/language/GremlinCore.java| 2 +- .../org/apache/tinkerpop}/machine/Bytecode.java| 2 +- .../org/apache/tinkerpop}/machine/Instruction.java | 2 +- .../org/apache/tinkerpop}/machine/Traversal.java | 2 +- .../org/apache/tinkerpop}/machine/Traverser.java | 2 +- .../machine/coefficients/Coefficients.java | 2 +- .../machine/coefficients/LongCoefficients.java | 2 +- .../tinkerpop}/machine/functions/GFunction.java| 6 +++--- .../tinkerpop}/machine/functions/MapFunction.java | 6 +++--- .../machine/traversers/TraverserSet.java | 7 +++--- .../machine/util/FastNoSuchElementException.java | 2 +- .../apache/tinkerpop}/machine/TraversalTest.java | 2 +- .../gremlin-pipes => java/machine/pipes}/pom.xml | 8 +++ .../org/apache/tinkerpop/machine}/pipes/Pipe.java | 4 ++-- .../org/apache/tinkerpop/machine}/pipes/Step.java | 8 +++ {gremlin-machines => java/machine}/pom.xml | 8 +++ {gremlin-machines => java}/pom.xml | 11 +- pom.xml| 9 20 files changed, 46 insertions(+), 70 deletions(-) diff --git a/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java b/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java deleted file mode 100644 index 243e301..000 --- a/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java +++ /dev/null @@ -1,25 +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.machines.pipes; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class PipeTest { -} diff --git a/gremlin-core/pom.xml b/java/core/pom.xml similarity index 92% rename from gremlin-core/pom.xml rename to java/core/pom.xml index c921791..5e3a2d3 100644 --- a/gremlin-core/pom.xml +++ b/java/core/pom.xml @@ -17,12 +17,12 @@ limitations under the License. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> 4.0.0 -tinkerpop +java org.apache.tinkerpop 4.0.0-SNAPSHOT -Apache TinkerPop :: Gremlin Core -gremlin-core +Apache TinkerPop (Java) :: Core +core ${basedir}/target ${project.artifactId}-${project.version} diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java similarity index 95% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java rename to java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java index f876aaa..59c4f69 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.language; +package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Bytecode.java b/java/core/src/main/java/org/apache/tinkerpop/machine/Bytecode.java similarity index 96% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Bytecode.java rename to java/core/src/main/java/org/apache/tinkerpop/machine/Bytecode.java index 5334fd0..2778366 100644 --- a/gremlin-core/src/main/j
[tinkerpop] 31/41: fixed a bug in FilterStep. Added repeat(). I have only tested it in Pipes. Given that Beam doesn't support recurssion, we will have to use the exponential loop form developed in the
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 4cae62b7310a8ad9d1443a11ac6dc502bfd5eda5 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 12:15:53 2019 -0600 fixed a bug in FilterStep. Added repeat(). I have only tested it in Pipes. Given that Beam doesn't support recurssion, we will have to use the exponential loop form developed in the Stream Ring Theory paper. Basically, concatenate the repeat sequence over and over and over (for some large number) and always have a multi-output for breaking out of the loop. Need to take a break. --- .../org/apache/tinkerpop/language/Symbols.java | 46 -- .../org/apache/tinkerpop/language/Traversal.java | 10 +++ .../java/org/apache/tinkerpop/language/__.java | 4 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../tinkerpop/machine/bytecode/Compilation.java| 5 ++ .../machine/functions/branch/RepeatBranch.java | 72 ++ .../apache/tinkerpop/machine/pipes/FilterStep.java | 10 ++- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +- 8 files changed, 147 insertions(+), 8 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 0d431ae..8b4ebef 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 @@ -23,6 +23,10 @@ package org.apache.tinkerpop.language; */ public final class Symbols { +public static enum Type { +INITIAL, MAP, FLATMAP, FILTER, REDUCE, BRANCH +} + // SOURCE OPS public static final String WITH_COEFFICIENT = "withCoefficient"; public static final String WITH_PROCESSOR = "withProcessor"; @@ -30,19 +34,53 @@ public final class Symbols { // INSTRUCTION OPS -public static final String AS = "as"; -public static final String C = "c"; public static final String COUNT = "count"; public static final String FILTER = "filter"; public static final String GROUP_COUNT = "groupCount"; -public static final String HAS_KEY_VALUE = "hasKeyValue"; public static final String HAS_KEY = "hasKey"; +public static final String HAS_KEY_VALUE = "hasKeyValue"; public static final String IDENTITY = "identity"; -public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String IS = "is"; public static final String MAP = "map"; public static final String PATH = "path"; +public static final String REPEAT = "repeat"; public static final String SUM = "sum"; public static final String UNION = "union"; + +public Type getOpType(final String op) { +switch (op) { +case COUNT: +return Type.REDUCE; +case FILTER: +return Type.FILTER; +case GROUP_COUNT: +return Type.REDUCE; +case HAS_KEY: +return Type.FILTER; +case HAS_KEY_VALUE: +return Type.FILTER; +case IDENTITY: +return Type.FILTER; +case INCR: +return Type.MAP; +case INJECT: +return Type.INITIAL; +case IS: +return Type.FILTER; +case MAP: +return Type.MAP; +case PATH: +return Type.MAP; +case REPEAT: +return Type.BRANCH; +case SUM: +return Type.REDUCE; +case UNION: +return Type.BRANCH; +default: +throw new IllegalArgumentException("The following op is unknown: " + op); +} +} } 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 92a7d23..cf90d24 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 @@ -143,6 +143,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal repeat(final Traversal repeatTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.REPEAT, repeatTraversal); +return this; +} + public Traversal sum() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.SUM); return (Traversal) this; @@ -153,6 +158,11 @@ pu
[tinkerpop] 23/41: added filter(traversal).
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 f684e0f0b7c4f9cbd6f1ecbff265cce79bf85d9e Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 14:16:05 2019 -0600 added filter(traversal). --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 +++ .../java/org/apache/tinkerpop/language/__.java | 4 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 ++ .../UnionFlatMap.java => filter/FilterFilter.java} | 48 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 3 +- .../machine/functions/flatMap/UnionFlatMap.java| 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +++ 9 files changed, 42 insertions(+), 33 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 7964d07..81c80bb 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 @@ -33,6 +33,7 @@ public final class Symbols { public static final String AS = "as"; public static final String C = "c"; public static final String COUNT = "count"; +public static final String FILTER = "filter"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 4eef5cd..0e8f40a 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 @@ -71,6 +71,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal filter(final Traversal filterTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal.bytecode); +return this; +} + public Traversal identity() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IDENTITY); return this; 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 4c2b4ba..8c8a929 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -25,6 +25,10 @@ import org.apache.tinkerpop.machine.bytecode.Bytecode; */ public class __ { +private __() { +// static class +} + private static Traversal start() { return new Traversal<>(new Bytecode<>()); } 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 10a9b2f..07f2f1d 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.machine.bytecode; import org.apache.tinkerpop.language.Symbols; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.CFunction; +import org.apache.tinkerpop.machine.functions.filter.FilterFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; import org.apache.tinkerpop.machine.functions.flatMap.UnionFlatMap; @@ -121,6 +122,8 @@ public final class BytecodeUtil { switch (op) { case Symbols.COUNT: return new CountReduce<>(coefficient, labels); +case Symbols.FILTER: +return new FilterFilter<>(coefficient, labels, compile((Bytecode) instruction.args()[0])); case Symbols.IDENTITY: return new IdentityFilter<>(coefficient, labels); case Symbols.INJECT: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java similarity index 55% copy from java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java copy to java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java index cb5502a..a4a18ec 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java +++ b/java/core/src/main/java/or
[tinkerpop] 15/41: cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines.
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 0fd1e42e32242401b34c95f699b8d684b4b623fd Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:39:35 2019 -0600 cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines. --- .../tinkerpop/machine/traversers/TraverserSet.java | 3 +- java/machine/beam/pom.xml | 5 ++ .../machine/beam/{MapFn.java => AbstractFn.java} | 25 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 57 +- .../apache/tinkerpop/machine/beam/FilterFn.java| 4 +- .../machine/beam/{FilterFn.java => Fn.java}| 17 ++- .../machine/beam/{FilterFn.java => InitialFn.java} | 22 ++--- .../org/apache/tinkerpop/machine/beam/MapFn.java | 27 -- .../machine/beam/{MapFn.java => ReduceFn.java} | 27 +- .../tinkerpop/machine/beam/TraverserCoder.java | 6 +-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- 12 files changed, 119 insertions(+), 81 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java index ce52b63..66169ab 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java @@ -21,6 +21,7 @@ package org.apache.tinkerpop.machine.traversers; import org.apache.tinkerpop.util.FastNoSuchElementException; +import java.io.Serializable; import java.util.AbstractSet; import java.util.Collections; import java.util.Iterator; @@ -33,7 +34,7 @@ import java.util.Spliterator; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class TraverserSet extends AbstractSet> implements Set>, Queue> { +public class TraverserSet extends AbstractSet> implements Set>, Queue>, Serializable { private final Map, Traverser> map = Collections.synchronizedMap(new LinkedHashMap<>()); diff --git a/java/machine/beam/pom.xml b/java/machine/beam/pom.xml index 2fb4c82..24a9773 100644 --- a/java/machine/beam/pom.xml +++ b/java/machine/beam/pom.xml @@ -79,6 +79,11 @@ limitations under the License. 2.11.0 runtime + +org.apache.tinkerpop +pipes +${project.version} + ${basedir}/target diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java similarity index 61% copy from java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java copy to java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java index 2b83ab2..63caa5e 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java @@ -19,23 +19,30 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.transforms.DoFn; -import org.apache.beam.sdk.values.TypeDescriptor; -import org.apache.tinkerpop.machine.functions.MapFunction; +import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.traversers.Traverser; +import org.apache.tinkerpop.machine.traversers.TraverserSet; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class MapFn extends DoFn, Traverser> { +public abstract class AbstractFn extends DoFn, Traverser> implements Fn { -private final MapFunction mapFunction; +protected final TraverserSet traversers = new TraverserSet<>(); +protected final CFunction function; -public MapFn(final MapFunction mapFunction) { -this.mapFunction = mapFunction; +protected AbstractFn(final CFunction function) { +this.function = function; } -@ProcessElement -public void processElement(final @Element Traverser traverser, final OutputReceiver> output) { -output.output(traverser.map(this.mapFunction)); +@Override +public void addStart(final Traverser traverser) { +this.traversers.add(traverser); } + +@Override +public String toString() { +return this.function.toString(); +} + } 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 a03ee71..b93174e 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java +++ b/java/machine/beam/src/main/java/org/
[tinkerpop] 30/41: We now naturally support constant or traversal-based arguments. This is all nicely packaged with the new Compilation object (which is turning out to be way cooler than Bytecode. Its
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 984a1b591029f572717e223f1f708b451b6161e3 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 11:15:31 2019 -0600 We now naturally support constant or traversal-based arguments. This is all nicely packaged with the new Compilation object (which is turning out to be way cooler than Bytecode. Its like JIT). Added has(), groupCount(), ... --- .../org/apache/tinkerpop/language/Symbols.java | 3 + .../org/apache/tinkerpop/language/Traversal.java | 53 +--- .../apache/tinkerpop/language/TraversalUtil.java | 4 -- .../{CompilationRing.java => Argument.java}| 35 --- .../tinkerpop/machine/bytecode/Bytecode.java | 2 + .../tinkerpop/machine/bytecode/BytecodeUtil.java | 9 +++ .../tinkerpop/machine/bytecode/Compilation.java| 9 +++ .../machine/bytecode/CompilationRing.java | 2 +- .../tinkerpop/machine/bytecode/Instruction.java| 4 ++ .../machine/functions/filter/HasKeyFilter.java | 53 .../functions/filter/HasKeyValueFilter.java| 55 + .../machine/functions/reduce/GroupCountReduce.java | 70 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 7 ++- .../apache/tinkerpop/machine/beam/BranchFn.java| 9 +-- .../apache/tinkerpop/machine/beam/FlatMapFn.java | 2 +- .../apache/tinkerpop/machine/beam/ReduceFn.java| 23 +++ .../CoefficientCoder.java} | 11 ++-- .../ObjectCoder.java} | 12 ++-- .../beam/{ => serialization}/ReducerCoder.java | 11 ++-- .../beam/{ => serialization}/TraverserCoder.java | 2 +- .../BasicReducer.java} | 9 +-- .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- .../beam/functions/TraversalSourceLibrary.java}| 18 +++--- .../functions/filter/BeamHasKeyValueTest.java} | 15 +++-- .../beam/functions/filter/BeamIdentityTest.java} | 16 ++--- .../apache/tinkerpop/machine/pipes/BranchStep.java | 5 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 2 +- .../tinkerpop/machine/pipes/FlatMapStep.java | 5 +- .../tinkerpop/machine/pipes/InitialStep.java | 2 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 2 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 5 +- .../tinkerpop/machine/pipes/PipesProcessor.java| 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 4 +- .../machine/pipes/strategies/PipesStrategy.java| 2 +- .../tinkerpop/machine/pipes/util/BasicReducer.java | 2 +- .../tinkerpop/machine/pipes/util/Reducer.java | 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 +- .../pipes/functions/TraversalSourceLibrary.java} | 19 +++--- .../functions/filter/PipesHasKeyValueTest.java}| 15 +++-- .../pipes/functions/filter/PipesIdentityTest.java} | 14 ++--- .../HasKeyValueTest.java} | 32 -- .../{filters => filter}/IdentityTest.java | 2 +- 42 files changed, 387 insertions(+), 170 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 81c80bb..0d431ae 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 @@ -34,6 +34,9 @@ public final class Symbols { public static final String C = "c"; public static final String COUNT = "count"; public static final String FILTER = "filter"; +public static final String GROUP_COUNT = "groupCount"; +public static final String HAS_KEY_VALUE = "hasKeyValue"; +public static final String HAS_KEY = "hasKey"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 92ae122..92a7d23 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 @@ -29,6 +29,7 @@ import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Map; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -68,10 +69,45 @@ public class Traversal implements Iterator { } public Traversal filter(final Traversal filterTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal.bytecode); +th
[tinkerpop] 24/41: added test/ module and stubbed the first IdentityTest.
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 7e313cb66ce4e557c284b98b3a194bda505f80de Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 15:41:40 2019 -0600 added test/ module and stubbed the first IdentityTest. --- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 4 ++-- .../{NestedFunction.java => BranchFunction.java} | 18 --- .../{NestedFunction.java => InternalFunction.java} | 13 +-- .../machine/functions/NestedFunction.java | 13 +-- .../UnionFlatMap.java => branch/UnionBranch.java} | 24 +-- .../machine/functions/filter/FilterFilter.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../apache/tinkerpop/machine/traversers/Path.java | 3 +++ .../tinkerpop/machine/traversers/Traverser.java| 5 .../org/apache/tinkerpop/machine/beam/Beam.java| 15 ++-- .../apache/tinkerpop/machine/beam/BranchFn.java} | 27 -- java/machine/pipes/pom.xml | 7 ++ .../pipes/{FlatMapStep.java => BranchStep.java}| 23 +++--- .../tinkerpop/machine/pipes/FlatMapStep.java | 9 +++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 11 + .../machine/pipes/PipesIdentityTest.java} | 26 ++--- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 ++-- java/pom.xml | 1 + java/{machine/pipes => test}/pom.xml | 17 +++--- .../machine/functions/filters/IdentityTest.java} | 22 -- 20 files changed, 129 insertions(+), 117 deletions(-) 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 07f2f1d..4746e97 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 @@ -24,7 +24,7 @@ import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.functions.filter.FilterFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; -import org.apache.tinkerpop.machine.functions.flatMap.UnionFlatMap; +import org.apache.tinkerpop.machine.functions.branch.UnionBranch; import org.apache.tinkerpop.machine.functions.initial.InjectInitial; import org.apache.tinkerpop.machine.functions.map.IncrMap; import org.apache.tinkerpop.machine.functions.map.MapMap; @@ -143,7 +143,7 @@ public final class BytecodeUtil { for (final Bytecode arg : (Bytecode[]) instruction.args()) { branchFunctions.add(compile(arg)); } -return new UnionFlatMap<>(coefficient, labels, branchFunctions); +return new UnionBranch<>(coefficient, labels, branchFunctions); default: throw new RuntimeException("This is an unknown instruction:" + instruction.op()); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java similarity index 64% copy from java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java copy to java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java index 2119f54..cfebf7a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java @@ -18,24 +18,16 @@ */ package org.apache.tinkerpop.machine.functions; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; +import org.apache.tinkerpop.machine.traversers.Traverser; +import java.util.Iterator; import java.util.List; +import java.util.function.Function; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface NestedFunction extends CFunction { +public interface BranchFunction extends Function, Iterator>>, InternalFunction { -public void setProcessor(final TraverserFactory traverserFactory, final ProcessorFactory processorFactory); - -public List>> getFunctions(); - -public interface Branching extends NestedFunction { -} - -public interface Internal extends NestedFunction { - -} +public List>> getBranches(); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java simi
[tinkerpop] 04/41: small tweaks to README.
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 0726e2d7190e8d3a35b691eba426995528ae8c55 Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 11:08:32 2019 -0700 small tweaks to README. --- README.asciidoc | 41 + 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index aba1b44..e791fb1 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -16,23 +16,24 @@ limitations under the License. == TinkerPop4 -* gremlin-core: A collection of Gremlin machine and language components -* gremlin-data -** gremlin-graphs -*** gremlin-neo4j: A Neo4j implementation of the Gremlin graph primitives -*** gremlin-tinkergraph: A TinkerGraph implementation of the Gremlin graph primitives -* gremlin-machines -** gremlin-beam: Apache Beam implementation of the Gremlin traversal machine -** gremlin-akka: Akka implementation of the Gremlin traversal machine -** gremlin-pipes: Java iterator implementation of the Gremlin traversal machine -* gremlin-languages -** gremlin-variants -*** gremlin-groovy: Groovy implementation of the Gremlin traversal language -*** gremlin-python: Python implementation of the Gremlin traversal language -*** gremlin-javascript: JavaScript implementation of the Gremlin traversal language -*** gremlin-dotnet: C# implementation of the Gremlin traversal language -** gremlin-uniques -*** gremlin-sparql: A SPARQL to Gremlin bytecode compiler -*** gremlin-sql: An SQL to Gremlin bytecode compiler -*** gremlin-cypher: A Cypher to Gremlin bytecode compiler -* gremlin-test: language test suite \ No newline at end of file +* *gremlin-core*: A collection of Gremlin machine and language components +* *gremlin-data* +** *gremlin-graph*: Operators for processing property graph data. +*** *gremlin-neo4j*: A Neo4j implementation of the Gremlin graph primitives +*** *gremlin-tinkergraph*: A TinkerGraph implementation of the Gremlin graph primitives +* *gremlin-machines* +** *gremlin-pipes*: Java iterator implementation of the Gremlin traversal machine +** *gremlin-rxjava*: RxJava implementation of the Gremlin traversal machine +** *gremlin-beam*: Apache Beam implementation of the Gremlin traversal machine +** *gremlin-akka*: Akka implementation of the Gremlin traversal machine +* *gremlin-languages* +** *gremlin-variants* +*** *gremlin-groovy*: Groovy implementation of the Gremlin traversal language +*** *gremlin-python*: Python implementation of the Gremlin traversal language +*** *gremlin-javascript*: JavaScript implementation of the Gremlin traversal language +*** *gremlin-dotnet*: C# implementation of the Gremlin traversal language +** *gremlin-uniques* +*** *gremlin-sparql*: A SPARQL to Gremlin bytecode compiler +*** *gremlin-sql*: An SQL to Gremlin bytecode compiler +*** *gremlin-cypher*: A Cypher to Gremlin bytecode compiler +* *gremlin-test*: language test suite \ No newline at end of file
[tinkerpop] 18/41: Strategy interface created and IdentityStrategy instance created. Bytecode sourceInstructions was stubbed along with the strategy application code.
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 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 implements Iterator { protected final Bytecode bytecode; private Coefficient currentCoefficient; -private final ProcessorFactory factory; +private final ProcessorFactory processorFactory; private Processor processor; +// private long lastCount = 0L; private E lastObject = null; -public Traversal(final Coefficient unity, final ProcessorFactory factory) { -this.currentCoefficient = unity; -this.bytecode = new Bytecode<>(); -this.factory = factory; +public Traversal(final Bytecode bytecode) { +this.bytecode = bytecode; +this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); +this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(null); } public Traversal as(final String label) { @@ -102,7 +105,7 @@ public class Traversal implements Iterator { 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; impo
[tinkerpop] 12/41: Added ProcessorFactory which is used with a TraversalSource to register the factoryused to mint Processors to execute traversal chains. Thus, g = g.processor(PipesProcessor.class).
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 342e7604c4b7a053d3f766a67edef67bb9754e87 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 11:14:02 2019 -0700 Added ProcessorFactory which is used with a TraversalSource to register the factoryused to mint Processors to execute traversal chains. Thus, g = g.processor(PipesProcessor.class). Everything is moving along nicely. --- .../org/apache/tinkerpop/language/Traversal.java | 44 ++ .../apache/tinkerpop/language/TraversalSource.java | 16 +++- .../language/{__.java => TraversalUtil.java} | 13 +-- .../java/org/apache/tinkerpop/language/__.java | 4 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 10 ++--- .../tinkerpop/machine/bytecode/Instruction.java| 3 +- .../machine/functions/AbstractFunction.java| 4 +- .../machine/functions/FilterFunction.java | 2 +- .../machine/functions/FlatMapFunction.java | 2 +- .../machine/functions/InitialFunction.java | 2 +- .../tinkerpop/machine/functions/MapFunction.java | 2 +- .../machine/functions/NestedFunction.java | 2 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 8 ++-- .../machine/functions/initial/InjectInitial.java | 22 +-- .../tinkerpop/machine/functions/map/IncrMap.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 4 +- .../tinkerpop/machine/functions/map/PathMap.java | 4 +- .../IncrMap.java => processor/EmptyProcessor.java} | 37 +- .../machine/processor/EmptyProcessorFactory.java} | 21 +++ .../machine/{ => processor}/Processor.java | 2 +- .../processor/ProcessorFactory.java} | 10 ++--- .../tinkerpop/machine/traversers/Traverser.java| 10 ++--- .../apache/tinkerpop/machine/TraversalTest.java| 5 +-- .../machine/compiler/BytecodeUtilTest.java | 7 ++-- .../tinkerpop/machine/pipes/AbstractStep.java | 16 +++- .../apache/tinkerpop/machine/pipes/FilterStep.java | 6 +-- .../apache/tinkerpop/machine/pipes/MapStep.java| 4 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 18 - .../tinkerpop/machine/pipes/PipesProcessor.java} | 13 +-- .../org/apache/tinkerpop/machine/pipes/Step.java} | 9 +++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 18 - 32 files changed, 195 insertions(+), 127 deletions(-) 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 06b93bf..4021d08 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,19 +19,28 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.processor.Processor; +import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** - * @author Marko S. Rodriguez (http://markorodriguez.com) + * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Traversal { +public class Traversal implements Iterator { -private final Bytecode bytecode; +protected final Bytecode bytecode; private C currentCoefficient; +private final ProcessorFactory factory; +private Processor processor; -public Traversal(final C unity) { +public Traversal(final C unity, final ProcessorFactory factory) { this.currentCoefficient = unity; this.bytecode = new Bytecode<>(); +this.factory = factory; } public Traversal as(final String label) { @@ -65,7 +74,7 @@ public class Traversal { } public Traversal map(final Traversal mapTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal.getBytecode()); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal.bytecode); return (Traversal) this; } @@ -74,10 +83,29 @@ public class Traversal { return (Traversal) this; } +private void setupProcessor() { +if (null == this.processor) +this.processor = this.factory.mint(this.bytecode); +} -// create a utility class that directly access the class field so we don't have to do the Admin stuff in TP4. -public Bytecode getBytecode() { -return this.bytecode; +@Override +public boolean hasNext() { +this.setupProcessor(); +return this.processor.hasNextTraverser(); } +@Override +public E next() { +this.setupProcessor();
[tinkerpop] 34/41: minor nothings. calling it a day.
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 955f2f14d1b0a21b3aa616e3b6c50dca827b662a Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 16:16:38 2019 -0600 minor nothings. calling it a day. --- .../org/apache/tinkerpop/machine/beam/Beam.java| 32 -- .../apache/tinkerpop/machine/beam/BeamTest.java| 4 ++- 2 files changed, 20 insertions(+), 16 deletions(-) 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 cf517e9..904 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 @@ -60,26 +60,27 @@ public class Beam implements Processor { private final List functions = new ArrayList<>(); private Iterator> iterator = null; -public Beam(final Compilation compilation) { +private final TraverserCoder coder = new TraverserCoder<>(); +public Beam(final Compilation compilation) { this.pipeline = Pipeline.create(); -PCollection> collection = this.pipeline.apply(Create.of(compilation.getTraverserFactory().create((Coefficient) LongCoefficient.create(), 1L))); -collection.setCoder(new TraverserCoder()); -for (final CFunction function : compilation.getFunctions()) { +PCollection> collection = this.pipeline.apply(Create.of(compilation.getTraverserFactory().create((Coefficient) LongCoefficient.create(), 1L))); +collection.setCoder(this.coder); +for (final CFunction function : compilation.getFunctions()) { collection = processFunction(collection, compilation.getTraverserFactory(), function, false); } -collection.apply(ParDo.of(new OutputStep())); +collection.apply(ParDo.of(new OutputStep<>())); this.pipeline.getOptions().setRunner(new PipelineOptions.DirectRunner().create(this.pipeline.getOptions())); } -private PCollection> processFunction( -PCollection> collection, +private PCollection> processFunction( +PCollection> collection, final TraverserFactory traverserFactory, final CFunction function, final boolean branching) { DoFn, Traverser> fn = null; if (function instanceof RepeatBranch) { -final Compilation repeat = ((RepeatBranch) function).getRepeat(); +; final List outputs = new ArrayList<>(); final TupleTag repeatDone = new TupleTag<>(); final TupleTag repeatLoop = new TupleTag<>(); @@ -89,7 +90,7 @@ public class Beam implements Processor { branches.get(repeatLoop).setCoder(new TraverserCoder()); branches.get(repeatDone).setCoder(new TraverserCoder()); outputs.add(branches.get(repeatDone)); -for (final CFunction repeatFunction : repeat.getFunctions()) { +for (final CFunction repeatFunction : ((RepeatBranch) function).getRepeat().getFunctions()) { collection = this.processFunction(branches.get(repeatLoop), traverserFactory, repeatFunction, true); } } @@ -98,9 +99,9 @@ public class Beam implements Processor { collection.setCoder(new TraverserCoder()); } else if (function instanceof BranchFunction) { final List> branches = ((BranchFunction) function).getInternals(); -final List>> collections = new ArrayList<>(branches.size()); +final List>> collections = new ArrayList<>(branches.size()); for (final Compilation branch : branches) { -PCollection> branchCollection = collection; +PCollection> branchCollection = collection; for (final CFunction branchFunction : branch.getFunctions()) { branchCollection = this.processFunction(branchCollection, traverserFactory, branchFunction, true); } @@ -118,7 +119,7 @@ public class Beam implements Processor { fn = new MapFn<>((MapFunction) function); } else if (function instanceof ReduceFunction) { final ReduceFn combine = new ReduceFn<>((ReduceFunction) function, traverserFactory); -collection = (PCollection>) collection.apply(Combine.globally((ReduceFn) combine)); +collection = (PCollection>) collection.apply(Combine.globally((ReduceFn) combine)); this.functions.add(combine); } else throw new RuntimeException("You need a new step type:" + function); @@ -126,9 +127,9 @@ public clas
[tinkerpop] 16/41: minor changes. taking a break.
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 d602c0706e0e430eacfc4761d61d6b2ddf7e2340 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:49:22 2019 -0600 minor changes. taking a break. --- .../java/org/apache/tinkerpop/language/Symbols.java | 5 + .../java/org/apache/tinkerpop/machine/beam/Beam.java | 19 ++- 2 files changed, 15 insertions(+), 9 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 b302b88..9ea778d 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 @@ -23,6 +23,11 @@ package org.apache.tinkerpop.language; */ public final class Symbols { +// SOURCE OPS +public static final String COEFFICIENT = "coefficient"; + + +// INSTRUCTION OPS public static final String AS = "as"; public static final String C = "c"; public static final String COUNT = "count"; 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 b93174e..f2813b4 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 @@ -19,6 +19,7 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.options.PipelineOptions; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.DoFn; import org.apache.beam.sdk.transforms.ParDo; @@ -44,17 +45,16 @@ import java.util.List; */ public class Beam implements Processor { -final Pipeline pipeline; -PCollection collection; -public static List OUTPUT = new ArrayList<>(); -Iterator iterator = null; +private final Pipeline pipeline; +public static List OUTPUT = new ArrayList<>(); // FIX THIS! private final List functions = new ArrayList<>(); +Iterator iterator = null; public Beam(final List> functions) { this.pipeline = Pipeline.create(); this.pipeline.getCoderRegistry().registerCoderForClass(Traverser.class, new TraverserCoder<>()); -this.collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); -this.collection.setCoder(new TraverserCoder()); +PCollection collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); +collection.setCoder(new TraverserCoder()); DoFn fn = null; for (final CFunction function : functions) { @@ -69,10 +69,11 @@ public class Beam implements Processor { } else throw new RuntimeException("You need a new step type:" + function); this.functions.add(fn); -this.collection = (PCollection) collection.apply(ParDo.of(fn)); -this.collection.setCoder(new TraverserCoder()); +collection = (PCollection) collection.apply(ParDo.of(fn)); +collection.setCoder(new TraverserCoder()); } collection = (PCollection) collection.apply(ParDo.of(new OutputStep())); +this.pipeline.getOptions().setRunner(new PipelineOptions.DirectRunner().create(this.pipeline.getOptions())); } public Beam(final Bytecode bytecode) { @@ -108,7 +109,7 @@ public class Beam implements Processor { private final void setupPipeline() { if (null == this.iterator) { -pipeline.run().waitUntilFinish(); +this.pipeline.run().waitUntilFinish(); this.iterator = new ArrayList<>(OUTPUT).iterator(); OUTPUT.clear(); }
[tinkerpop] branch tp4 updated: Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just w
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 The following commit(s) were added to refs/heads/tp4 by this push: new 58e761d Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just work without any special consideration in Beam. I need to get repeat() to be general -- but that is tricky given its recrussive nature. For now, a special repeat()-case exists. 58e761d is described below commit 58e761de63ab5c2f89343ed2a5f70fd7a257ed4f Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 10:09:01 2019 -0600 Really cleaned up Beam. We have a TopologyUtil that translates a Compilation into a Beam topology. We also have branch support generalized so union, choose, etc. just work without any special consideration in Beam. I need to get repeat() to be general -- but that is tricky given its recrussive nature. For now, a special repeat()-case exists. --- .../machine/functions/branch/UnionBranch.java | 3 +- .../machine/traversers/EmptyTraverser.java | 63 +++ .../org/apache/tinkerpop/machine/beam/Beam.java| 108 ++- .../apache/tinkerpop/machine/beam/BranchFn.java| 6 +- .../apache/tinkerpop/machine/beam/RepeatFn.java| 10 +- .../tinkerpop/machine/beam/util/TopologyUtil.java | 120 + .../apache/tinkerpop/machine/beam/BeamTest.java| 13 ++- 7 files changed, 212 insertions(+), 111 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java index f10e22c..3195a40 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java @@ -52,8 +52,7 @@ public final class UnionBranch extends AbstractFunction> apply(final Traverser traverser) { final MultiIterator> iterator = new MultiIterator<>(); for (final Compilation branch : this.branches.get(Boolean.TRUE)) { -branch.getProcessor().addStart(traverser.clone()); -iterator.addIterator(branch.getProcessor()); +iterator.addIterator(branch.addTraverser(traverser)); } return iterator; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java new file mode 100644 index 000..b2eefb8 --- /dev/null +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/EmptyTraverser.java @@ -0,0 +1,63 @@ +/* + * 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.machine.traversers; + +import org.apache.tinkerpop.machine.coefficients.Coefficient; +import org.apache.tinkerpop.machine.functions.CFunction; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + */ +public final class EmptyTraverser implements Traverser { + +private static final EmptyTraverser INSTANCE = new EmptyTraverser(); + +private EmptyTraverser() { +// for static instances +} + +@Override +public Coefficient coefficient() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain a coefficient"); +} + +@Override +public S object() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain an object"); +} + +@Override +public Path path() { +throw new IllegalStateException(EmptyTraverser.class.getSimpleName() + " does not contain a path"); +} + +@Override +public Traverser split(CFunction function, E object) { +return INSTANCE; +} + +@Override +public Traverser clone() { +return INSTANCE; +} + +public static final EmptyTraverser instance() { +return INSTANC
[tinkerpop] branch tp4 updated: Finally figured out the generalized branch model. Its a little different than TP3 and it accounts for stream ring theory stuff. However, what makes it really special is
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 The following commit(s) were added to refs/heads/tp4 by this push: new 4c141f6 Finally figured out the generalized branch model. Its a little different than TP3 and it accounts for stream ring theory stuff. However, what makes it really special is that it lends itself easily to either a pull-based processor (Pipes) or a push-based processor (Beam). Beam is now generalized where it can take a BranchFunction (regardless of instance) and create an appropriate split/merge topology. 4c141f6 is described below commit 4c141f6a39a4a04875f0b23748a7d7d6fab6e480 Author: Marko A. Rodriguez AuthorDate: Wed Mar 13 07:28:06 2019 -0600 Finally figured out the generalized branch model. Its a little different than TP3 and it accounts for stream ring theory stuff. However, what makes it really special is that it lends itself easily to either a pull-based processor (Pipes) or a push-based processor (Beam). Beam is now generalized where it can take a BranchFunction (regardless of instance) and create an appropriate split/merge topology. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 14 +++- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 6 ++ .../tinkerpop/machine/bytecode/Compilation.java| 6 ++ .../machine/functions/BranchFunction.java | 9 ++- .../machine/functions/InternalFunction.java| 6 -- .../machine/functions/branch/ChooseBranch.java | 86 ++ .../machine/functions/branch/RepeatBranch.java | 19 +++-- .../machine/functions/branch/UnionBranch.java | 27 +-- .../branch/selector/HasNextSelector.java} | 22 +++--- .../selector/Selector.java}| 9 ++- .../selector/TrueSelector.java}| 17 - .../machine/functions/filter/FilterFilter.java | 4 - .../tinkerpop/machine/functions/map/MapMap.java| 5 -- .../machine/functions/reduce/GroupCountReduce.java | 4 - .../tinkerpop/machine/traversers/Traverser.java| 2 +- .../org/apache/tinkerpop/util/NumberHelper.java| 2 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 30 +--- .../apache/tinkerpop/machine/beam/BranchFn.java| 21 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 4 +- .../apache/tinkerpop/machine/pipes/BranchStep.java | 6 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 9 +-- 23 files changed, 229 insertions(+), 82 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 a11321f..efeeaad 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 @@ -34,6 +34,7 @@ public final class Symbols { // INSTRUCTION OPS +public static final String CHOOSE_IF_THEN_ELSE = "chooseIfThenElse"; public static final String COUNT = "count"; public static final String FILTER = "filter"; public static final String GROUP_COUNT = "groupCount"; 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 fdcc8d4..9a17bc5 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 @@ -63,6 +63,11 @@ public class Traversal implements Iterator { return this; } +public Traversal choose(final Traversal predicate, final Traversal trueTraversal, final Traversal falseTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.CHOOSE_IF_THEN_ELSE, predicate, trueTraversal, falseTraversal); +return (Traversal) this; +} + public Traversal count() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); return (Traversal) this; @@ -158,8 +163,13 @@ public class Traversal implements Iterator { return (Traversal) this; } -public Traversal union(final Traversal traversal, Traversal... traversals) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversal, traversals); +public Traversal union(final Traversal traversalA, final Traversal traversalB) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversalA, traversalB); +return (Traversal) this; +} + +public Traversal union(final Traversal traversalA, final Traversal traversalB, final Traversal traversalC) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UN
[tinkerpop] branch tp4 updated: minor nothings. calling it a day.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 955f2f1 minor nothings. calling it a day. 955f2f1 is described below commit 955f2f14d1b0a21b3aa616e3b6c50dca827b662a Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 16:16:38 2019 -0600 minor nothings. calling it a day. --- .../org/apache/tinkerpop/machine/beam/Beam.java| 32 -- .../apache/tinkerpop/machine/beam/BeamTest.java| 4 ++- 2 files changed, 20 insertions(+), 16 deletions(-) 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 cf517e9..904 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 @@ -60,26 +60,27 @@ public class Beam implements Processor { private final List functions = new ArrayList<>(); private Iterator> iterator = null; -public Beam(final Compilation compilation) { +private final TraverserCoder coder = new TraverserCoder<>(); +public Beam(final Compilation compilation) { this.pipeline = Pipeline.create(); -PCollection> collection = this.pipeline.apply(Create.of(compilation.getTraverserFactory().create((Coefficient) LongCoefficient.create(), 1L))); -collection.setCoder(new TraverserCoder()); -for (final CFunction function : compilation.getFunctions()) { +PCollection> collection = this.pipeline.apply(Create.of(compilation.getTraverserFactory().create((Coefficient) LongCoefficient.create(), 1L))); +collection.setCoder(this.coder); +for (final CFunction function : compilation.getFunctions()) { collection = processFunction(collection, compilation.getTraverserFactory(), function, false); } -collection.apply(ParDo.of(new OutputStep())); +collection.apply(ParDo.of(new OutputStep<>())); this.pipeline.getOptions().setRunner(new PipelineOptions.DirectRunner().create(this.pipeline.getOptions())); } -private PCollection> processFunction( -PCollection> collection, +private PCollection> processFunction( +PCollection> collection, final TraverserFactory traverserFactory, final CFunction function, final boolean branching) { DoFn, Traverser> fn = null; if (function instanceof RepeatBranch) { -final Compilation repeat = ((RepeatBranch) function).getRepeat(); +; final List outputs = new ArrayList<>(); final TupleTag repeatDone = new TupleTag<>(); final TupleTag repeatLoop = new TupleTag<>(); @@ -89,7 +90,7 @@ public class Beam implements Processor { branches.get(repeatLoop).setCoder(new TraverserCoder()); branches.get(repeatDone).setCoder(new TraverserCoder()); outputs.add(branches.get(repeatDone)); -for (final CFunction repeatFunction : repeat.getFunctions()) { +for (final CFunction repeatFunction : ((RepeatBranch) function).getRepeat().getFunctions()) { collection = this.processFunction(branches.get(repeatLoop), traverserFactory, repeatFunction, true); } } @@ -98,9 +99,9 @@ public class Beam implements Processor { collection.setCoder(new TraverserCoder()); } else if (function instanceof BranchFunction) { final List> branches = ((BranchFunction) function).getInternals(); -final List>> collections = new ArrayList<>(branches.size()); +final List>> collections = new ArrayList<>(branches.size()); for (final Compilation branch : branches) { -PCollection> branchCollection = collection; +PCollection> branchCollection = collection; for (final CFunction branchFunction : branch.getFunctions()) { branchCollection = this.processFunction(branchCollection, traverserFactory, branchFunction, true); } @@ -118,7 +119,7 @@ public class Beam implements Processor { fn = new MapFn<>((MapFunction) function); } else if (function instanceof ReduceFunction) { final ReduceFn combine = new ReduceFn<>((ReduceFunction) function, traverserFactory); -collection = (PCollection>) collection.apply(Combine.globally((ReduceFn) combine)); +collection = (PCollection>) collection.apply(Combine.globally((ReduceFn) combine)); this.functions.add(combi
[tinkerpop] branch tp4 updated: repeat() implemented in Apache Beam. Its not pretty, but it works. I'm not that confident with the Beam API. Once I fully grock it, I will do a massive cleanup of the B
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 The following commit(s) were added to refs/heads/tp4 by this push: new e21924f repeat() implemented in Apache Beam. Its not pretty, but it works. I'm not that confident with the Beam API. Once I fully grock it, I will do a massive cleanup of the Beam compiler. e21924f is described below commit e21924fcd2cba64e1e8c88e70c092c72cfd053c4 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 15:28:59 2019 -0600 repeat() implemented in Apache Beam. Its not pretty, but it works. I'm not that confident with the Beam API. Once I fully grock it, I will do a massive cleanup of the Beam compiler. --- .../org/apache/tinkerpop/language/Symbols.java | 3 + .../org/apache/tinkerpop/language/Traversal.java | 5 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../machine/functions/branch/RepeatBranch.java | 18 -- .../machine/functions/flatmap/UnfoldFlatMap.java | 68 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 27 +++-- .../apache/tinkerpop/machine/beam/BranchFn.java| 2 +- .../machine/beam/{BranchFn.java => RepeatFn.java} | 28 ++--- .../apache/tinkerpop/machine/beam/BeamTest.java| 10 ++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 +- 10 files changed, 147 insertions(+), 21 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 8b4ebef..a11321f 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 @@ -47,6 +47,7 @@ public final class Symbols { public static final String PATH = "path"; public static final String REPEAT = "repeat"; public static final String SUM = "sum"; +public static final String UNFOLD = "unfold"; public static final String UNION = "union"; public Type getOpType(final String op) { @@ -77,6 +78,8 @@ public final class Symbols { return Type.BRANCH; case SUM: return Type.REDUCE; +case UNFOLD: +return Type.FLATMAP; case UNION: return Type.BRANCH; default: 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 cf90d24..fdcc8d4 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 @@ -153,6 +153,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal unfold() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNFOLD); +return (Traversal) this; +} + public Traversal union(final Traversal traversal, Traversal... traversals) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, traversal, traversals); return (Traversal) this; 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 42922b7..eea1df5 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,6 +28,7 @@ import org.apache.tinkerpop.machine.functions.filter.HasKeyFilter; import org.apache.tinkerpop.machine.functions.filter.HasKeyValueFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; +import org.apache.tinkerpop.machine.functions.flatmap.UnfoldFlatMap; import org.apache.tinkerpop.machine.functions.initial.InjectInitial; import org.apache.tinkerpop.machine.functions.map.IncrMap; import org.apache.tinkerpop.machine.functions.map.MapMap; @@ -161,6 +162,8 @@ public final class BytecodeUtil { return new RepeatBranch(coefficient, labels, Compilation.compile(instruction.args())); case Symbols.SUM: return new SumReduce<>(coefficient, labels); +case Symbols.UNFOLD: +return new UnfoldFlatMap<>(coefficient, labels); case Symbols.UNION: return new UnionBranch<>(coefficient, labels, Compilation.compile(instruction.args())); default: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java index f8ec403..c31b7c1 100644 ---
[tinkerpop] branch tp4 updated: have a much cleaner implementation of RepeatBranch. Simplified Compilation a bit.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 1c3c607 have a much cleaner implementation of RepeatBranch. Simplified Compilation a bit. 1c3c607 is described below commit 1c3c607e2df1531606494cb0dd9e19d736569f3c Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 12:25:09 2019 -0600 have a much cleaner implementation of RepeatBranch. Simplified Compilation a bit. --- .../tinkerpop/machine/bytecode/Compilation.java | 5 - .../machine/functions/branch/RepeatBranch.java | 20 +--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java index a3d9b6c..f973a8f 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java @@ -55,11 +55,6 @@ public final class Compilation implements Serializable { return this.processor; } -public void addTraverser(final Traverser traverser) { -this.prepareProcessor(); -this.processor.addStart(traverser); -} - public void reset() { if (null != this.processor) this.processor.reset(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java index c879373..f8ec403 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java @@ -23,9 +23,9 @@ import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.AbstractFunction; import org.apache.tinkerpop.machine.functions.BranchFunction; import org.apache.tinkerpop.machine.traversers.Traverser; +import org.apache.tinkerpop.util.IteratorUtils; import org.apache.tinkerpop.util.StringFactory; -import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -47,17 +47,15 @@ public class RepeatBranch extends AbstractFunction> apply(final Traverser traverser) { -this.repeat.addTraverser(traverser); -final List> toGo = new ArrayList<>(); -while (this.repeat.getProcessor().hasNext()) { -Traverser t = this.repeat.getProcessor().next(); -boolean loop = !this.until.filterTraverser(t); -if (loop) +this.repeat.getProcessor().addStart(traverser); +return IteratorUtils.filter(this.repeat.getProcessor(), t -> { +if (!this.until.filterTraverser(t)) { this.repeat.getProcessor().addStart(t); -else -toGo.add(t); -} -return toGo.iterator(); +return false; +} else +return true; + +}); } @Override
[tinkerpop] branch tp4 updated: fixed a bug in FilterStep. Added repeat(). I have only tested it in Pipes. Given that Beam doesn't support recurssion, we will have to use the exponential loop form dev
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 The following commit(s) were added to refs/heads/tp4 by this push: new 4cae62b fixed a bug in FilterStep. Added repeat(). I have only tested it in Pipes. Given that Beam doesn't support recurssion, we will have to use the exponential loop form developed in the Stream Ring Theory paper. Basically, concatenate the repeat sequence over and over and over (for some large number) and always have a multi-output for breaking out of the loop. Need to take a break. 4cae62b is described below commit 4cae62b7310a8ad9d1443a11ac6dc502bfd5eda5 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 12:15:53 2019 -0600 fixed a bug in FilterStep. Added repeat(). I have only tested it in Pipes. Given that Beam doesn't support recurssion, we will have to use the exponential loop form developed in the Stream Ring Theory paper. Basically, concatenate the repeat sequence over and over and over (for some large number) and always have a multi-output for breaking out of the loop. Need to take a break. --- .../org/apache/tinkerpop/language/Symbols.java | 46 -- .../org/apache/tinkerpop/language/Traversal.java | 10 +++ .../java/org/apache/tinkerpop/language/__.java | 4 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../tinkerpop/machine/bytecode/Compilation.java| 5 ++ .../machine/functions/branch/RepeatBranch.java | 72 ++ .../apache/tinkerpop/machine/pipes/FilterStep.java | 10 ++- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +- 8 files changed, 147 insertions(+), 8 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 0d431ae..8b4ebef 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 @@ -23,6 +23,10 @@ package org.apache.tinkerpop.language; */ public final class Symbols { +public static enum Type { +INITIAL, MAP, FLATMAP, FILTER, REDUCE, BRANCH +} + // SOURCE OPS public static final String WITH_COEFFICIENT = "withCoefficient"; public static final String WITH_PROCESSOR = "withProcessor"; @@ -30,19 +34,53 @@ public final class Symbols { // INSTRUCTION OPS -public static final String AS = "as"; -public static final String C = "c"; public static final String COUNT = "count"; public static final String FILTER = "filter"; public static final String GROUP_COUNT = "groupCount"; -public static final String HAS_KEY_VALUE = "hasKeyValue"; public static final String HAS_KEY = "hasKey"; +public static final String HAS_KEY_VALUE = "hasKeyValue"; public static final String IDENTITY = "identity"; -public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String IS = "is"; public static final String MAP = "map"; public static final String PATH = "path"; +public static final String REPEAT = "repeat"; public static final String SUM = "sum"; public static final String UNION = "union"; + +public Type getOpType(final String op) { +switch (op) { +case COUNT: +return Type.REDUCE; +case FILTER: +return Type.FILTER; +case GROUP_COUNT: +return Type.REDUCE; +case HAS_KEY: +return Type.FILTER; +case HAS_KEY_VALUE: +return Type.FILTER; +case IDENTITY: +return Type.FILTER; +case INCR: +return Type.MAP; +case INJECT: +return Type.INITIAL; +case IS: +return Type.FILTER; +case MAP: +return Type.MAP; +case PATH: +return Type.MAP; +case REPEAT: +return Type.BRANCH; +case SUM: +return Type.REDUCE; +case UNION: +return Type.BRANCH; +default: +throw new IllegalArgumentException("The following op is unknown: " + op); +} +} } 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 92a7d23..cf90d24 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java +++ b/java/core/src/main/java/org/
[tinkerpop] branch tp4 updated: We now naturally support constant or traversal-based arguments. This is all nicely packaged with the new Compilation object (which is turning out to be way cooler than
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 The following commit(s) were added to refs/heads/tp4 by this push: new 984a1b5 We now naturally support constant or traversal-based arguments. This is all nicely packaged with the new Compilation object (which is turning out to be way cooler than Bytecode. Its like JIT). Added has(), groupCount(), ... 984a1b5 is described below commit 984a1b591029f572717e223f1f708b451b6161e3 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 11:15:31 2019 -0600 We now naturally support constant or traversal-based arguments. This is all nicely packaged with the new Compilation object (which is turning out to be way cooler than Bytecode. Its like JIT). Added has(), groupCount(), ... --- .../org/apache/tinkerpop/language/Symbols.java | 3 + .../org/apache/tinkerpop/language/Traversal.java | 53 +--- .../apache/tinkerpop/language/TraversalUtil.java | 4 -- .../{CompilationRing.java => Argument.java}| 35 --- .../tinkerpop/machine/bytecode/Bytecode.java | 2 + .../tinkerpop/machine/bytecode/BytecodeUtil.java | 9 +++ .../tinkerpop/machine/bytecode/Compilation.java| 9 +++ .../machine/bytecode/CompilationRing.java | 2 +- .../tinkerpop/machine/bytecode/Instruction.java| 4 ++ .../machine/functions/filter/HasKeyFilter.java | 53 .../functions/filter/HasKeyValueFilter.java| 55 + .../machine/functions/reduce/GroupCountReduce.java | 70 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 7 ++- .../apache/tinkerpop/machine/beam/BranchFn.java| 9 +-- .../apache/tinkerpop/machine/beam/FlatMapFn.java | 2 +- .../apache/tinkerpop/machine/beam/ReduceFn.java| 23 +++ .../CoefficientCoder.java} | 11 ++-- .../ObjectCoder.java} | 12 ++-- .../beam/{ => serialization}/ReducerCoder.java | 11 ++-- .../beam/{ => serialization}/TraverserCoder.java | 2 +- .../BasicReducer.java} | 9 +-- .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- .../beam/functions/TraversalSourceLibrary.java}| 18 +++--- .../functions/filter/BeamHasKeyValueTest.java} | 15 +++-- .../beam/functions/filter/BeamIdentityTest.java} | 16 ++--- .../apache/tinkerpop/machine/pipes/BranchStep.java | 5 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 2 +- .../tinkerpop/machine/pipes/FlatMapStep.java | 5 +- .../tinkerpop/machine/pipes/InitialStep.java | 2 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 2 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 5 +- .../tinkerpop/machine/pipes/PipesProcessor.java| 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 4 +- .../machine/pipes/strategies/PipesStrategy.java| 2 +- .../tinkerpop/machine/pipes/util/BasicReducer.java | 2 +- .../tinkerpop/machine/pipes/util/Reducer.java | 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 +- .../pipes/functions/TraversalSourceLibrary.java} | 19 +++--- .../functions/filter/PipesHasKeyValueTest.java}| 15 +++-- .../pipes/functions/filter/PipesIdentityTest.java} | 14 ++--- .../HasKeyValueTest.java} | 32 -- .../{filters => filter}/IdentityTest.java | 2 +- 42 files changed, 387 insertions(+), 170 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 81c80bb..0d431ae 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 @@ -34,6 +34,9 @@ public final class Symbols { public static final String C = "c"; public static final String COUNT = "count"; public static final String FILTER = "filter"; +public static final String GROUP_COUNT = "groupCount"; +public static final String HAS_KEY_VALUE = "hasKeyValue"; +public static final String HAS_KEY = "hasKey"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 92ae122..92a7d23 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 @@ -29,6 +29,7 @@ import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.
[tinkerpop] branch tp4 updated: add CoefficientStrategy which knows how to propagate the unity coefficient to all child bytecode. Also, it assumes LongCoefficient (95 percent of cases) if no withCoeff
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 The following commit(s) were added to refs/heads/tp4 by this push: new d4e4503 add CoefficientStrategy which knows how to propagate the unity coefficient to all child bytecode. Also, it assumes LongCoefficient (95 percent of cases) if no withCoefficient() is provided to the TraversalSource. Added our first by() modulation support to path()-step. CompilationRing is used in an analagous fashion to FunctionRing in TP3. Finally cleaned up ProcessorFactory to now take a Compilation. There is a hard line where Bytecode is no longer the currency of the ma [...] d4e4503 is described below commit d4e4503c342efd2e9fb4aff885b10f07bb823079 Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 07:57:36 2019 -0600 add CoefficientStrategy which knows how to propagate the unity coefficient to all child bytecode. Also, it assumes LongCoefficient (95 percent of cases) if no withCoefficient() is provided to the TraversalSource. Added our first by() modulation support to path()-step. CompilationRing is used in an analagous fashion to FunctionRing in TP3. Finally cleaned up ProcessorFactory to now take a Compilation. There is a hard line where Bytecode is no longer the currency of the machine, but a C [...] --- .../org/apache/tinkerpop/language/Traversal.java | 4 +- .../apache/tinkerpop/language/TraversalSource.java | 2 + .../tinkerpop/machine/bytecode/BytecodeUtil.java | 5 +-- .../tinkerpop/machine/bytecode/Compilation.java| 17 - .../CompilationRing.java} | 44 +- .../tinkerpop/machine/functions/map/PathMap.java | 18 - .../machine/processor/EmptyProcessorFactory.java | 5 +-- .../machine/processor/ProcessorFactory.java| 11 +- .../machine/strategies/CoefficientStrategy.java| 21 ++- .../org/apache/tinkerpop/machine/beam/Beam.java| 29 ++ .../tinkerpop/machine/beam/BeamProcessor.java | 7 ++-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 ++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 11 +++--- .../tinkerpop/machine/pipes/PipesProcessor.java| 10 ++--- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 7 .../tinkerpop/machine/pipes/util/BasicReducer.java | 7 .../tinkerpop/machine/pipes/util/Reducer.java | 2 + .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 18 files changed, 133 insertions(+), 74 deletions(-) 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 e620314..92ae122 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 @@ -52,7 +52,7 @@ public class Traversal implements Iterator { return this; } -public Traversal by(final Traversal byTraversal) { +public Traversal by(final Traversal byTraversal) { this.bytecode.lastInstruction().addArg(byTraversal); return this; } @@ -120,7 +120,7 @@ public class Traversal implements Iterator { private final void prepareTraversal() { if (null == this.compilation) -this.compilation = Compilation.compile(bytecode); +this.compilation = Compilation.compile(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 355ab61..e42c8dd 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.processor.ProcessorFactory; +import org.apache.tinkerpop.machine.strategies.CoefficientStrategy; import org.apache.tinkerpop.machine.strategies.Strategy; /** @@ -32,6 +33,7 @@ public class TraversalSource { protected TraversalSource() { this.bytecode = new Bytecode<>(); +this.bytecode.addSourceInstruction(Symbols.WITH_STRATEGY, CoefficientStrategy.class); } public TraversalSource withCoefficient(final Class> coefficient) { 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 635e787..0f129f2 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 @@ -47,11 +47,10
[tinkerpop] branch tp4 updated: InternalFunctions is a super interface to BranchFunction and NestedFunction. getInternals() (crappy name for now) allow access to Function compilations.
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 The following commit(s) were added to refs/heads/tp4 by this push: new e26ca81 InternalFunctions is a super interface to BranchFunction and NestedFunction. getInternals() (crappy name for now) allow access to Function compilations. e26ca81 is described below commit e26ca81c52474cc491c77b6f12171399053f154e Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 07:03:23 2019 -0600 InternalFunctions is a super interface to BranchFunction and NestedFunction. getInternals() (crappy name for now) allow access to Function compilations. --- .../org/apache/tinkerpop/machine/functions/BranchFunction.java | 3 --- .../apache/tinkerpop/machine/functions/InternalFunction.java | 7 +-- .../apache/tinkerpop/machine/functions/branch/UnionBranch.java | 10 ++ .../tinkerpop/machine/functions/filter/FilterFilter.java | 7 +++ .../org/apache/tinkerpop/machine/functions/map/MapMap.java | 7 +++ .../src/main/java/org/apache/tinkerpop/machine/beam/Beam.java | 7 --- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java index 8092095..8f7965f 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java @@ -21,7 +21,6 @@ package org.apache.tinkerpop.machine.functions; import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.Iterator; -import java.util.List; import java.util.function.Function; /** @@ -29,6 +28,4 @@ import java.util.function.Function; */ public interface BranchFunction extends Function, Iterator>>, InternalFunction { -public List>> getBranches(); - } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java index a2ce8e1..9481137 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/InternalFunction.java @@ -18,12 +18,15 @@ */ package org.apache.tinkerpop.machine.functions; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; +import org.apache.tinkerpop.machine.bytecode.Compilation; + +import java.util.List; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ public interface InternalFunction extends CFunction { +public List> getInternals(); + } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java index c2f7a21..6f72b48 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/UnionBranch.java @@ -22,12 +22,10 @@ import org.apache.tinkerpop.machine.bytecode.Compilation; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.AbstractFunction; import org.apache.tinkerpop.machine.functions.BranchFunction; -import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.traversers.Traverser; import org.apache.tinkerpop.util.MultiIterator; import org.apache.tinkerpop.util.StringFactory; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -60,11 +58,7 @@ public final class UnionBranch extends AbstractFunction>> getBranches() { -final List>> branches = new ArrayList<>(); -for (final Compilation compilation : this.branches) { -branches.add(compilation.getFunctions()); -} -return branches; +public List> getInternals() { +return (List) this.branches; } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java index b7b25bd..f9e86d4 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java @@ -26,6 +26,8 @@ import org.apache.tinkerpop.machine.functions.NestedFunction; import org.apache.tinkerpop.machine.traversers.Traverser; import org.apache.tinkerpop.util.StringFactory; +import java.util.Collections; +import java.util.List; import java.util.
[tinkerpop] branch tp4 updated: really cleaned up the compilation process. We have a new super cool class called Compilation. It represents a strategized and function compiled Bytecode. It also enable
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 The following commit(s) were added to refs/heads/tp4 by this push: new eb05677 really cleaned up the compilation process. We have a new super cool class called Compilation. It represents a strategized and function compiled Bytecode. It also enables Processor interaction. Sorta like TraversalHelper in TP3. This really cleaned up the function code and will allow us to now do nested traversal processing with ease. eb05677 is described below commit eb05677bd53d9be682399727d6169d9a6db06e7e Author: Marko A. Rodriguez AuthorDate: Tue Mar 12 06:57:59 2019 -0600 really cleaned up the compilation process. We have a new super cool class called Compilation. It represents a strategized and function compiled Bytecode. It also enables Processor interaction. Sorta like TraversalHelper in TP3. This really cleaned up the function code and will allow us to now do nested traversal processing with ease. --- .../org/apache/tinkerpop/language/Traversal.java | 28 ++--- .../apache/tinkerpop/language/TraversalSource.java | 9 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 50 + .../tinkerpop/machine/bytecode/Compilation.java| 113 + .../machine/coefficients/LongCoefficient.java | 2 +- .../machine/functions/BranchFunction.java | 1 + .../machine/functions/InternalFunction.java| 1 - .../machine/functions/NestedFunction.java | 3 - .../machine/functions/branch/UnionBranch.java | 41 +++- .../machine/functions/filter/FilterFilter.java | 37 ++- .../tinkerpop/machine/functions/map/MapMap.java| 37 ++- .../machine/processor/EmptyProcessor.java | 2 +- .../machine/processor/EmptyProcessorFactory.java | 9 +- .../machine/processor/ProcessorFactory.java| 12 +++ .../CoefficientStrategy.java} | 13 +-- .../apache/tinkerpop/machine/traversers/Path.java | 12 +++ .../apache/tinkerpop/machine/TraversalTest.java| 4 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 5 - .../tinkerpop/machine/beam/BeamProcessor.java | 11 +- .../BeamStrategy.java} | 20 ++-- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 3 - .../tinkerpop/machine/pipes/PipesProcessor.java| 12 ++- .../machine/pipes/strategies/PipesStrategy.java} | 20 ++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- 24 files changed, 268 insertions(+), 179 deletions(-) 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 f072712..e620314 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 @@ -20,11 +20,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.bytecode.Compilation; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.coefficients.LongCoefficient; -import org.apache.tinkerpop.machine.processor.EmptyProcessorFactory; -import org.apache.tinkerpop.machine.processor.Processor; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; import org.apache.tinkerpop.machine.traversers.Traverser; @@ -39,8 +37,7 @@ public class Traversal implements Iterator { protected final Bytecode bytecode; private Coefficient currentCoefficient; -private final ProcessorFactory processorFactory; -private Processor processor; +private Compilation compilation; // private long lastCount = 0L; private E lastObject = null; @@ -48,7 +45,6 @@ public class Traversal implements Iterator { protected Traversal(final Bytecode bytecode) { this.bytecode = bytecode; this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); -this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(EmptyProcessorFactory.instance()); } public Traversal as(final String label) { @@ -122,26 +118,25 @@ public class Traversal implements Iterator { /// - -private void setupProcessor() { -if (null == this.processor) -this.processor = this.processorFactory.mint(this.bytecode); +private final void prepareTraversal() { +if (null == this.compilation) +this.compilation = Compilation.compile(bytecode); } @Override public boolean hasNext() { -this.setupProcessor(); -return this.lastCount >
[tinkerpop] branch tp4 updated: small tweak.
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 The following commit(s) were added to refs/heads/tp4 by this push: new bd06d2a small tweak. bd06d2a is described below commit bd06d2aa0f2eb0af71a0f07fa616f9b9f00dd82a Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 15:43:01 2019 -0600 small tweak. --- .../java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java | 3 +-- .../apache/tinkerpop/machine/functions/filters/IdentityTest.java| 6 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java index 88b833d..13dd6b2 100644 --- a/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java +++ b/java/machine/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesIdentityTest.java @@ -30,10 +30,9 @@ import org.junit.jupiter.api.Test; public class PipesIdentityTest { private TraversalSource g = Gremlin.traversal().withProcessor(PipesProcessor.class).withCoefficient(LongCoefficient.class); -private IdentityTest test = new IdentityTest(); @Test public void g_injectX2X_identity() { -test.g_injectX2X_identity(g.inject(2L).identity()); +IdentityTest.g_injectX2X_identity(g.inject(2L).identity()); } } diff --git a/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java b/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java index 45d0515..4699eb7 100644 --- a/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java +++ b/java/test/src/main/java/org/apache/tinkerpop/machine/functions/filters/IdentityTest.java @@ -29,7 +29,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; */ public class IdentityTest { -public void g_injectX2X_identity(final Traversal traversal) { +private IdentityTest() { +// static class +} + +public static void g_injectX2X_identity(final Traversal traversal) { final List list = traversal.toList(); assertEquals(1, list.size()); assertEquals(2L, list.get(0));
[tinkerpop] branch tp4 updated: added test/ module and stubbed the first IdentityTest.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 7e313cb added test/ module and stubbed the first IdentityTest. 7e313cb is described below commit 7e313cb66ce4e557c284b98b3a194bda505f80de Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 15:41:40 2019 -0600 added test/ module and stubbed the first IdentityTest. --- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 4 ++-- .../{NestedFunction.java => BranchFunction.java} | 18 --- .../{NestedFunction.java => InternalFunction.java} | 13 +-- .../machine/functions/NestedFunction.java | 13 +-- .../UnionFlatMap.java => branch/UnionBranch.java} | 24 +-- .../machine/functions/filter/FilterFilter.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../apache/tinkerpop/machine/traversers/Path.java | 3 +++ .../tinkerpop/machine/traversers/Traverser.java| 5 .../org/apache/tinkerpop/machine/beam/Beam.java| 15 ++-- .../apache/tinkerpop/machine/beam/BranchFn.java} | 27 -- java/machine/pipes/pom.xml | 7 ++ .../pipes/{FlatMapStep.java => BranchStep.java}| 23 +++--- .../tinkerpop/machine/pipes/FlatMapStep.java | 9 +++- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 11 + .../machine/pipes/PipesIdentityTest.java} | 26 ++--- .../apache/tinkerpop/machine/pipes/PipesTest.java | 4 ++-- java/pom.xml | 1 + java/{machine/pipes => test}/pom.xml | 17 +++--- .../machine/functions/filters/IdentityTest.java} | 22 -- 20 files changed, 129 insertions(+), 117 deletions(-) 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 07f2f1d..4746e97 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 @@ -24,7 +24,7 @@ import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.functions.filter.FilterFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; -import org.apache.tinkerpop.machine.functions.flatMap.UnionFlatMap; +import org.apache.tinkerpop.machine.functions.branch.UnionBranch; import org.apache.tinkerpop.machine.functions.initial.InjectInitial; import org.apache.tinkerpop.machine.functions.map.IncrMap; import org.apache.tinkerpop.machine.functions.map.MapMap; @@ -143,7 +143,7 @@ public final class BytecodeUtil { for (final Bytecode arg : (Bytecode[]) instruction.args()) { branchFunctions.add(compile(arg)); } -return new UnionFlatMap<>(coefficient, labels, branchFunctions); +return new UnionBranch<>(coefficient, labels, branchFunctions); default: throw new RuntimeException("This is an unknown instruction:" + instruction.op()); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java similarity index 64% copy from java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java copy to java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java index 2119f54..cfebf7a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/BranchFunction.java @@ -18,24 +18,16 @@ */ package org.apache.tinkerpop.machine.functions; -import org.apache.tinkerpop.machine.processor.ProcessorFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; +import org.apache.tinkerpop.machine.traversers.Traverser; +import java.util.Iterator; import java.util.List; +import java.util.function.Function; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface NestedFunction extends CFunction { +public interface BranchFunction extends Function, Iterator>>, InternalFunction { -public void setProcessor(final TraverserFactory traverserFactory, final ProcessorFactory processorFactory); - -public List>> getFunctions(); - -public interface Branching extends NestedFunction { -} - -public interface Internal extends NestedFunction { - -} +public List>> getBranches(); } diff --git a/java/co
[tinkerpop] branch tp4 updated: added filter(traversal).
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 The following commit(s) were added to refs/heads/tp4 by this push: new f684e0f added filter(traversal). f684e0f is described below commit f684e0f0b7c4f9cbd6f1ecbff265cce79bf85d9e Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 14:16:05 2019 -0600 added filter(traversal). --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 +++ .../java/org/apache/tinkerpop/language/__.java | 4 ++ .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 ++ .../UnionFlatMap.java => filter/FilterFilter.java} | 48 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 3 +- .../machine/functions/flatMap/UnionFlatMap.java| 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +++ 9 files changed, 42 insertions(+), 33 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 7964d07..81c80bb 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 @@ -33,6 +33,7 @@ public final class Symbols { public static final String AS = "as"; public static final String C = "c"; public static final String COUNT = "count"; +public static final String FILTER = "filter"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 4eef5cd..0e8f40a 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 @@ -71,6 +71,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal filter(final Traversal filterTraversal) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.FILTER, filterTraversal.bytecode); +return this; +} + public Traversal identity() { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IDENTITY); return this; 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 4c2b4ba..8c8a929 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/__.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/__.java @@ -25,6 +25,10 @@ import org.apache.tinkerpop.machine.bytecode.Bytecode; */ public class __ { +private __() { +// static class +} + private static Traversal start() { return new Traversal<>(new Bytecode<>()); } 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 10a9b2f..07f2f1d 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 @@ -21,6 +21,7 @@ package org.apache.tinkerpop.machine.bytecode; import org.apache.tinkerpop.language.Symbols; import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.CFunction; +import org.apache.tinkerpop.machine.functions.filter.FilterFilter; import org.apache.tinkerpop.machine.functions.filter.IdentityFilter; import org.apache.tinkerpop.machine.functions.filter.IsFilter; import org.apache.tinkerpop.machine.functions.flatMap.UnionFlatMap; @@ -121,6 +122,8 @@ public final class BytecodeUtil { switch (op) { case Symbols.COUNT: return new CountReduce<>(coefficient, labels); +case Symbols.FILTER: +return new FilterFilter<>(coefficient, labels, compile((Bytecode) instruction.args()[0])); case Symbols.IDENTITY: return new IdentityFilter<>(coefficient, labels); case Symbols.INJECT: diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java similarity index 55% copy from java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java copy to java/core/src/main/java/org/apache/tinkerpop/machine/functions/filter/FilterFilter.java inde
[tinkerpop] branch tp4 updated: found a mutation bug in Apache Beam. Even when you filter, you have to make sure that its a new object being added to the output. Thus, you have to clone the object.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 0af1189 found a mutation bug in Apache Beam. Even when you filter, you have to make sure that its a new object being added to the output. Thus, you have to clone the object. 0af1189 is described below commit 0af118912b2d55f0b9c88fccd1eb3693133e86f1 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 14:02:47 2019 -0600 found a mutation bug in Apache Beam. Even when you filter, you have to make sure that its a new object being added to the output. Thus, you have to clone the object. --- .../apache/tinkerpop/machine/strategies/IdentityStrategy.java | 5 - .../tinkerpop/machine/traversers/CompleteTraverser.java | 10 -- .../java/org/apache/tinkerpop/machine/traversers/Path.java| 4 ++-- .../org/apache/tinkerpop/machine/traversers/Traverser.java| 11 +-- .../org/apache/tinkerpop/machine/traversers/TraverserSet.java | 2 +- .../main/java/org/apache/tinkerpop/machine/beam/FilterFn.java | 5 +++-- .../main/java/org/apache/tinkerpop/machine/beam/MapFn.java| 11 ++- .../test/java/org/apache/tinkerpop/machine/beam/BeamTest.java | 2 +- 8 files changed, 14 insertions(+), 36 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java index 9b91e2c..92ef157 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/strategies/IdentityStrategy.java @@ -28,6 +28,9 @@ public final class IdentityStrategy implements Strategy { @Override public void apply(final Bytecode bytecode) { -bytecode.getInstructions().removeIf(instruction -> instruction.op().equals(Symbols.IDENTITY)); +bytecode.getInstructions().removeIf(instruction -> +instruction.op().equals(Symbols.IDENTITY) && +instruction.labels().isEmpty()); +//!instruction.coefficient().equals(unity)); } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java index b6c471e..b605da2 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverser.java @@ -22,8 +22,6 @@ import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.functions.ReduceFunction; -import java.util.Collections; - /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ @@ -33,10 +31,6 @@ public class CompleteTraverser implements Traverser { private S object; private Path path = new Path(); -public CompleteTraverser() { - -} - public CompleteTraverser(final Coefficient coefficient, final S object) { this.coefficient = coefficient; this.object = object; @@ -54,10 +48,6 @@ public class CompleteTraverser implements Traverser { return this.path; } -public void addLabel(final String label) { -this.path.addLabels(Collections.singleton(label)); -} - @Override public Traverser split(final CFunction function, final E eObject) { final CompleteTraverser clone = new CompleteTraverser<>( diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java index 7509824..9f5b997 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Path.java @@ -35,8 +35,8 @@ public class Path implements Serializable { } public Path(final Path path) { -path.objects.forEach(o -> objects.add(o)); -path.labels.forEach(l -> labels.add(l)); +this.objects.addAll(path.objects); +this.labels.addAll(path.labels); } public void add(final Set labels, final Object object) { diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java index 4164fe6..6484d18 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/Traverser.java @@ -28,7 +28,6 @@ import org.apache.tinkerpop.util.IteratorUtils; import java.io.Serializable; import java.util.Iterator; -import java.ut
[tinkerpop] branch tp4 updated: NestedFunctions.Branching are now split/merged PCollections in Beam. This is equivalent to GlobalChildren in TP3 where you want these individual nested traversals to be
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 The following commit(s) were added to refs/heads/tp4 by this push: new 30a1266 NestedFunctions.Branching are now split/merged PCollections in Beam. This is equivalent to GlobalChildren in TP3 where you want these individual nested traversals to be independent of one another. Starting to get the hang of the Apache Beam API. 30a1266 is described below commit 30a12669d04f2ecffca4a1b51b976eac88eca10f Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 13:38:02 2019 -0600 NestedFunctions.Branching are now split/merged PCollections in Beam. This is equivalent to GlobalChildren in TP3 where you want these individual nested traversals to be independent of one another. Starting to get the hang of the Apache Beam API. --- .../machine/functions/NestedFunction.java | 7 ++ .../machine/functions/flatMap/UnionFlatMap.java| 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 2 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 83 +- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 4 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- 6 files changed, 62 insertions(+), 38 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java index a63f226..2119f54 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/NestedFunction.java @@ -31,4 +31,11 @@ public interface NestedFunction extends CFunction { public void setProcessor(final TraverserFactory traverserFactory, final ProcessorFactory processorFactory); public List>> getFunctions(); + +public interface Branching extends NestedFunction { +} + +public interface Internal extends NestedFunction { + +} } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java index 7544580..cb5502a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/flatMap/UnionFlatMap.java @@ -39,7 +39,7 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class UnionFlatMap extends AbstractFunction> implements FlatMapFunction, NestedFunction { +public class UnionFlatMap extends AbstractFunction> implements FlatMapFunction, NestedFunction.Branching { private final List>> branchFunctions; private transient List> processors; diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java index 08d4961..63d64c0 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/map/MapMap.java @@ -36,7 +36,7 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class MapMap extends AbstractFunction implements MapFunction, NestedFunction { +public class MapMap extends AbstractFunction implements MapFunction, NestedFunction.Internal { private final List> mapFunctions; private TraverserFactory traverserFactory; 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 fa06730..6531693 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 @@ -23,8 +23,10 @@ import org.apache.beam.sdk.options.PipelineOptions; import org.apache.beam.sdk.transforms.Combine; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.Flatten; import org.apache.beam.sdk.transforms.ParDo; import org.apache.beam.sdk.values.PCollection; +import org.apache.beam.sdk.values.PCollectionList; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.coefficients.Coefficient; @@ -54,54 +56,71 @@ public class Beam implements Processor { private final Pipeline pipeline; public static List OUTPUT = new ArrayList<>(); // FIX THIS! private final List functions = new ArrayList<>(); -Iterator iterator = null; +Iterator> iterator = null; +private TraverserFactory trave
[tinkerpop] branch tp4 updated: got FlatMapFunctions working. Added __.union(). Added all the Iterator utilities from TP3.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 193f012 got FlatMapFunctions working. Added __.union(). Added all the Iterator utilities from TP3. 193f012 is described below commit 193f012802014532c18860ac4e7483ab5e54244e Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 12:54:19 2019 -0600 got FlatMapFunctions working. Added __.union(). Added all the Iterator utilities from TP3. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 12 +- .../java/org/apache/tinkerpop/language/__.java | 21 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 23 +- .../machine/functions/FlatMapFunction.java | 2 +- .../machine/functions/NestedFunction.java | 7 +- .../machine/functions/flatMap/UnionFlatMap.java| 85 .../tinkerpop/machine/functions/map/MapMap.java| 25 +- .../machine/processor/EmptyProcessorFactory.java | 7 +- .../machine/processor/ProcessorFactory.java| 14 +- .../machine/traversers/CompleteTraverser.java | 12 + .../tinkerpop/machine/traversers/Traverser.java| 8 +- .../ArrayIterator.java}| 34 +- .../org/apache/tinkerpop/util/DoubleIterator.java | 65 .../org/apache/tinkerpop/util/IteratorUtils.java | 433 + .../org/apache/tinkerpop/util/MultiIterator.java | 104 + .../SingleIterator.java} | 33 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 12 +- .../tinkerpop/machine/beam/BeamProcessor.java | 8 +- .../apache/tinkerpop/machine/beam/FlatMapFn.java} | 22 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 16 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 7 +- .../tinkerpop/machine/pipes/FlatMapStep.java} | 30 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 15 +- .../tinkerpop/machine/pipes/PipesProcessor.java| 9 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 6 +- 26 files changed, 920 insertions(+), 91 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 4f5ed5f..7964d07 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 @@ -40,4 +40,5 @@ public final class Symbols { public static final String MAP = "map"; public static final String PATH = "path"; public static final String SUM = "sum"; +public static final String UNION = "union"; } 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 e9ebb85..4eef5cd 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 @@ -22,6 +22,7 @@ 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.EmptyProcessorFactory; import org.apache.tinkerpop.machine.processor.Processor; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; @@ -47,7 +48,7 @@ public class Traversal implements Iterator { public Traversal(final Bytecode bytecode) { this.bytecode = bytecode; this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); -this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(null); +this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(EmptyProcessorFactory.instance()); } public Traversal as(final String label) { @@ -105,6 +106,15 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal union(final Traversal... traversals) { +final Bytecode[] bytecodes = new Bytecode[traversals.length]; +for (int i = 0; i < traversals.length; i++) { +bytecodes[i] = traversals[i].bytecode; +} +this.bytecode.addInstruction(this.currentCoefficient, Symbols.UNION, bytecodes); +return (Traversal) this; +} + /// 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 80bb253..4c2b4ba 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/lan
[tinkerpop] 06/19: reorganized tp4 based on languages and removed all the gremlin- naming.
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 2493711487946a4d9750ba2ed1b2b4af52b22acf Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 07:59:18 2019 -0700 reorganized tp4 based on languages and removed all the gremlin- naming. --- .../apache/tinkerpop/machines/pipes/PipeTest.java | 25 -- {gremlin-core => java/core}/pom.xml| 6 +++--- .../apache/tinkerpop}/language/GremlinCore.java| 2 +- .../org/apache/tinkerpop}/machine/Bytecode.java| 2 +- .../org/apache/tinkerpop}/machine/Instruction.java | 2 +- .../org/apache/tinkerpop}/machine/Traversal.java | 2 +- .../org/apache/tinkerpop}/machine/Traverser.java | 2 +- .../machine/coefficients/Coefficients.java | 2 +- .../machine/coefficients/LongCoefficients.java | 2 +- .../tinkerpop}/machine/functions/GFunction.java| 6 +++--- .../tinkerpop}/machine/functions/MapFunction.java | 6 +++--- .../machine/traversers/TraverserSet.java | 7 +++--- .../machine/util/FastNoSuchElementException.java | 2 +- .../apache/tinkerpop}/machine/TraversalTest.java | 2 +- .../gremlin-pipes => java/machine/pipes}/pom.xml | 8 +++ .../org/apache/tinkerpop/machine}/pipes/Pipe.java | 4 ++-- .../org/apache/tinkerpop/machine}/pipes/Step.java | 8 +++ {gremlin-machines => java/machine}/pom.xml | 8 +++ {gremlin-machines => java}/pom.xml | 11 +- pom.xml| 9 20 files changed, 46 insertions(+), 70 deletions(-) diff --git a/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java b/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java deleted file mode 100644 index 243e301..000 --- a/gremlin-machines/gremlin-pipes/src/test/java/org/apache/tinkerpop/machines/pipes/PipeTest.java +++ /dev/null @@ -1,25 +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.machines.pipes; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public class PipeTest { -} diff --git a/gremlin-core/pom.xml b/java/core/pom.xml similarity index 92% rename from gremlin-core/pom.xml rename to java/core/pom.xml index c921791..5e3a2d3 100644 --- a/gremlin-core/pom.xml +++ b/java/core/pom.xml @@ -17,12 +17,12 @@ limitations under the License. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> 4.0.0 -tinkerpop +java org.apache.tinkerpop 4.0.0-SNAPSHOT -Apache TinkerPop :: Gremlin Core -gremlin-core +Apache TinkerPop (Java) :: Core +core ${basedir}/target ${project.artifactId}-${project.version} diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java similarity index 95% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java rename to java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java index f876aaa..59c4f69 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.language; +package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Bytecode.java b/java/core/src/main/java/org/apache/tinkerpop/machine/Bytecode.java similarity index 96% rename from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Bytecode.java rename to java/core/src/main/java/org/apache/tinkerpop/machine/Bytecode.java index 5334fd0..2778366 100644 --- a/gremlin-core/src/main/j
[tinkerpop] branch tp4 updated (d602c07 -> 3e72077)
This is an automated email from the ASF dual-hosted git repository. okram pushed a change to branch tp4 in repository https://gitbox.apache.org/repos/asf/tinkerpop.git. from d602c07 minor changes. taking a break. new 4ee2c36 have ReducerFn working in Apache Beam. Now we have count(). This means that both Pipes and Beam machines are at the same level of completition. new c26b7e8 Strategy interface created and IdentityStrategy instance created. Bytecode sourceInstructions was stubbed along with the strategy application code. new 3e72077 got SumReduce working easily. Lots of Traverser tweaks. Added @dkuppitz NumberHelper class from TP3. The 19 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../org/apache/tinkerpop/language/Symbols.java | 5 +- .../org/apache/tinkerpop/language/Traversal.java | 20 +- .../apache/tinkerpop/language/TraversalSource.java | 37 +- .../java/org/apache/tinkerpop/language/__.java | 5 +- .../tinkerpop/machine/bytecode/Bytecode.java | 23 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 71 +++- .../machine/bytecode/SourceInstruction.java| 7 + .../machine/coefficients/LongCoefficient.java | 3 +- .../machine/functions/ReduceFunction.java | 2 + .../machine/functions/reduce/CountReduce.java | 5 + .../reduce/{CountReduce.java => SumReduce.java}| 18 +- .../strategies/IdentityStrategy.java} | 15 +- .../machine/{compiler => strategies}/Strategy.java | 4 +- .../machine/traversers/CompleteTraverser.java | 13 +- .../traversers/CompleteTraverserFactory.java | 5 +- .../tinkerpop/machine/traversers/Traverser.java| 17 +- .../machine/traversers/TraverserFactory.java | 7 +- .../org/apache/tinkerpop/util/NumberHelper.java| 445 + .../org/apache/tinkerpop/util/StringFactory.java | 15 + .../apache/tinkerpop/machine/TraversalTest.java| 3 +- .../machine/compiler/BytecodeUtilTest.java | 6 +- java/machine/beam/pom.xml | 2 +- .../apache/tinkerpop/machine/beam/AbstractFn.java | 4 +- .../tinkerpop/machine/beam/BasicAccumulator.java} | 51 +-- .../org/apache/tinkerpop/machine/beam/Beam.java| 31 +- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 2 + .../apache/tinkerpop/machine/beam/InitialFn.java | 9 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 4 +- .../apache/tinkerpop/machine/beam/ReduceFn.java| 67 +++- .../{TraverserCoder.java => ReducerCoder.java} | 9 +- .../apache/tinkerpop/machine/beam/BeamTest.java| 9 +- java/machine/pipes/pom.xml | 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 4 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 6 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 12 +- .../machine/pipes/util}/BasicReducer.java | 2 +- .../tinkerpop/machine/pipes/util}/Reducer.java | 6 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 12 +- 38 files changed, 781 insertions(+), 177 deletions(-) copy java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/{CountReduce.java => SumReduce.java} (66%) copy java/core/src/main/java/org/apache/tinkerpop/{language/TraversalUtil.java => machine/strategies/IdentityStrategy.java} (74%) rename java/core/src/main/java/org/apache/tinkerpop/machine/{compiler => strategies}/Strategy.java (90%) create mode 100644 java/core/src/main/java/org/apache/tinkerpop/util/NumberHelper.java copy java/machine/{pipes/src/main/java/org/apache/tinkerpop/machine/pipes/ReduceStep.java => beam/src/main/java/org/apache/tinkerpop/machine/beam/BasicAccumulator.java} (51%) copy java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/{TraverserCoder.java => ReducerCoder.java} (81%) rename java/{core/src/main/java/org/apache/tinkerpop/machine/functions/reduce => machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/util}/BasicReducer.java (95%) rename java/{core/src/main/java/org/apache/tinkerpop/machine/functions/reduce => machine/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/util}/Reducer.java (87%)
[tinkerpop] 13/19: Coefficients are now wrapped in Coefficient objects and passed around through functions and traversers. This was the only way to make it clean. Added StringFactory which gives By
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 d56b089fc2b7bdaa2d535858647c731e765cb694 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 14:33:33 2019 -0700 Coefficients are now wrapped in Coefficient objects and passed around through functions and traversers. This was the only way to make it clean. Added StringFactory which gives Bytecode and Traversals standard toString() representations. Stubbed the strategy/ package and interface. Processors now implement Iterator. This makes sense as its up to the Traversal to get traversers from the processor and stream them out (unpack them) to the user. The processor is now completel [...] --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 36 +++- .../apache/tinkerpop/language/TraversalSource.java | 24 -- .../java/org/apache/tinkerpop/language/__.java | 4 +- .../tinkerpop/machine/bytecode/Bytecode.java | 7 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 +- .../tinkerpop/machine/bytecode/Instruction.java| 10 ++- .../{Coefficients.java => Coefficient.java}| 19 +++-- .../machine/coefficients/LongCoefficient.java | 98 ++ .../machine/coefficients/LongCoefficients.java | 56 - .../Coefficients.java => compiler/Strategy.java} | 17 ++-- .../machine/functions/AbstractFunction.java| 13 +-- .../tinkerpop/machine/functions/CFunction.java | 4 +- .../machine/functions/filter/IdentityFilter.java | 4 +- .../machine/functions/filter/IsFilter.java | 7 +- .../machine/functions/initial/InjectInitial.java | 9 +- .../tinkerpop/machine/functions/map/IncrMap.java | 5 +- .../tinkerpop/machine/functions/map/MapMap.java| 12 +-- .../tinkerpop/machine/functions/map/PathMap.java | 5 +- .../machine/processor/EmptyProcessor.java | 6 +- .../tinkerpop/machine/processor/Processor.java | 8 +- .../tinkerpop/machine/traversers/Traverser.java| 12 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 13 ++- .../util/FastNoSuchElementException.java | 2 +- .../org/apache/tinkerpop/util/StringFactory.java | 68 +++ .../apache/tinkerpop/machine/TraversalTest.java| 4 +- .../machine/compiler/BytecodeUtilTest.java | 4 +- .../tinkerpop/machine/pipes/AbstractStep.java | 12 +-- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 9 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 36 ++-- .../org/apache/tinkerpop/machine/pipes/Step.java | 4 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 11 ++- 33 files changed, 348 insertions(+), 177 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 387a209..681e26e 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,6 +24,7 @@ package org.apache.tinkerpop.language; public final class Symbols { public static final String AS = "as"; +public static final String C = "c"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 4021d08..7acdd75 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,9 +19,11 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.coefficients.Coefficient; import org.apache.tinkerpop.machine.processor.Processor; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; +import org.apache.tinkerpop.machine.traversers.Traverser; import java.util.ArrayList; import java.util.Iterator; @@ -33,11 +35,13 @@ import java.util.List; public class Traversal implements Iterator { protected final Bytecode bytecode; -private C currentCoefficient; +private Coefficient currentCoefficient; private final ProcessorFactory factory; private Processor processor; +private long lastCount = 0L; +private E lastObject = null; -public Traversal(final C unity, final ProcessorFactory factory) { +public Traversal(final Coefficient unity, final ProcessorFactory factory) { this.currentCoefficient = unity; this.bytecode = new Byteco
[tinkerpop] 16/19: minor changes. taking a break.
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 d602c0706e0e430eacfc4761d61d6b2ddf7e2340 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:49:22 2019 -0600 minor changes. taking a break. --- .../java/org/apache/tinkerpop/language/Symbols.java | 5 + .../java/org/apache/tinkerpop/machine/beam/Beam.java | 19 ++- 2 files changed, 15 insertions(+), 9 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 b302b88..9ea778d 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 @@ -23,6 +23,11 @@ package org.apache.tinkerpop.language; */ public final class Symbols { +// SOURCE OPS +public static final String COEFFICIENT = "coefficient"; + + +// INSTRUCTION OPS public static final String AS = "as"; public static final String C = "c"; public static final String COUNT = "count"; 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 b93174e..f2813b4 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 @@ -19,6 +19,7 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.options.PipelineOptions; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.DoFn; import org.apache.beam.sdk.transforms.ParDo; @@ -44,17 +45,16 @@ import java.util.List; */ public class Beam implements Processor { -final Pipeline pipeline; -PCollection collection; -public static List OUTPUT = new ArrayList<>(); -Iterator iterator = null; +private final Pipeline pipeline; +public static List OUTPUT = new ArrayList<>(); // FIX THIS! private final List functions = new ArrayList<>(); +Iterator iterator = null; public Beam(final List> functions) { this.pipeline = Pipeline.create(); this.pipeline.getCoderRegistry().registerCoderForClass(Traverser.class, new TraverserCoder<>()); -this.collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); -this.collection.setCoder(new TraverserCoder()); +PCollection collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); +collection.setCoder(new TraverserCoder()); DoFn fn = null; for (final CFunction function : functions) { @@ -69,10 +69,11 @@ public class Beam implements Processor { } else throw new RuntimeException("You need a new step type:" + function); this.functions.add(fn); -this.collection = (PCollection) collection.apply(ParDo.of(fn)); -this.collection.setCoder(new TraverserCoder()); +collection = (PCollection) collection.apply(ParDo.of(fn)); +collection.setCoder(new TraverserCoder()); } collection = (PCollection) collection.apply(ParDo.of(new OutputStep())); +this.pipeline.getOptions().setRunner(new PipelineOptions.DirectRunner().create(this.pipeline.getOptions())); } public Beam(final Bytecode bytecode) { @@ -108,7 +109,7 @@ public class Beam implements Processor { private final void setupPipeline() { if (null == this.iterator) { -pipeline.run().waitUntilFinish(); +this.pipeline.run().waitUntilFinish(); this.iterator = new ArrayList<>(OUTPUT).iterator(); OUTPUT.clear(); }
[tinkerpop] 09/19: got TraversalSource, Traversal, and a basic implementation of Pipes/Steps working. Bytecode compilation no longer requires Java reflection -- big ass switch statement.
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 a472603dcaa9a50e6cd77d4bbd5049b56ccc22c3 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 05:34:22 2019 -0700 got TraversalSource, Traversal, and a basic implementation of Pipes/Steps working. Bytecode compilation no longer requires Java reflection -- big ass switch statement. --- .../language/{GremlinCore.java => Gremlin.java}| 6 +-- .../tinkerpop/{machine => language}/Traversal.java | 19 ++-- .../{GremlinCore.java => TraversalSource.java} | 20 ++-- .../tinkerpop/machine/{ => bytecode}/Bytecode.java | 7 ++- .../machine/{ => bytecode}/Instruction.java| 15 -- .../machine/coefficients/LongCoefficients.java | 6 +++ .../machine/compiler/BytecodeToFunction.java | 57 ++ .../compiler/Symbols.java} | 10 ++-- .../{GFunction.java => FilterFunction.java}| 7 ++- .../machine/functions/FlatMapFunction.java}| 26 ++ .../tinkerpop/machine/functions/GFunction.java | 22 ++--- .../functions/{GFunction.java => IncrMap.java} | 16 -- .../{GFunction.java => InitialFunction.java} | 8 +-- .../machine/functions/InjectInitial.java} | 24 + .../functions/{GFunction.java => IsFilter.java}| 24 +++-- .../tinkerpop/machine/functions/MapFunction.java | 19 +--- .../machine/{ => traversers}/Traverser.java| 6 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 1 - .../apache/tinkerpop/machine/TraversalTest.java| 17 --- .../BytecodeToFunctionTest.java} | 16 +++--- .../machine/pipes/{Pipe.java => Pipes.java}| 30 +--- .../org/apache/tinkerpop/machine/pipes/Step.java | 46 - .../apache/tinkerpop/machine/pipes/PipesTest.java} | 21 +--- 23 files changed, 287 insertions(+), 136 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java similarity index 88% copy from java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java copy to java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java index 59c4f69..2f29245 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Gremlin.java @@ -21,9 +21,9 @@ package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface GremlinCore { +public final class Gremlin { -public default GremlinCore select() { -return null; +public static TraversalSource traversal() { +return new TraversalSource<>(); } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java similarity index 66% rename from java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java rename to java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java index 964143f..86d307a 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/Traversal.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Traversal.java @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.machine; +package org.apache.tinkerpop.language; -import java.util.function.Function; +import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.compiler.Symbols; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -33,8 +34,18 @@ public class Traversal { this.bytecode = new Bytecode<>(); } -public Traversal map(final Function mapFunction) { -this.bytecode.addInstruction(this.currentCoefficient, "map", mapFunction); +public Traversal is(final B object) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); +return this; +} + +public Traversal incr() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.INCR); +return (Traversal) this; +} + +public Traversal inject(final D... objects) { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.INJECT, objects); return (Traversal) this; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java b/java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java similarity index 59% copy from java/core/src/main/java/org/apache/tinkerpop/language/GremlinCore.java copy to java/core/src/main/java/org/apache/tinkerpop/language/TraversalSource.java index 59c4f69..01c145a 100644 --- a/java/core/src/m
[tinkerpop] 17/19: have ReducerFn working in Apache Beam. Now we have count(). This means that both Pipes and Beam machines are at the same level of completition.
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 4ee2c36b57d1f1fdb888d6c32ffdf5c3fedb4ac1 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 09:15:37 2019 -0600 have ReducerFn working in Apache Beam. Now we have count(). This means that both Pipes and Beam machines are at the same level of completition. --- .../tinkerpop/machine/bytecode/Bytecode.java | 6 +- .../machine/functions/ReduceFunction.java | 2 + .../machine/functions/reduce/CountReduce.java | 5 ++ .../machine/functions/reduce/Reducer.java | 4 +- .../traversers/CompleteTraverserFactory.java | 5 +- .../machine/traversers/TraverserFactory.java | 6 +- .../tinkerpop/machine/beam/BasicAccumulator.java} | 51 .../org/apache/tinkerpop/machine/beam/Beam.java| 20 +-- .../java/org/apache/tinkerpop/machine/beam/Fn.java | 2 + .../apache/tinkerpop/machine/beam/ReduceFn.java| 68 +++--- .../tinkerpop/machine/beam/ReducerCoder.java | 62 .../apache/tinkerpop/machine/beam/BeamTest.java| 2 +- .../tinkerpop/machine/pipes/InitialStep.java | 4 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 4 +- 15 files changed, 191 insertions(+), 52 deletions(-) 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 3310070..74d4d3e 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 @@ -31,8 +31,8 @@ import java.util.List; */ public class Bytecode implements Cloneable { -public List strategies = new ArrayList<>(); -public List> instructions = new ArrayList<>(); +private List strategies = new ArrayList<>(); +private List> instructions = new ArrayList<>(); public void addStrategy(final Strategy strategy) { @@ -63,7 +63,7 @@ public class Bytecode implements Cloneable { } // this should be part of processor! -public TraverserFactory getTraverserFactory() { +public TraverserFactory getTraverserFactory() { return new CompleteTraverserFactory<>(); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java index c2ceb0d..eac368d 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/ReduceFunction.java @@ -28,5 +28,7 @@ import java.util.function.BiFunction; public interface ReduceFunction extends BiFunction, E, E>, CFunction { public E getInitialValue(); + +public E merge(final E valueA, final E valueB); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java index 8c674c3..65dde8e 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/CountReduce.java @@ -40,6 +40,11 @@ public class CountReduce extends AbstractFunction implements R } @Override +public Long merge(final Long valueA, final Long valueB) { +return valueA + valueB; +} + +@Override public Long getInitialValue() { return 0L; } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java index 8434ca7..8103459 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/reduce/Reducer.java @@ -18,10 +18,12 @@ */ package org.apache.tinkerpop.machine.functions.reduce; +import java.io.Serializable; + /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public interface Reducer { +public interface Reducer extends Serializable { public S get(); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java index 7d9356f..59ed747 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/CompleteTraverserFactory.java @@ -23,9 +23,10 @@ import org.apache.tinkerpop.machine.coefficie
[tinkerpop] 11/19: awesome push. we have nested traversals working, we have a micro-stub of Bytecode optimization (basically, just removes identity instructions for now), we have a Processor API which
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 5f24a29461ba4368102ac1c14d79bf27728c0998 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 09:33:10 2019 -0700 awesome push. we have nested traversals working, we have a micro-stub of Bytecode optimization (basically, just removes identity instructions for now), we have a Processor API which is THE CONCEPT. A nested function requires a Processor in order to execute its nested functions. Pipes implements Processor. However, you can imagine having Akka going and if the nested functions are simple, just use Pipes as the processor for that. Thus, you can mix and match processors at the nesting lev [...] --- .../org/apache/tinkerpop/language/Symbols.java | 2 + .../org/apache/tinkerpop/language/Traversal.java | 33 +++--- .../tinkerpop/language/{Symbols.java => __.java} | 10 ++- .../Symbols.java => machine/Processor.java}| 18 -- .../tinkerpop/machine/bytecode/Bytecode.java | 4 ++ .../BytecodeUtil.java} | 32 +++--- .../tinkerpop/machine/bytecode/Instruction.java| 9 ++- .../machine/functions/AbstractFunction.java| 2 +- .../functions/NestedFunction.java} | 16 +++-- .../{PathMap.java => filter/IdentityFilter.java} | 13 ++-- .../machine/functions/{ => filter}/IsFilter.java | 4 +- .../functions/{ => initial}/InjectInitial.java | 4 +- .../machine/functions/{ => map}/IncrMap.java | 4 +- .../tinkerpop/machine/functions/map/MapMap.java| 63 ++ .../machine/functions/{ => map}/PathMap.java | 4 +- .../tinkerpop/machine/traversers/TraverserSet.java | 4 +- .../apache/tinkerpop/machine/TraversalTest.java| 7 +- ...deToFunctionTest.java => BytecodeUtilTest.java} | 5 +- .../tinkerpop/machine/pipes/AbstractStep.java | 69 .../apache/tinkerpop/machine/pipes/EmptyStep.java} | 27 +--- .../tinkerpop/machine/pipes/FilterStep.java} | 21 +++--- .../tinkerpop/machine/pipes/InitialStep.java} | 24 +++ .../apache/tinkerpop/machine/pipes/MapStep.java} | 15 ++--- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 73 ++--- .../org/apache/tinkerpop/machine/pipes/Step.java | 74 -- .../apache/tinkerpop/machine/pipes/PipesTest.java | 15 +++-- 26 files changed, 368 insertions(+), 184 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 fdaf642..387a209 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,8 +24,10 @@ package org.apache.tinkerpop.language; public final class Symbols { public static final String AS = "as"; +public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String MAP = "map"; public static final String PATH = "path"; } 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 f363342f..06b93bf 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,13 +19,12 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; - -import java.util.Map; +import org.apache.tinkerpop.machine.traversers.Path; /** - * @author Marko A. Rodriguez (http://markorodriguez.com) + * @author Marko S. Rodriguez (http://markorodriguez.com) */ -public class Traversal { +public class Traversal { private final Bytecode bytecode; private C currentCoefficient; @@ -35,32 +34,48 @@ public class Traversal { this.bytecode = new Bytecode<>(); } -public Traversal as(final String label) { +public Traversal as(final String label) { this.bytecode.lastInstruction().addLabel(label); return this; } -public Traversal is(final B object) { +public Traversal by(final Traversal byTraversal) { +this.bytecode.lastInstruction().addArg(byTraversal); +return this; +} + +public Traversal identity() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.IDENTITY); +return this; +} + +public Traversal is(final E object) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); return this; } -public Traversal incr() { +p
[tinkerpop] 03/19: starting to spec out the gremlin-machines submodule which includes gremlin-pipes which is what we currently think of Traversal as. gremlin-pipes will be a local traversal engine.
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 c6033cbb9aee0f91f7de0878c0ef40d72c98eb4e Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 10:56:06 2019 -0700 starting to spec out the gremlin-machines submodule which includes gremlin-pipes which is what we currently think of Traversal as. gremlin-pipes will be a local traversal engine. --- gremlin-core/pom.xml | 2 +- .../tinkerpop/gremlin/machine/Instruction.java | 2 +- .../tinkerpop/gremlin/machine/Traverser.java | 5 + .../{Traverser.java => functions/GFunction.java} | 29 +--- .../gremlin/machine/functions/MapFunction.java | 2 +- .../gremlin/machine/traversers/TraverserSet.java | 160 + .../FastNoSuchElementException.java} | 32 ++--- .../gremlin-pipes}/pom.xml | 15 +- .../org/apache/tinkerpop/machines/pipes/Pipe.java | 29 ++-- .../org/apache/tinkerpop/machines/pipes/Step.java | 35 +++-- .../apache/tinkerpop/machines/pipes/PipeTest.java | 24 +--- {gremlin-core => gremlin-machines}/pom.xml | 30 +--- pom.xml| 3 +- 13 files changed, 247 insertions(+), 121 deletions(-) diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml index b92f8fd..c921791 100644 --- a/gremlin-core/pom.xml +++ b/gremlin-core/pom.xml @@ -19,7 +19,7 @@ limitations under the License. tinkerpop org.apache.tinkerpop -4.0-SNAPSHOT +4.0.0-SNAPSHOT Apache TinkerPop :: Gremlin Core gremlin-core diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java index dfc9d0a..b46462e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Instruction.java @@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.machine; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Instruction { +public final class Instruction { private final C coefficient; private final String op; diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java index 6c0712c..d0c321f 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java @@ -42,4 +42,9 @@ public class Traverser { public Traverser split(final C coefficient, final B object) { return new Traverser<>(coefficient, object); } + +@Override +public boolean equals(final Object other) { +return other instanceof Traverser && ((Traverser) other).object.equals(this.object); +} } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java similarity index 61% copy from gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java copy to gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java index 6c0712c..48a3b7c 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/Traverser.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/GFunction.java @@ -16,30 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.gremlin.machine; +package org.apache.tinkerpop.gremlin.machine.functions; + +import org.apache.tinkerpop.gremlin.machine.Traverser; + +import java.util.Iterator; +import java.util.function.Function; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Traverser { - -private final C coefficient; -private final A object; - -public Traverser(final C coefficient, final A object) { -this.coefficient = coefficient; -this.object = object; -} - -public C getCoefficient() { -return this.coefficient; -} - -public A getObject() { -return this.object; -} - -public Traverser split(final C coefficient, final B object) { -return new Traverser<>(coefficient, object); -} +public interface GFunction extends Function, Traverser> { } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/MapFunction.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/functions/MapFunction.java index 35d5b12..4491414 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/machine/func
[tinkerpop] 07/19: removed the pom.xml from the root tinkerpop directory. the parent pom is now in java/. Added a stub of documentation.
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 69551513260705860cebe05101ce0357a33d15b2 Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 08:18:58 2019 -0700 removed the pom.xml from the root tinkerpop directory. the parent pom is now in java/. Added a stub of documentation. --- docs/README.asciidoc | 1 + java/pom.xml | 203 +-- pom.xml | 217 --- 3 files changed, 196 insertions(+), 225 deletions(-) diff --git a/docs/README.asciidoc b/docs/README.asciidoc new file mode 100644 index 000..c0f7435 --- /dev/null +++ b/docs/README.asciidoc @@ -0,0 +1 @@ +This is a stub of documentation. \ No newline at end of file diff --git a/java/pom.xml b/java/pom.xml index f8f31ab..6ee5dd1 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -14,18 +14,205 @@ limitations under the License. --> http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd;> 4.0.0 + +org.apache +apache +21 + +org.apache.tinkerpop +tinkerpop +4.0.0-SNAPSHOT pom +Apache TinkerPop +A Virtual Machine and Language +http://tinkerpop.apache.org/ + + +Users +http://groups.google.com/group/gremlin-users + http://groups.google.com/group/gremlin-users + http://groups.google.com/group/gremlin-users/topics + + +Developers +dev-subscr...@tinkerpop.apache.org +dev-unsubscr...@tinkerpop.apache.org +dev-digest-subscr...@tinkerpop.apache.org + + +2019 + + +Apache 2 +http://www.opensource.org/licenses/Apache-2.0 + + + +Apache Software Foundation +http://www.apache.org/ + + + +Marko A. Rodriguez +ok...@apache.org +http://markorodriguez.com + + + +3.2.5 + core machine - -tinkerpop -org.apache.tinkerpop -4.0.0-SNAPSHOT - -Apache TinkerPop :: Java -java + +scm:git:g...@github.com:apache/tinkerpop.git + scm:git:g...@github.com:apache/tinkerpop.git +https://github.com/apache/tinkerpop + + +5.4.0 + + + + +org.junit.jupiter +junit-jupiter-api +${junit.version} +test + + +org.junit.jupiter +junit-jupiter-engine +${junit.version} +test + + + +${basedir}/target + + +org.apache.maven.plugins +maven-compiler-plugin + + +maven-enforcer-plugin +1.4.1 + + +enforce-all + +enforce + + + + + +[11.0,) + + +[3.2.5,) + + + + + + + +org.apache.rat +apache-rat-plugin +0.12 + + +rat-checks +validate + +check + + + + +false + +fileTemplates/ +**/*.iml +**/target/** + + + + + + + + + + +org.apache.maven.plugins +maven-compiler-plugin +3.8.0 + +11 +11 + +-parameters + + + + +org.apache.maven.plugins +
[tinkerpop] 02/19: first organizational push on tp4. basic structure, pom.xmls up and running, and some basic code for play.
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 08be42f34b3e5068a08363e18a78e90aff3288e2 Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 08:37:10 2019 -0700 first organizational push on tp4. basic structure, pom.xmls up and running, and some basic code for play. --- .gitignore | 5 + README.asciidoc| 21 ++ gremlin-core/pom.xml | 46 + .../tinkerpop/gremlin/language/GremlinCore.java| 29 +++ .../apache/tinkerpop/gremlin/machine/Bytecode.java | 42 .../tinkerpop/gremlin/machine/Instruction.java | 47 + .../tinkerpop/gremlin/machine/Traversal.java | 45 + .../tinkerpop/gremlin/machine/Traverser.java | 45 + .../gremlin/machine/coefficients/Coefficients.java | 36 .../machine/coefficients/LongCoefficients.java | 50 + .../gremlin/machine/functions/MapFunction.java | 45 + .../tinkerpop/gremlin/machine/TraversalTest.java | 36 pom.xml| 217 + 13 files changed, 664 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 000..ad8c63c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.iml +*.ipr +*.iws +target/ +fileTemplates/ diff --git a/README.asciidoc b/README.asciidoc index 1eaec1a..aba1b44 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -15,3 +15,24 @@ See the License for the specific language governing permissions and limitations under the License. == TinkerPop4 + +* gremlin-core: A collection of Gremlin machine and language components +* gremlin-data +** gremlin-graphs +*** gremlin-neo4j: A Neo4j implementation of the Gremlin graph primitives +*** gremlin-tinkergraph: A TinkerGraph implementation of the Gremlin graph primitives +* gremlin-machines +** gremlin-beam: Apache Beam implementation of the Gremlin traversal machine +** gremlin-akka: Akka implementation of the Gremlin traversal machine +** gremlin-pipes: Java iterator implementation of the Gremlin traversal machine +* gremlin-languages +** gremlin-variants +*** gremlin-groovy: Groovy implementation of the Gremlin traversal language +*** gremlin-python: Python implementation of the Gremlin traversal language +*** gremlin-javascript: JavaScript implementation of the Gremlin traversal language +*** gremlin-dotnet: C# implementation of the Gremlin traversal language +** gremlin-uniques +*** gremlin-sparql: A SPARQL to Gremlin bytecode compiler +*** gremlin-sql: An SQL to Gremlin bytecode compiler +*** gremlin-cypher: A Cypher to Gremlin bytecode compiler +* gremlin-test: language test suite \ No newline at end of file diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml new file mode 100644 index 000..b92f8fd --- /dev/null +++ b/gremlin-core/pom.xml @@ -0,0 +1,46 @@ + +http://maven.apache.org/POM/4.0.0; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> +4.0.0 + +tinkerpop +org.apache.tinkerpop +4.0-SNAPSHOT + +Apache TinkerPop :: Gremlin Core +gremlin-core + +${basedir}/target +${project.artifactId}-${project.version} + + +${basedir}/src/test/resources + + + + + +org.apache.maven.plugins +maven-surefire-plugin + + +org.apache.maven.plugins +maven-failsafe-plugin + + + + \ No newline at end of file diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java new file mode 100644 index 000..f876aaa --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/GremlinCore.java @@ -0,0 +1,29 @@ +/* + * 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 perm
[tinkerpop] 18/19: Strategy interface created and IdentityStrategy instance created. Bytecode sourceInstructions was stubbed along with the strategy application code.
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 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 implements Iterator { protected final Bytecode bytecode; private Coefficient currentCoefficient; -private final ProcessorFactory factory; +private final ProcessorFactory processorFactory; private Processor processor; +// private long lastCount = 0L; private E lastObject = null; -public Traversal(final Coefficient unity, final ProcessorFactory factory) { -this.currentCoefficient = unity; -this.bytecode = new Bytecode<>(); -this.factory = factory; +public Traversal(final Bytecode bytecode) { +this.bytecode = bytecode; +this.currentCoefficient = BytecodeUtil.getCoefficient(this.bytecode).orElse((Coefficient) LongCoefficient.create()); +this.processorFactory = BytecodeUtil.getProcessorFactory(this.bytecode).orElse(null); } public Traversal as(final String label) { @@ -102,7 +105,7 @@ public class Traversal implements Iterator { 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; impo
[tinkerpop] 04/19: small tweaks to README.
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 0726e2d7190e8d3a35b691eba426995528ae8c55 Author: Marko A. Rodriguez AuthorDate: Sun Mar 3 11:08:32 2019 -0700 small tweaks to README. --- README.asciidoc | 41 + 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index aba1b44..e791fb1 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -16,23 +16,24 @@ limitations under the License. == TinkerPop4 -* gremlin-core: A collection of Gremlin machine and language components -* gremlin-data -** gremlin-graphs -*** gremlin-neo4j: A Neo4j implementation of the Gremlin graph primitives -*** gremlin-tinkergraph: A TinkerGraph implementation of the Gremlin graph primitives -* gremlin-machines -** gremlin-beam: Apache Beam implementation of the Gremlin traversal machine -** gremlin-akka: Akka implementation of the Gremlin traversal machine -** gremlin-pipes: Java iterator implementation of the Gremlin traversal machine -* gremlin-languages -** gremlin-variants -*** gremlin-groovy: Groovy implementation of the Gremlin traversal language -*** gremlin-python: Python implementation of the Gremlin traversal language -*** gremlin-javascript: JavaScript implementation of the Gremlin traversal language -*** gremlin-dotnet: C# implementation of the Gremlin traversal language -** gremlin-uniques -*** gremlin-sparql: A SPARQL to Gremlin bytecode compiler -*** gremlin-sql: An SQL to Gremlin bytecode compiler -*** gremlin-cypher: A Cypher to Gremlin bytecode compiler -* gremlin-test: language test suite \ No newline at end of file +* *gremlin-core*: A collection of Gremlin machine and language components +* *gremlin-data* +** *gremlin-graph*: Operators for processing property graph data. +*** *gremlin-neo4j*: A Neo4j implementation of the Gremlin graph primitives +*** *gremlin-tinkergraph*: A TinkerGraph implementation of the Gremlin graph primitives +* *gremlin-machines* +** *gremlin-pipes*: Java iterator implementation of the Gremlin traversal machine +** *gremlin-rxjava*: RxJava implementation of the Gremlin traversal machine +** *gremlin-beam*: Apache Beam implementation of the Gremlin traversal machine +** *gremlin-akka*: Akka implementation of the Gremlin traversal machine +* *gremlin-languages* +** *gremlin-variants* +*** *gremlin-groovy*: Groovy implementation of the Gremlin traversal language +*** *gremlin-python*: Python implementation of the Gremlin traversal language +*** *gremlin-javascript*: JavaScript implementation of the Gremlin traversal language +*** *gremlin-dotnet*: C# implementation of the Gremlin traversal language +** *gremlin-uniques* +*** *gremlin-sparql*: A SPARQL to Gremlin bytecode compiler +*** *gremlin-sql*: An SQL to Gremlin bytecode compiler +*** *gremlin-cypher*: A Cypher to Gremlin bytecode compiler +* *gremlin-test*: language test suite \ No newline at end of file
[tinkerpop] 08/19: updated README.
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 d8e5b4030b815782684cefd9589e6b076684 Author: Marko A. Rodriguez AuthorDate: Tue Mar 5 08:22:49 2019 -0700 updated README. --- README.asciidoc | 44 +++- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index e791fb1..363b7c7 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -16,24 +16,26 @@ limitations under the License. == TinkerPop4 -* *gremlin-core*: A collection of Gremlin machine and language components -* *gremlin-data* -** *gremlin-graph*: Operators for processing property graph data. -*** *gremlin-neo4j*: A Neo4j implementation of the Gremlin graph primitives -*** *gremlin-tinkergraph*: A TinkerGraph implementation of the Gremlin graph primitives -* *gremlin-machines* -** *gremlin-pipes*: Java iterator implementation of the Gremlin traversal machine -** *gremlin-rxjava*: RxJava implementation of the Gremlin traversal machine -** *gremlin-beam*: Apache Beam implementation of the Gremlin traversal machine -** *gremlin-akka*: Akka implementation of the Gremlin traversal machine -* *gremlin-languages* -** *gremlin-variants* -*** *gremlin-groovy*: Groovy implementation of the Gremlin traversal language -*** *gremlin-python*: Python implementation of the Gremlin traversal language -*** *gremlin-javascript*: JavaScript implementation of the Gremlin traversal language -*** *gremlin-dotnet*: C# implementation of the Gremlin traversal language -** *gremlin-uniques* -*** *gremlin-sparql*: A SPARQL to Gremlin bytecode compiler -*** *gremlin-sql*: An SQL to Gremlin bytecode compiler -*** *gremlin-cypher*: A Cypher to Gremlin bytecode compiler -* *gremlin-test*: language test suite \ No newline at end of file +* *java*: Apache TinkerPop for Java +** *core*: A collection of machine and language components +** *data* +*** *graph*: Operators for processing property graph data. + *neo4j*: A Neo4j implementation of the graph primitives + *tinkergraph*: A TinkerGraph implementation of the graph primitives +** *machine* +*** *pipes*: Java iterator implementation of the traversal machine +*** *rxjava*: RxJava implementation of the traversal machine +*** *beam*: Apache Beam implementation of the traversal machine +*** *akka*: Akka implementation of the traversal machine +** *language* +*** *variant* + *groovy*: Groovy implementation of the Gremlin language + *scala*: Python implementation of the Gremlin language +*** *distinct* + *sparql*: A SPARQL to Gremlin bytecode compiler + *sql*: An SQL to Gremlin bytecode compiler + *cypher*: A Cypher to Gremlin bytecode compiler +* *test*: language test suite +* *python*: Apache TinkerPop for Python +* *dotnet*: Apache TinkerPop for C# +* *javascript*: Apache TinkerPop for JavaScript \ No newline at end of file
[tinkerpop] 14/19: have the first stub of Apache Beam working in TP4. I was in the most nightmarish hell for the longest time --- I didn't have the machine pom.xml have beam as a submodule so changes
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 49c7d208b85955b2f4906b21007da25b338f0b6c Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 05:42:27 2019 -0600 have the first stub of Apache Beam working in TP4. I was in the most nightmarish hell for the longest time --- I didn't have the machine pom.xml have beam as a submodule so changes I did to core did nothing. Had this serialization error and I spent a good 2 hours to ultimately realize that my code changes werent taking effect. So bad. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 + .../apache/tinkerpop/language/TraversalSource.java | 2 + .../tinkerpop/machine/bytecode/Bytecode.java | 36 ++- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 3 + .../SourceInstruction.java}| 23 +++-- .../machine/coefficients/Coefficient.java | 4 +- .../machine/coefficients/LongCoefficient.java | 5 +- .../machine/functions/AbstractFunction.java| 12 +-- .../tinkerpop/machine/functions/CFunction.java | 3 +- .../machine/functions/InitialFunction.java | 4 +- .../tinkerpop/machine/functions/MapFunction.java | 3 +- .../{MapFunction.java => ReduceFunction.java} | 6 +- .../machine/functions/filter/IdentityFilter.java | 3 +- .../machine/functions/filter/IsFilter.java | 4 +- .../machine/functions/initial/InjectInitial.java | 5 +- .../tinkerpop/machine/functions/map/IncrMap.java | 5 +- .../tinkerpop/machine/functions/map/MapMap.java| 5 +- .../tinkerpop/machine/functions/map/PathMap.java | 4 +- .../{CFunction.java => reduce/BasicReducer.java} | 23 +++-- .../{map/IncrMap.java => reduce/CountReduce.java} | 17 ++-- .../{CFunction.java => reduce/Reducer.java}| 13 +-- .../{Traverser.java => CompleteTraverser.java} | 28 +++--- .../CompleteTraverserFactory.java} | 15 ++- .../apache/tinkerpop/machine/traversers/Path.java | 3 +- .../tinkerpop/machine/traversers/Traverser.java| 67 +++-- .../TraverserFactory.java} | 11 +-- .../tinkerpop/machine/traversers/TraverserSet.java | 6 +- java/machine/beam/pom.xml | 103 .../org/apache/tinkerpop/machine/beam/Beam.java| 106 + .../tinkerpop/machine/beam/BeamProcessor.java} | 14 ++- .../apache/tinkerpop/machine/beam/FilterFn.java} | 25 +++-- .../org/apache/tinkerpop/machine/beam/MapFn.java} | 18 ++-- .../apache/tinkerpop/machine/beam/OutputStep.java} | 18 +++- .../tinkerpop/machine/beam/TraverserCoder.java | 65 + .../apache/tinkerpop/machine/beam/BeamTest.java} | 15 +-- .../tinkerpop/machine/pipes/AbstractStep.java | 2 +- .../apache/tinkerpop/machine/pipes/EmptyStep.java | 4 +- .../apache/tinkerpop/machine/pipes/FilterStep.java | 37 ++- .../tinkerpop/machine/pipes/InitialStep.java | 9 +- .../apache/tinkerpop/machine/pipes/MapStep.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 14 ++- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 63 .../apache/tinkerpop/machine/pipes/PipesTest.java | 7 +- java/machine/pom.xml | 1 + java/pom.xml | 3 +- 46 files changed, 642 insertions(+), 183 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 681e26e..b302b88 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 @@ -25,6 +25,7 @@ public final class Symbols { public static final String AS = "as"; public static final String C = "c"; +public static final String COUNT = "count"; public static final String IDENTITY = "identity"; public static final String IS = "is"; public static final String INCR = "incr"; 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 7acdd75..f8f446c 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 @@ -62,6 +62,11 @@ public class Traversal implements Iterator { return this; } +public Traversal count() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.COUNT); +return (Traversal) this; +} + public Traversal identity() { this.bytecode.addInstruction(this.curre
[tinkerpop] 15/19: cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines.
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 0fd1e42e32242401b34c95f699b8d684b4b623fd Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:39:35 2019 -0600 cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines. --- .../tinkerpop/machine/traversers/TraverserSet.java | 3 +- java/machine/beam/pom.xml | 5 ++ .../machine/beam/{MapFn.java => AbstractFn.java} | 25 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 57 +- .../apache/tinkerpop/machine/beam/FilterFn.java| 4 +- .../machine/beam/{FilterFn.java => Fn.java}| 17 ++- .../machine/beam/{FilterFn.java => InitialFn.java} | 22 ++--- .../org/apache/tinkerpop/machine/beam/MapFn.java | 27 -- .../machine/beam/{MapFn.java => ReduceFn.java} | 27 +- .../tinkerpop/machine/beam/TraverserCoder.java | 6 +-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- 12 files changed, 119 insertions(+), 81 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java index ce52b63..66169ab 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java @@ -21,6 +21,7 @@ package org.apache.tinkerpop.machine.traversers; import org.apache.tinkerpop.util.FastNoSuchElementException; +import java.io.Serializable; import java.util.AbstractSet; import java.util.Collections; import java.util.Iterator; @@ -33,7 +34,7 @@ import java.util.Spliterator; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class TraverserSet extends AbstractSet> implements Set>, Queue> { +public class TraverserSet extends AbstractSet> implements Set>, Queue>, Serializable { private final Map, Traverser> map = Collections.synchronizedMap(new LinkedHashMap<>()); diff --git a/java/machine/beam/pom.xml b/java/machine/beam/pom.xml index 2fb4c82..24a9773 100644 --- a/java/machine/beam/pom.xml +++ b/java/machine/beam/pom.xml @@ -79,6 +79,11 @@ limitations under the License. 2.11.0 runtime + +org.apache.tinkerpop +pipes +${project.version} + ${basedir}/target diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java similarity index 61% copy from java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java copy to java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java index 2b83ab2..63caa5e 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java @@ -19,23 +19,30 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.transforms.DoFn; -import org.apache.beam.sdk.values.TypeDescriptor; -import org.apache.tinkerpop.machine.functions.MapFunction; +import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.traversers.Traverser; +import org.apache.tinkerpop.machine.traversers.TraverserSet; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class MapFn extends DoFn, Traverser> { +public abstract class AbstractFn extends DoFn, Traverser> implements Fn { -private final MapFunction mapFunction; +protected final TraverserSet traversers = new TraverserSet<>(); +protected final CFunction function; -public MapFn(final MapFunction mapFunction) { -this.mapFunction = mapFunction; +protected AbstractFn(final CFunction function) { +this.function = function; } -@ProcessElement -public void processElement(final @Element Traverser traverser, final OutputReceiver> output) { -output.output(traverser.map(this.mapFunction)); +@Override +public void addStart(final Traverser traverser) { +this.traversers.add(traverser); } + +@Override +public String toString() { +return this.function.toString(); +} + } 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 a03ee71..b93174e 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java +++ b/java/machine/beam/src/main/java/org/
[tinkerpop] 10/19: trucking along. got as() and path() working. Really neat -- as() is a pop/push on the Bytecode. Just as specified in the TP4 article. as(), by(), and all other step-modulators will
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 32c5caefe24e470f811da1505a860d2b0d647a10 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 06:25:02 2019 -0700 trucking along. got as() and path() working. Really neat -- as() is a pop/push on the Bytecode. Just as specified in the TP4 article. as(), by(), and all other step-modulators will pop/push the instruction stack. --- .../{machine/compiler => language}/Symbols.java| 4 +++- .../org/apache/tinkerpop/language/Traversal.java | 14 ++- .../tinkerpop/machine/bytecode/Bytecode.java | 4 .../tinkerpop/machine/bytecode/Instruction.java| 13 ++- .../machine/compiler/BytecodeToFunction.java | 21 +++-- .../{GFunction.java => AbstractFunction.java} | 26 ++--- .../{FilterFunction.java => CFunction.java}| 11 + .../machine/functions/FilterFunction.java | 2 +- .../machine/functions/FlatMapFunction.java | 2 +- .../tinkerpop/machine/functions/IncrMap.java | 10 .../machine/functions/InitialFunction.java | 2 +- .../tinkerpop/machine/functions/InjectInitial.java | 7 +++--- .../tinkerpop/machine/functions/IsFilter.java | 8 --- .../tinkerpop/machine/functions/MapFunction.java | 2 +- .../functions/{IncrMap.java => PathMap.java} | 13 +++ .../Bytecode.java => traversers/Path.java} | 27 ++ .../tinkerpop/machine/traversers/Traverser.java| 22 +- .../apache/tinkerpop/machine/TraversalTest.java| 2 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 8 +++ .../org/apache/tinkerpop/machine/pipes/Step.java | 8 +++ .../apache/tinkerpop/machine/pipes/PipesTest.java | 1 + 21 files changed, 151 insertions(+), 56 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java similarity index 89% rename from java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java rename to java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java index 7de197f..fdaf642 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/compiler/Symbols.java +++ b/java/core/src/main/java/org/apache/tinkerpop/language/Symbols.java @@ -16,14 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.tinkerpop.machine.compiler; +package org.apache.tinkerpop.language; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ public final class Symbols { +public static final String AS = "as"; public static final String IS = "is"; public static final String INCR = "incr"; public static final String INJECT = "inject"; +public static final String PATH = "path"; } 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 86d307a..f363342f 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,8 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; -import org.apache.tinkerpop.machine.compiler.Symbols; + +import java.util.Map; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -34,6 +35,11 @@ public class Traversal { this.bytecode = new Bytecode<>(); } +public Traversal as(final String label) { +this.bytecode.lastInstruction().addLabel(label); +return this; +} + public Traversal is(final B object) { this.bytecode.addInstruction(this.currentCoefficient, Symbols.IS, object); return this; @@ -49,6 +55,12 @@ public class Traversal { return (Traversal) this; } +public Traversal> path() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.PATH); +return (Traversal) this; +} + + public Bytecode getBytecode() { return this.bytecode; } 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 f58f719..e1ef154 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 @@ -40,6 +40,10 @@ public class Bytecode { return this.instructions; } +public Instruction lastInstruction() { +return this.instructions.get(this.instructions.size() - 1); +} + @Override public St
[tinkerpop] 19/19: got SumReduce working easily. Lots of Traverser tweaks. Added @dkuppitz NumberHelper class from TP3.
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 3e72077ba8a418cf36fdbbe0ae691d662056be41 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 11:32:16 2019 -0600 got SumReduce working easily. Lots of Traverser tweaks. Added @dkuppitz NumberHelper class from TP3. --- .../org/apache/tinkerpop/language/Symbols.java | 1 + .../org/apache/tinkerpop/language/Traversal.java | 5 + .../tinkerpop/machine/bytecode/Bytecode.java | 7 - .../tinkerpop/machine/bytecode/BytecodeUtil.java | 9 + .../machine/functions/reduce/SumReduce.java} | 32 +- .../machine/traversers/CompleteTraverser.java | 13 +- .../tinkerpop/machine/traversers/Traverser.java| 17 +- .../machine/traversers/TraverserFactory.java | 1 + .../org/apache/tinkerpop/util/NumberHelper.java| 445 + .../apache/tinkerpop/machine/beam/AbstractFn.java | 4 +- .../org/apache/tinkerpop/machine/beam/Beam.java| 17 +- .../apache/tinkerpop/machine/beam/InitialFn.java | 9 +- .../org/apache/tinkerpop/machine/beam/MapFn.java | 4 +- .../apache/tinkerpop/machine/beam/ReduceFn.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 4 +- .../apache/tinkerpop/machine/pipes/ReduceStep.java | 8 +- .../machine/pipes/util}/BasicReducer.java | 2 +- .../tinkerpop/machine/pipes/util}/Reducer.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 5 +- 19 files changed, 525 insertions(+), 65 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 2912789..4f5ed5f 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 @@ -39,4 +39,5 @@ public final class Symbols { public static final String INJECT = "inject"; public static final String MAP = "map"; public static final String PATH = "path"; +public static final String SUM = "sum"; } 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 ba090d9..e9ebb85 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 @@ -100,6 +100,11 @@ public class Traversal implements Iterator { return (Traversal) this; } +public Traversal sum() { +this.bytecode.addInstruction(this.currentCoefficient, Symbols.SUM); +return (Traversal) this; +} + /// 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 1529a5c..ddc1cf9 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,8 +19,6 @@ package org.apache.tinkerpop.machine.bytecode; import org.apache.tinkerpop.machine.coefficients.Coefficient; -import org.apache.tinkerpop.machine.traversers.CompleteTraverserFactory; -import org.apache.tinkerpop.machine.traversers.TraverserFactory; import java.util.ArrayList; import java.util.List; @@ -60,11 +58,6 @@ public class Bytecode implements Cloneable { return this.instructions.get(this.instructions.size() - 1); } -// this should be part of withProcessor! -public TraverserFactory getTraverserFactory() { -return new CompleteTraverserFactory<>(); -} - @Override public String toString() { return this.instructions.toString(); 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 538825a..61882b7 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,8 +28,11 @@ 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.functions.reduce.SumReduce; import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.strategies.Strategy; +import org.apache.tinkerpop.machine.traversers.CompleteTraverserFactory; +import org.apache.tinkerpop.machine.traversers.TraverserFactory; import java.lang.reflect.InvocationTargetException; import java.util.Arra
[tinkerpop] 12/19: Added ProcessorFactory which is used with a TraversalSource to register the factoryused to mint Processors to execute traversal chains. Thus, g = g.processor(PipesProcessor.class).
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 342e7604c4b7a053d3f766a67edef67bb9754e87 Author: Marko A. Rodriguez AuthorDate: Thu Mar 7 11:14:02 2019 -0700 Added ProcessorFactory which is used with a TraversalSource to register the factoryused to mint Processors to execute traversal chains. Thus, g = g.processor(PipesProcessor.class). Everything is moving along nicely. --- .../org/apache/tinkerpop/language/Traversal.java | 44 ++ .../apache/tinkerpop/language/TraversalSource.java | 16 +++- .../language/{__.java => TraversalUtil.java} | 13 +-- .../java/org/apache/tinkerpop/language/__.java | 4 +- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 10 ++--- .../tinkerpop/machine/bytecode/Instruction.java| 3 +- .../machine/functions/AbstractFunction.java| 4 +- .../machine/functions/FilterFunction.java | 2 +- .../machine/functions/FlatMapFunction.java | 2 +- .../machine/functions/InitialFunction.java | 2 +- .../tinkerpop/machine/functions/MapFunction.java | 2 +- .../machine/functions/NestedFunction.java | 2 +- .../machine/functions/filter/IdentityFilter.java | 2 +- .../machine/functions/filter/IsFilter.java | 8 ++-- .../machine/functions/initial/InjectInitial.java | 22 +-- .../tinkerpop/machine/functions/map/IncrMap.java | 2 +- .../tinkerpop/machine/functions/map/MapMap.java| 4 +- .../tinkerpop/machine/functions/map/PathMap.java | 4 +- .../IncrMap.java => processor/EmptyProcessor.java} | 37 +- .../machine/processor/EmptyProcessorFactory.java} | 21 +++ .../machine/{ => processor}/Processor.java | 2 +- .../processor/ProcessorFactory.java} | 10 ++--- .../tinkerpop/machine/traversers/Traverser.java| 10 ++--- .../apache/tinkerpop/machine/TraversalTest.java| 5 +-- .../machine/compiler/BytecodeUtilTest.java | 7 ++-- .../tinkerpop/machine/pipes/AbstractStep.java | 16 +++- .../apache/tinkerpop/machine/pipes/FilterStep.java | 6 +-- .../apache/tinkerpop/machine/pipes/MapStep.java| 4 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 18 - .../tinkerpop/machine/pipes/PipesProcessor.java} | 13 +-- .../org/apache/tinkerpop/machine/pipes/Step.java} | 9 +++-- .../apache/tinkerpop/machine/pipes/PipesTest.java | 18 - 32 files changed, 195 insertions(+), 127 deletions(-) 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 06b93bf..4021d08 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,19 +19,28 @@ package org.apache.tinkerpop.language; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.processor.Processor; +import org.apache.tinkerpop.machine.processor.ProcessorFactory; import org.apache.tinkerpop.machine.traversers.Path; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** - * @author Marko S. Rodriguez (http://markorodriguez.com) + * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class Traversal { +public class Traversal implements Iterator { -private final Bytecode bytecode; +protected final Bytecode bytecode; private C currentCoefficient; +private final ProcessorFactory factory; +private Processor processor; -public Traversal(final C unity) { +public Traversal(final C unity, final ProcessorFactory factory) { this.currentCoefficient = unity; this.bytecode = new Bytecode<>(); +this.factory = factory; } public Traversal as(final String label) { @@ -65,7 +74,7 @@ public class Traversal { } public Traversal map(final Traversal mapTraversal) { -this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal.getBytecode()); +this.bytecode.addInstruction(this.currentCoefficient, Symbols.MAP, mapTraversal.bytecode); return (Traversal) this; } @@ -74,10 +83,29 @@ public class Traversal { return (Traversal) this; } +private void setupProcessor() { +if (null == this.processor) +this.processor = this.factory.mint(this.bytecode); +} -// create a utility class that directly access the class field so we don't have to do the Admin stuff in TP4. -public Bytecode getBytecode() { -return this.bytecode; +@Override +public boolean hasNext() { +this.setupProcessor(); +return this.processor.hasNextTraverser(); } +@Override +public E next() { +this.setupProcessor();
[tinkerpop] 05/19: small pom tweak.
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 a69ea2f621d2e1547c713af0e9403155bfb684f3 Author: Marko A. Rodriguez AuthorDate: Mon Mar 4 10:28:54 2019 -0700 small pom tweak. --- gremlin-machines/gremlin-pipes/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gremlin-machines/gremlin-pipes/pom.xml b/gremlin-machines/gremlin-pipes/pom.xml index 783bada..91ea4f1 100644 --- a/gremlin-machines/gremlin-pipes/pom.xml +++ b/gremlin-machines/gremlin-pipes/pom.xml @@ -21,7 +21,7 @@ limitations under the License. org.apache.tinkerpop 4.0.0-SNAPSHOT -Apache TinkerPop :: Gremlin Pipes +Apache TinkerPop :: Gremlin Machines :: Gremlin Pipes gremlin-pipes
[tinkerpop] 01/19: Apache TinkerPop 4.x all starts with a README
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 4463a8343834812ab617a15c8f0cf1538caa3b63 Author: Stephen Mallette AuthorDate: Fri Mar 1 15:19:43 2019 -0500 Apache TinkerPop 4.x all starts with a README --- README.asciidoc | 17 + 1 file changed, 17 insertions(+) diff --git a/README.asciidoc b/README.asciidoc new file mode 100644 index 000..1eaec1a --- /dev/null +++ b/README.asciidoc @@ -0,0 +1,17 @@ + +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. + +== TinkerPop4
[tinkerpop] branch tp4 updated: minor changes. taking a break.
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 The following commit(s) were added to refs/heads/tp4 by this push: new d602c07 minor changes. taking a break. d602c07 is described below commit d602c0706e0e430eacfc4761d61d6b2ddf7e2340 Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:49:22 2019 -0600 minor changes. taking a break. --- .../java/org/apache/tinkerpop/language/Symbols.java | 5 + .../java/org/apache/tinkerpop/machine/beam/Beam.java | 19 ++- 2 files changed, 15 insertions(+), 9 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 b302b88..9ea778d 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 @@ -23,6 +23,11 @@ package org.apache.tinkerpop.language; */ public final class Symbols { +// SOURCE OPS +public static final String COEFFICIENT = "coefficient"; + + +// INSTRUCTION OPS public static final String AS = "as"; public static final String C = "c"; public static final String COUNT = "count"; 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 b93174e..f2813b4 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 @@ -19,6 +19,7 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.options.PipelineOptions; import org.apache.beam.sdk.transforms.Create; import org.apache.beam.sdk.transforms.DoFn; import org.apache.beam.sdk.transforms.ParDo; @@ -44,17 +45,16 @@ import java.util.List; */ public class Beam implements Processor { -final Pipeline pipeline; -PCollection collection; -public static List OUTPUT = new ArrayList<>(); -Iterator iterator = null; +private final Pipeline pipeline; +public static List OUTPUT = new ArrayList<>(); // FIX THIS! private final List functions = new ArrayList<>(); +Iterator iterator = null; public Beam(final List> functions) { this.pipeline = Pipeline.create(); this.pipeline.getCoderRegistry().registerCoderForClass(Traverser.class, new TraverserCoder<>()); -this.collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); -this.collection.setCoder(new TraverserCoder()); +PCollection collection = this.pipeline.apply(Create.of(new CompleteTraverser(LongCoefficient.create(), 1L))); +collection.setCoder(new TraverserCoder()); DoFn fn = null; for (final CFunction function : functions) { @@ -69,10 +69,11 @@ public class Beam implements Processor { } else throw new RuntimeException("You need a new step type:" + function); this.functions.add(fn); -this.collection = (PCollection) collection.apply(ParDo.of(fn)); -this.collection.setCoder(new TraverserCoder()); +collection = (PCollection) collection.apply(ParDo.of(fn)); +collection.setCoder(new TraverserCoder()); } collection = (PCollection) collection.apply(ParDo.of(new OutputStep())); +this.pipeline.getOptions().setRunner(new PipelineOptions.DirectRunner().create(this.pipeline.getOptions())); } public Beam(final Bytecode bytecode) { @@ -108,7 +109,7 @@ public class Beam implements Processor { private final void setupPipeline() { if (null == this.iterator) { -pipeline.run().waitUntilFinish(); +this.pipeline.run().waitUntilFinish(); this.iterator = new ArrayList<>(OUTPUT).iterator(); OUTPUT.clear(); }
[tinkerpop] branch tp4 updated: cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines.
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 The following commit(s) were added to refs/heads/tp4 by this push: new 0fd1e42 cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines. 0fd1e42 is described below commit 0fd1e42e32242401b34c95f699b8d684b4b623fd Author: Marko A. Rodriguez AuthorDate: Mon Mar 11 06:39:35 2019 -0600 cleaned up and organized Apache Beam machine. Need to add reducer support and then its at the same state as the Pipes machines. --- .../tinkerpop/machine/traversers/TraverserSet.java | 3 +- java/machine/beam/pom.xml | 5 ++ .../machine/beam/{MapFn.java => AbstractFn.java} | 25 ++ .../org/apache/tinkerpop/machine/beam/Beam.java| 57 +- .../apache/tinkerpop/machine/beam/FilterFn.java| 4 +- .../machine/beam/{FilterFn.java => Fn.java}| 17 ++- .../machine/beam/{FilterFn.java => InitialFn.java} | 22 ++--- .../org/apache/tinkerpop/machine/beam/MapFn.java | 27 -- .../machine/beam/{MapFn.java => ReduceFn.java} | 27 +- .../tinkerpop/machine/beam/TraverserCoder.java | 6 +-- .../apache/tinkerpop/machine/beam/BeamTest.java| 5 +- .../org/apache/tinkerpop/machine/pipes/Pipes.java | 2 +- 12 files changed, 119 insertions(+), 81 deletions(-) diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java index ce52b63..66169ab 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/traversers/TraverserSet.java @@ -21,6 +21,7 @@ package org.apache.tinkerpop.machine.traversers; import org.apache.tinkerpop.util.FastNoSuchElementException; +import java.io.Serializable; import java.util.AbstractSet; import java.util.Collections; import java.util.Iterator; @@ -33,7 +34,7 @@ import java.util.Spliterator; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class TraverserSet extends AbstractSet> implements Set>, Queue> { +public class TraverserSet extends AbstractSet> implements Set>, Queue>, Serializable { private final Map, Traverser> map = Collections.synchronizedMap(new LinkedHashMap<>()); diff --git a/java/machine/beam/pom.xml b/java/machine/beam/pom.xml index 2fb4c82..24a9773 100644 --- a/java/machine/beam/pom.xml +++ b/java/machine/beam/pom.xml @@ -79,6 +79,11 @@ limitations under the License. 2.11.0 runtime + +org.apache.tinkerpop +pipes +${project.version} + ${basedir}/target diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java similarity index 61% copy from java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java copy to java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java index 2b83ab2..63caa5e 100644 --- a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/MapFn.java +++ b/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/AbstractFn.java @@ -19,23 +19,30 @@ package org.apache.tinkerpop.machine.beam; import org.apache.beam.sdk.transforms.DoFn; -import org.apache.beam.sdk.values.TypeDescriptor; -import org.apache.tinkerpop.machine.functions.MapFunction; +import org.apache.tinkerpop.machine.functions.CFunction; import org.apache.tinkerpop.machine.traversers.Traverser; +import org.apache.tinkerpop.machine.traversers.TraverserSet; /** * @author Marko A. Rodriguez (http://markorodriguez.com) */ -public class MapFn extends DoFn, Traverser> { +public abstract class AbstractFn extends DoFn, Traverser> implements Fn { -private final MapFunction mapFunction; +protected final TraverserSet traversers = new TraverserSet<>(); +protected final CFunction function; -public MapFn(final MapFunction mapFunction) { -this.mapFunction = mapFunction; +protected AbstractFn(final CFunction function) { +this.function = function; } -@ProcessElement -public void processElement(final @Element Traverser traverser, final OutputReceiver> output) { -output.output(traverser.map(this.mapFunction)); +@Override +public void addStart(final Traverser traverser) { +this.traversers.add(traverser); } + +@Override +public String toString() { +return this.function.toString(); +} + } diff --git a/java/machine/beam/src/main/java/org/apache/tinkerpop/machine/beam/Beam.java