dcapwell commented on code in PR #65:
URL: https://github.com/apache/cassandra-accord/pull/65#discussion_r1443501284


##########
accord-core/src/test/java/accord/burn/BurnTest.java:
##########
@@ -217,21 +254,41 @@ static void burn(RandomSource random, TopologyFactory 
topologyFactory, List<Id>
                     .asLongSupplier(forked);
         };
 
-        Verifier verifier = createVerifier(keyCount);
-        SimulatedDelayedExecutorService globalExecutor = new 
SimulatedDelayedExecutorService(queue, null);
-
+        SimulatedDelayedExecutorService globalExecutor = new 
SimulatedDelayedExecutorService(queue, new ListAgent(1000L, failures::add, 
retryBootstrap, (i1, i2) -> {
+            throw new IllegalAccessError("Global executor should enver get a 
stale event");
+        }));
+        Int2ObjectHashMap<Verifier> validators = new Int2ObjectHashMap<>();
         Function<CommandStore, AsyncExecutor> executor = ignore -> 
globalExecutor;
 
         MessageListener listener = MessageListener.get();
 
-        Packet[] requests = toArray(generate(random, listener, executor, 
clients, nodes, keyCount, operations), Packet[]::new);
+        if (keyCount > ((long) HASH_RANGE_END - (long) HASH_RANGE_START + 1L))
+            throw new AssertionError(String.format("Attempted to create %d 
keys which is larger than the range (%d, %d]", keyCount, HASH_RANGE_START, 
HASH_RANGE_END));
+        int[] keys = new int[keyCount];
+        {
+            IntHashSet seen = new IntHashSet();
+            for (int i = 0; i < keyCount; i++)
+            {
+                int hash;
+                do
+                {
+                    // start is exclusive, and end is inclusive; which is the 
oposite of nextInt, so +1 to account for this
+                    hash = 1 + random.nextInt(HASH_RANGE_START, 
HASH_RANGE_END);
+                }
+                while (!seen.add(hash));
+                keys[i] = CRCUtils.reverseCRC32LittleEnding(hash);

Review Comment:
   > I don't think we need to use the same hashing behaviour between tests 
though?
   
   Agree
   
   > It would be nicer to support hash collisions IMO
   
   Let me take a look at this again.  The reason for this line `keys[i] = 
CRCUtils.reverseCRC32LittleEnding(hash);` was to try to respect `keyCount` (I 
interpret as number of unique keys to test again) and the limited hash range 
you had desired.  Since `PrefixedIntHashKey` uses crc32 for the hashing and 
doesn't mod like the other hash impl, the only way to limit the hash range 
would be to reverse the hash to get the keys.



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