You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "andreachild (via GitHub)" <gi...@apache.org> on 2025/11/06 06:17:39 UTC

[PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

andreachild opened a new pull request, #3273:
URL: https://github.com/apache/tinkerpop/pull/3273

   Fixed `SampleGlobalStep` computer algorithm to return the correct sample size when used in repeat by retaining only the traversers which have passed through all loops when merging traverser sets. Prior to this fix the traverser sets would be merged together and traversers which were excluded from the sample would potentially be added to the sample in the next loop.
   
   VOTE +1


-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#discussion_r2505205663


##########
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);

Review Comment:
   Moved the reducer operator to field of the step so that it's only initialized once when the step is initialized.



-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#issuecomment-3504342959

   This looks like a good change to have. VOTE +1.


-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#discussion_r2501436950


##########
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:
   Upon re-reading the PR description that appears to be the case.



-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#discussion_r2501439701


##########
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);

Review Comment:
   Nit: Could save on some object initialization overhead here by reusing a single SampleBiOperator object, although I highly doubt there would be any significance.



-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#issuecomment-3495303796

   ## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/3273?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :warning: Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`3.8-dev@01a1ca5`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#section-missing-base-commit) about missing BASE report.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             3.8-dev    #3273   +/-   ##
   ==========================================
     Coverage           ?   79.12%           
   ==========================================
     Files              ?       28           
     Lines              ?     5944           
     Branches           ?        0           
   ==========================================
     Hits               ?     4703           
     Misses             ?     1020           
     Partials           ?      221           
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/tinkerpop/pull/3273?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273#issuecomment-3500154154

   VOTE +1


-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix sample in repeat computer algorithm to retain sample size [tinkerpop]

Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild merged PR #3273:
URL: https://github.com/apache/tinkerpop/pull/3273


-- 
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: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org