tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [45/50] tinkerpop git commit: Made sure that the barrier step and the reducing operator are reevaluated when the value traversal is being replaced.
Date Fri, 04 Aug 2017 16:59:25 GMT
Made sure that the barrier step and the reducing operator are reevaluated when the value traversal
is being replaced.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/429aa73a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/429aa73a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/429aa73a

Branch: refs/heads/TINKERPOP-1682
Commit: 429aa73acef694bf1368a514f45615b4081474aa
Parents: 073ff2f
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Fri Jun 23 23:43:13 2017 +0200
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Fri Aug 4 09:58:05 2017 -0700

----------------------------------------------------------------------
 .../process/traversal/step/map/GroupStep.java     | 12 ++++++++----
 .../step/sideEffect/GroupSideEffectStep.java      | 18 +++++++++++-------
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/429aa73a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
index 521debc..4d795f9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
@@ -63,15 +63,19 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S,
Map<K, V>>
         this.setSeedSupplier(HashMapSupplier.instance());
     }
 
+    private void setValueTraversal(final Traversal.Admin<?, ?> kvTraversal) {
+        this.valueTraversal = this.integrateChild(convertValueTraversal(kvTraversal));
+        this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
+        this.setReducingBiOperator(new GroupBiOperator<>(null == this.barrierStep ?
Operator.assign : this.barrierStep.getMemoryComputeKey().getReducer()));
+    }
+
     @Override
     public void modulateBy(final Traversal.Admin<?, ?> kvTraversal) {
         if ('k' == this.state) {
             this.keyTraversal = this.integrateChild(kvTraversal);
             this.state = 'v';
         } else if ('v' == this.state) {
-            this.valueTraversal = this.integrateChild(convertValueTraversal(kvTraversal));
-            this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class,
this.valueTraversal).orElse(null);
-            this.setReducingBiOperator(new GroupBiOperator<>(null == this.barrierStep
? Operator.assign : this.barrierStep.getMemoryComputeKey().getReducer()));
+            this.setValueTraversal(kvTraversal);
             this.state = 'x';
         } else {
             throw new IllegalStateException("The key and value traversals for group()-step
have already been set: " + this);
@@ -83,7 +87,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S,
Map<K, V>>
         if (null != this.keyTraversal && this.keyTraversal.equals(oldTraversal))
             this.keyTraversal = this.integrateChild(newTraversal);
         else if (null != this.valueTraversal && this.valueTraversal.equals(oldTraversal))
-            this.valueTraversal = this.integrateChild(newTraversal);
+            this.setValueTraversal(newTraversal);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/429aa73a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
index 35f3cd7..ee73fec 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
@@ -62,18 +62,22 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S>
implem
                         this.barrierStep.getMemoryComputeKey().getReducer()));
     }
 
+    private void setValueTraversal(final Traversal.Admin<?, ?> valueTraversal) {
+        this.valueTraversal = this.integrateChild(GroupStep.convertValueTraversal(valueTraversal));
+        this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
+        this.getTraversal().getSideEffects().register(this.sideEffectKey, null,
+                new GroupStep.GroupBiOperator<>(null == this.barrierStep ?
+                        Operator.assign :
+                        this.barrierStep.getMemoryComputeKey().getReducer()));
+    }
+
     @Override
     public void modulateBy(final Traversal.Admin<?, ?> kvTraversal) {
         if ('k' == this.state) {
             this.keyTraversal = this.integrateChild(kvTraversal);
             this.state = 'v';
         } else if ('v' == this.state) {
-            this.valueTraversal = this.integrateChild(GroupStep.convertValueTraversal(kvTraversal));
-            this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class,
this.valueTraversal).orElse(null);
-            this.getTraversal().getSideEffects().register(this.sideEffectKey, null,
-                    new GroupStep.GroupBiOperator<>(null == this.barrierStep ?
-                            Operator.assign :
-                            this.barrierStep.getMemoryComputeKey().getReducer()));
+            this.setValueTraversal(kvTraversal);
             this.state = 'x';
         } else {
             throw new IllegalStateException("The key and value traversals for group()-step
have already been set: " + this);
@@ -85,7 +89,7 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S>
implem
         if (null != this.keyTraversal && this.keyTraversal.equals(oldTraversal))
             this.keyTraversal = this.integrateChild(newTraversal);
         else if (null != this.valueTraversal && this.valueTraversal.equals(oldTraversal))
-            this.valueTraversal = this.integrateChild(newTraversal);
+            this.setValueTraversal(newTraversal);
     }
 
     @Override


Mime
View raw message