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 80c88fe CoreCompiler.Symbols now exists. Likewise TinkerGraphCompiler.Symbols. 80c88fe is described below commit 80c88fe09885035c9f9205089325b5decafe6d1c Author: Marko A. Rodriguez <okramma...@gmail.com> AuthorDate: Mon Mar 18 14:13:56 2019 -0600 CoreCompiler.Symbols now exists. Likewise TinkerGraphCompiler.Symbols. --- .../tinkerpop/machine/bytecode/BytecodeUtil.java | 12 +- .../tinkerpop/machine/bytecode/CoreCompiler.java | 106 +++++++++++++++++ .../apache/tinkerpop/machine/bytecode/Symbols.java | 128 --------------------- .../machine/function/barrier/JoinBarrier.java | 6 +- .../machine/strategy/CoefficientStrategy.java | 8 +- .../strategy/CoefficientVerificationStrategy.java | 4 +- .../machine/strategy/IdentityStrategy.java | 4 +- .../tinkerpop/language/gremlin/Traversal.java | 2 +- .../language/gremlin/TraversalSource.java | 2 +- .../tinkerpop/language/gremlin/TraversalUtil.java | 2 +- .../machine/beam/strategy/BeamStrategy.java | 2 +- .../machine/pipes/strategy/PipesStrategy.java | 2 +- .../apache/tinkerpop/machine/pipes/PipesTest.java | 2 +- .../tinkergraph/bytecode/TinkerGraphCompiler.java | 11 +- .../tinkergraph/strategy/VerticesStrategy.java | 7 +- 15 files changed, 143 insertions(+), 155 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 a46b756..b9a750c 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 @@ -56,7 +56,7 @@ public final class BytecodeUtil { try { final List<Strategy> strategies = new ArrayList<>(); for (final SourceInstruction sourceInstruction : bytecode.getSourceInstructions()) { - if (sourceInstruction.op().equals(Symbols.WITH_STRATEGY)) + if (sourceInstruction.op().equals(CoreCompiler.Symbols.WITH_STRATEGY)) strategies.add(((Class<? extends Strategy>) sourceInstruction.args()[0]).getConstructor().newInstance()); } // TODO: sort strategies @@ -70,7 +70,7 @@ public final class BytecodeUtil { try { Coefficient<C> coefficient = null; for (final SourceInstruction sourceInstruction : bytecode.getSourceInstructions()) { - if (sourceInstruction.op().equals(Symbols.WITH_COEFFICIENT)) { + if (sourceInstruction.op().equals(CoreCompiler.Symbols.WITH_COEFFICIENT)) { coefficient = ((Class<? extends Coefficient<C>>) sourceInstruction.args()[0]).getConstructor().newInstance(); } } @@ -85,7 +85,7 @@ public final class BytecodeUtil { try { ProcessorFactory processor = null; for (final SourceInstruction sourceInstruction : bytecode.getSourceInstructions()) { - if (sourceInstruction.op().equals(Symbols.WITH_PROCESSOR)) { + if (sourceInstruction.op().equals(CoreCompiler.Symbols.WITH_PROCESSOR)) { processor = (ProcessorFactory) ((Class<? extends Coefficient<C>>) sourceInstruction.args()[0]).getConstructor().newInstance(); } } @@ -99,7 +99,7 @@ public final class BytecodeUtil { try { StructureFactory structure = null; for (final SourceInstruction sourceInstruction : bytecode.getSourceInstructions()) { - if (sourceInstruction.op().equals(Symbols.WITH_STRUCTURE)) { + if (sourceInstruction.op().equals(CoreCompiler.Symbols.WITH_STRUCTURE)) { structure = (StructureFactory) ((Class<? extends Coefficient<C>>) sourceInstruction.args()[0]).getConstructor().newInstance(); } } @@ -126,9 +126,9 @@ public final class BytecodeUtil { public static <C> Optional<TraverserFactory<C>> getTraverserFactory(final Bytecode<C> bytecode) { // TODO: make this real for (final Instruction<C> instruction : bytecode.getInstructions()) { - if (instruction.op().equals(Symbols.PATH)) + if (instruction.op().equals(CoreCompiler.Symbols.PATH)) return Optional.of(COPTraverserFactory.instance()); - else if (instruction.op().equals(Symbols.REPEAT)) + else if (instruction.op().equals(CoreCompiler.Symbols.REPEAT)) return Optional.of(CORTraverserFactory.instance()); } return Optional.of(COPTraverserFactory.instance()); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CoreCompiler.java b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CoreCompiler.java index 53e8c3f..9832d58 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CoreCompiler.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/CoreCompiler.java @@ -106,4 +106,110 @@ public final class CoreCompiler implements BytecodeCompiler { return null; } } + + public static final class Symbols { + + private Symbols() { + // static instance + } + + public static enum Type { + 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"; + public static final String WITH_STRUCTURE = "withStructure"; + public static final String WITH_STRATEGY = "withStrategy"; + + + // ARGUMENT TOKENS + public static final String EQ = "eq"; + public static final String NEQ = "neq"; + public static final String LT = "lt"; + public static final String GT = "gt"; + public static final String LTE = "lte"; + public static final String GTE = "gte"; + public static final String REGEX = "regex"; + + // 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 CONSTANT = "constant"; + 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 = "hasKey"; + public static final String HAS_KEY_VALUE = "hasKeyValue"; + public static final String IDENTITY = "identity"; + public static final String INCR = "incr"; + public static final String INJECT = "inject"; + public static final String IS = "is"; + public static final String JOIN = "join"; + public static final String LOOPS = "loops"; + 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 UNFOLD = "unfold"; + public static final String UNION = "union"; + public static final String V = "V"; + + public static Type getOpType(final String op) { + switch (op) { + case BARRIER: + return Type.BARRIER; + case CHOOSE_IF_THEN: + return Type.BRANCH; + case CHOOSE_IF_THEN_ELSE: + return Type.BRANCH; + case CONSTANT: + return Type.MAP; + 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 JOIN: + return Type.BARRIER; + case LOOPS: + return Type.MAP; + case MAP: + return Type.MAP; + case PATH: + return Type.MAP; + case REPEAT: + return Type.BRANCH; + case SUM: + return Type.REDUCE; + case UNFOLD: + return Type.FLATMAP; + case UNION: + return Type.BRANCH; + case V: + return Type.FLATMAP; + default: + throw new IllegalArgumentException("The following op is unknown: " + op); + } + } + } } 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 deleted file mode 100644 index f518324..0000000 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Symbols.java +++ /dev/null @@ -1,128 +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.bytecode; - -/** - * @author Marko A. Rodriguez (http://markorodriguez.com) - */ -public final class Symbols { - - private Symbols() { - // static instance - } - - public static enum Type { - 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"; - public static final String WITH_STRUCTURE = "withStructure"; - public static final String WITH_STRATEGY = "withStrategy"; - - - // ARGUMENT TOKENS - public static final String EQ = "eq"; - public static final String NEQ = "neq"; - public static final String LT = "lt"; - public static final String GT = "gt"; - public static final String LTE = "lte"; - public static final String GTE = "gte"; - public static final String REGEX = "regex"; - - // 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 CONSTANT = "constant"; - 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 = "hasKey"; - public static final String HAS_KEY_VALUE = "hasKeyValue"; - public static final String IDENTITY = "identity"; - public static final String INCR = "incr"; - public static final String INJECT = "inject"; - public static final String IS = "is"; - public static final String JOIN = "join"; - public static final String LOOPS = "loops"; - 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 UNFOLD = "unfold"; - public static final String UNION = "union"; - public static final String V = "V"; - - public static Type getOpType(final String op) { - switch (op) { - case BARRIER: - return Type.BARRIER; - case CHOOSE_IF_THEN: - return Type.BRANCH; - case CHOOSE_IF_THEN_ELSE: - return Type.BRANCH; - case CONSTANT: - return Type.MAP; - 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 JOIN: - return Type.BARRIER; - case LOOPS: - return Type.MAP; - case MAP: - return Type.MAP; - case PATH: - return Type.MAP; - case REPEAT: - return Type.BRANCH; - case SUM: - return Type.REDUCE; - case UNFOLD: - return Type.FLATMAP; - case UNION: - return Type.BRANCH; - case V: - return Type.FLATMAP; - default: - throw new IllegalArgumentException("The following op is unknown: " + op); - } - } -} 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 b110f15..2e637e2 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,7 +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.bytecode.CoreCompiler; import org.apache.tinkerpop.machine.coefficient.Coefficient; import org.apache.tinkerpop.machine.function.AbstractFunction; import org.apache.tinkerpop.machine.function.BarrierFunction; @@ -39,12 +39,12 @@ import java.util.Set; */ public class JoinBarrier<C, K, V> extends AbstractFunction<C> implements BarrierFunction<C, Map<K, V>, Map<K, V>, List<Map<K, V>>> { - private final Symbols.Tokens joinType; + private final CoreCompiler.Symbols.Tokens joinType; private final Compilation<C, Map<K, V>, Map<K, V>> joinCompilation; private final Argument<K> joinKey; public JoinBarrier(final Coefficient<C> coefficient, final Set<String> labels, - Symbols.Tokens joinType, + CoreCompiler.Symbols.Tokens joinType, final Compilation<C, Map<K, V>, Map<K, V>> joinCompilation, final Argument<K> joinKey) { super(coefficient, labels); diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientStrategy.java b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientStrategy.java index 1eba1fd..67d700c 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientStrategy.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientStrategy.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.machine.strategy; -import org.apache.tinkerpop.machine.bytecode.Symbols; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.bytecode.Instruction; @@ -34,14 +34,14 @@ public final class CoefficientStrategy implements Strategy { Coefficient<C> coefficient = BytecodeUtil.getCoefficient(bytecode).orElse(null); if (null == coefficient) { coefficient = (Coefficient<C>) LongCoefficient.create(); - bytecode.addSourceInstruction(Symbols.WITH_COEFFICIENT, coefficient.getClass()); + bytecode.addSourceInstruction(CoreCompiler.Symbols.WITH_COEFFICIENT, coefficient.getClass()); } for (final Instruction<C> instruction : bytecode.getInstructions()) { for (final Object arg : instruction.args()) { if (arg instanceof Bytecode) { final Bytecode<C> next = (Bytecode<C>) arg; - if (!BytecodeUtil.hasSourceInstruction(next, Symbols.WITH_COEFFICIENT)) { - next.addSourceInstruction(Symbols.WITH_COEFFICIENT, coefficient.getClass()); + if (!BytecodeUtil.hasSourceInstruction(next, CoreCompiler.Symbols.WITH_COEFFICIENT)) { + next.addSourceInstruction(CoreCompiler.Symbols.WITH_COEFFICIENT, coefficient.getClass()); } } } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientVerificationStrategy.java b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientVerificationStrategy.java index b0128ea..0bfb420 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientVerificationStrategy.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/CoefficientVerificationStrategy.java @@ -19,8 +19,8 @@ package org.apache.tinkerpop.machine.strategy; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler; import org.apache.tinkerpop.machine.bytecode.Instruction; -import org.apache.tinkerpop.machine.bytecode.Symbols; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -30,7 +30,7 @@ public final class CoefficientVerificationStrategy implements Strategy { @Override public <C> void apply(final Bytecode<C> bytecode) { for (final Instruction<C> instruction : bytecode.getInstructions()) { - if (Symbols.getOpType(instruction.op()).equals(Symbols.Type.REDUCE)) { + if (CoreCompiler.Symbols.getOpType(instruction.op()).equals(CoreCompiler.Symbols.Type.REDUCE)) { if (!instruction.coefficient().isUnity()) throw new IllegalStateException("Reduce functions can not have non-unity coefficients: " + instruction); } diff --git a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/IdentityStrategy.java b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/IdentityStrategy.java index 6886244..5772914 100644 --- a/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/IdentityStrategy.java +++ b/java/core/src/main/java/org/apache/tinkerpop/machine/strategy/IdentityStrategy.java @@ -18,7 +18,7 @@ */ package org.apache.tinkerpop.machine.strategy; -import org.apache.tinkerpop.machine.bytecode.Symbols; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler; import org.apache.tinkerpop.machine.bytecode.Bytecode; /** @@ -29,7 +29,7 @@ public final class IdentityStrategy implements Strategy { @Override public <C> void apply(final Bytecode<C> bytecode) { bytecode.getInstructions().removeIf(instruction -> - instruction.op().equals(Symbols.IDENTITY) && + instruction.op().equals(CoreCompiler.Symbols.IDENTITY) && instruction.labels().isEmpty() && instruction.coefficient().isUnity()); } diff --git a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java index 1d74861..72177a3 100644 --- a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java +++ b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/Traversal.java @@ -18,12 +18,12 @@ */ package org.apache.tinkerpop.language.gremlin; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler.Symbols; import org.apache.tinkerpop.machine.structure.data.TVertex; 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.P; -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.Traverser; diff --git a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalSource.java b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalSource.java index 5be6eba..389e429 100644 --- a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalSource.java +++ b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalSource.java @@ -19,7 +19,7 @@ package org.apache.tinkerpop.language.gremlin; import org.apache.tinkerpop.machine.bytecode.Bytecode; -import org.apache.tinkerpop.machine.bytecode.Symbols; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler.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/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalUtil.java b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalUtil.java index 15f0ccc..83f3150 100644 --- a/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalUtil.java +++ b/java/language/gremlin/src/main/java/org/apache/tinkerpop/language/gremlin/TraversalUtil.java @@ -19,8 +19,8 @@ package org.apache.tinkerpop.language.gremlin; import org.apache.tinkerpop.machine.bytecode.Bytecode; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler.Symbols; import org.apache.tinkerpop.machine.bytecode.Instruction; -import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.coefficient.Coefficient; /** diff --git a/java/machine/processor/beam/src/main/java/org/apache/tinkerpop/machine/beam/strategy/BeamStrategy.java b/java/machine/processor/beam/src/main/java/org/apache/tinkerpop/machine/beam/strategy/BeamStrategy.java index 920d8f3..b793b3b 100644 --- a/java/machine/processor/beam/src/main/java/org/apache/tinkerpop/machine/beam/strategy/BeamStrategy.java +++ b/java/machine/processor/beam/src/main/java/org/apache/tinkerpop/machine/beam/strategy/BeamStrategy.java @@ -18,9 +18,9 @@ */ package org.apache.tinkerpop.machine.beam.strategy; -import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler.Symbols; import org.apache.tinkerpop.machine.pipes.PipesProcessor; import org.apache.tinkerpop.machine.strategy.Strategy; diff --git a/java/machine/processor/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/strategy/PipesStrategy.java b/java/machine/processor/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/strategy/PipesStrategy.java index 5f5452c..271e174 100644 --- a/java/machine/processor/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/strategy/PipesStrategy.java +++ b/java/machine/processor/pipes/src/main/java/org/apache/tinkerpop/machine/pipes/strategy/PipesStrategy.java @@ -18,9 +18,9 @@ */ package org.apache.tinkerpop.machine.pipes.strategy; -import org.apache.tinkerpop.machine.bytecode.Symbols; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler.Symbols; import org.apache.tinkerpop.machine.pipes.PipesProcessor; import org.apache.tinkerpop.machine.strategy.Strategy; diff --git a/java/machine/processor/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java b/java/machine/processor/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java index 9f7b2f8..c1d65dc 100644 --- a/java/machine/processor/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java +++ b/java/machine/processor/pipes/src/test/java/org/apache/tinkerpop/machine/pipes/PipesTest.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; import static org.apache.tinkerpop.language.gremlin.__.incr; -import static org.apache.tinkerpop.machine.bytecode.Symbols.Tokens.inner; +import static org.apache.tinkerpop.machine.bytecode.CoreCompiler.Symbols.Tokens.inner; /** * @author Marko A. Rodriguez (http://markorodriguez.com) diff --git a/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/bytecode/TinkerGraphCompiler.java b/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/bytecode/TinkerGraphCompiler.java index f005933..e4c04ff 100644 --- a/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/bytecode/TinkerGraphCompiler.java +++ b/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/bytecode/TinkerGraphCompiler.java @@ -35,9 +35,18 @@ public class TinkerGraphCompiler implements BytecodeCompiler { final String op = instruction.op(); final Coefficient<C> coefficient = instruction.coefficient(); final Set<String> labels = instruction.labels(); - if (op.equals("tg:V")) + if (op.equals(Symbols.TG_V)) return new VerticesFlatMap<>(coefficient, labels); else return null; } + + public static class Symbols { + + private Symbols() { + // static instance + } + + public static final String TG_V = "tg:V"; + } } diff --git a/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/strategy/VerticesStrategy.java b/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/strategy/VerticesStrategy.java index 9bf2ea6..f5163e5 100644 --- a/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/strategy/VerticesStrategy.java +++ b/java/machine/structure/tinkergraph/src/main/java/org/apache/tinkerpop/machine/structure/tinkergraph/strategy/VerticesStrategy.java @@ -21,8 +21,9 @@ package org.apache.tinkerpop.machine.structure.tinkergraph.strategy; import org.apache.tinkerpop.machine.bytecode.Bytecode; import org.apache.tinkerpop.machine.bytecode.BytecodeUtil; import org.apache.tinkerpop.machine.bytecode.Instruction; -import org.apache.tinkerpop.machine.bytecode.Symbols; +import org.apache.tinkerpop.machine.bytecode.CoreCompiler; import org.apache.tinkerpop.machine.strategy.Strategy; +import org.apache.tinkerpop.machine.structure.tinkergraph.bytecode.TinkerGraphCompiler; /** * @author Marko A. Rodriguez (http://markorodriguez.com) @@ -32,10 +33,10 @@ public class VerticesStrategy implements Strategy { public <C> void apply(final Bytecode<C> bytecode) { Instruction<C> temp = null; for (final Instruction<C> instruction : bytecode.getInstructions()) { - if (instruction.op().equals(Symbols.V)) + if (instruction.op().equals(CoreCompiler.Symbols.V)) temp = instruction; } if (null != temp) - BytecodeUtil.replaceInstruction(bytecode, temp, new Instruction<>(temp.coefficient(), "tg:V")); + BytecodeUtil.replaceInstruction(bytecode, temp, new Instruction<>(temp.coefficient(), TinkerGraphCompiler.Symbols.TG_V)); } }