dcapwell commented on code in PR #3835:
URL: https://github.com/apache/cassandra/pull/3835#discussion_r1931175924


##########
test/unit/accord/utils/Gens.java:
##########
@@ -336,24 +507,70 @@ public static <T> Gen<Gen<T>> mixedDistribution(T... list)
     public static <T> Gen<Gen<T>> mixedDistribution(List<T> list)
     {
         return rs -> {
-            switch (rs.nextInt(0, 2))
+            switch (rs.nextInt(0, 4))
             {
                 case 0: // uniform
                     return r -> list.get(rs.nextInt(0, list.size()));
-                case 1: // zipf
+                case 1: // median biased
+                    int median = rs.nextInt(0, list.size());
+                    return r -> list.get(r.nextBiasedInt(0, median, 
list.size()));
+                case 2: // zipf
                     List<T> array = list;
                     if (rs.nextBoolean())
                     {
                         array = new ArrayList<>(list);
                         Collections.reverse(array);
                     }
                     return pickZipf(array);
+                case 3: // random weight
+                    return randomWeights(list).next(rs);
                 default:
                     throw new AssertionError();
             }
         };
     }
 
+    public static <T> Gen<Gen.IntGen> mixedDistribution(int[] list)
+    {
+        return rs -> {
+            switch (rs.nextInt(0, 4))
+            {
+                case 0: // uniform
+                    return r -> list[rs.nextInt(0, list.length)];
+                case 1: // median biased
+                    int median = rs.nextInt(0, list.length);
+                    return r -> list[r.nextBiasedInt(0, median, list.length)];
+                case 2: // zipf
+                    int[] array = list;
+                    if (rs.nextBoolean())
+                    {
+                        array = Arrays.copyOf(array, array.length);
+                        reverse(array);
+                    }
+                    return pickZipf(array);
+                case 3: // random weight
+                    return randomWeights(list).next(rs);
+                default:
+                    throw new AssertionError();
+            }
+        };
+    }
+
+    /**
+     * This is a change from accord as that uses {@link 
accord.utils.Utils#reverse}, which doesn't exist in this forward port.

Review Comment:
   this is the only change... i didn't want to bring in `Utils` and add more 
conflict with cep-15-accord... so in-lined... when accord merges this whole 
file will go away...



-- 
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]


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

Reply via email to