Cole-Greer commented on code in PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#discussion_r2501434897


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/SampleGlobalStep.java:
##########
@@ -135,7 +137,39 @@ public void barrierConsumer(final TraverserSet<S> 
traverserSet) {
         traverserSet.addAll(sampledSet);
     }
 
+    @Override
+    public MemoryComputeKey<TraverserSet<S>> getMemoryComputeKey() {
+        return MemoryComputeKey.of(this.getId(), new SampleBiOperator<>(), 
false, true);
+    }
+    
+    public static final class SampleBiOperator<S> implements 
BinaryOperator<TraverserSet<S>>, Serializable {
+        @Override
+        public TraverserSet<S> apply(final TraverserSet<S> setA, final 
TraverserSet<S> setB) {
+            int maxLoops = -1;
+            // if the traversers have gone through loops, only retain the ones 
that have passed through the most loops
+            // if there are no loops, all traversers are retained

Review Comment:
   Overall the tests look good and this appears to be correct, I'm curious 
though where these traversers with fewer loops are coming from and what they 
represent. Are these the traversers from a previous loop which weren't sampled?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to