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 <okramma...@gmail.com> 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<C> implements Cloneable { /// public void addInstruction(final Coefficient<C> 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<C, S, E> 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<C> { private final Set<String> labels = new HashSet<>(); public Instruction(final Coefficient<C> 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<C> extends Cloneable, Serializable { - public Coefficient<C> sum(final Coefficient<C> other); + public void sum(final Coefficient<C> other); - public Coefficient<C> multiply(final Coefficient<C> other); + public void multiply(final Coefficient<C> other); - public Coefficient<C> set(final C other); + public void set(final C other); - public Coefficient<C> unity(); + public void unity(); - public Coefficient<C> 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<Long> { } @Override - public Coefficient<Long> sum(final Coefficient<Long> other) { + public void sum(final Coefficient<Long> other) { this.value = this.value + other.value(); - return this; } @Override - public Coefficient<Long> multiply(final Coefficient<Long> other) { + public void multiply(final Coefficient<Long> other) { this.value = this.value * other.value(); - return this; } @Override - public Coefficient<Long> set(final Long value) { + public void set(final Long value) { this.value = value; - return this; } @Override - public Coefficient<Long> unity() { + public void unity() { this.value = 1L; - return this; } @Override - public Coefficient<Long> zero() { + public void zero() { this.value = 0L; - return this; } @Override