This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git


The following commit(s) were added to refs/heads/trunk by this push:
     new a63cac24 Check for splittable ranges Patch by Alex Petrov; reviewed by 
Ariel Weisberg for CASSANDRA-20032
a63cac24 is described below

commit a63cac24a2198a5893874cdf72946073854a8d4d
Author: Alex Petrov <[email protected]>
AuthorDate: Fri Oct 25 17:36:19 2024 -0700

    Check for splittable ranges
    Patch by Alex Petrov; reviewed by Ariel Weisberg for CASSANDRA-20032
---
 accord-core/src/main/java/accord/local/ShardDistributor.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/accord-core/src/main/java/accord/local/ShardDistributor.java 
b/accord-core/src/main/java/accord/local/ShardDistributor.java
index d2dd9da5..9a69549f 100644
--- a/accord-core/src/main/java/accord/local/ShardDistributor.java
+++ b/accord-core/src/main/java/accord/local/ShardDistributor.java
@@ -47,6 +47,7 @@ public interface ShardDistributor
     {
         public interface Splitter<T>
         {
+            default boolean splittable(Range range, int numSplits) { return 
true; }
             T sizeOf(Range range);
             Range subRange(Range range, T start, T end);
 
@@ -76,6 +77,9 @@ public interface ShardDistributor
             Invariants.checkArgument(from <= to);
             Invariants.checkArgument(to <= numSplits);
             Splitter<T> splitter = this.splitter.apply(Ranges.single(range));
+            if (!splitter.splittable(range, numSplits))
+                return range;
+
             T size = splitter.sizeOf(range);
             T splitSize = splitter.divide(size, numSplits);
             T remainder = splitter.subtract(size, splitter.multiply(splitSize, 
numSplits));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to