@Test public void testNormal() throws Exception { for (int i = 0; i < 100000; i++) { int partitionNo = strategy.computePartitionNo(generateRandomString(100), 5); assertTrue(partitionNo < 5); assertTrue(partitionNo >= 0); } }
@Override public int computePartitionNo(String key, int partitionCount) { if (key == null) { return m_random.nextInt(Integer.MAX_VALUE) % partitionCount; } else { return (key.hashCode() == Integer.MIN_VALUE ? 0 : Math.abs(key.hashCode())) % partitionCount; } }
HashPartitioningStrategy implements PartitioningStrategy { @Override public int computePartitionNo(String key, int partitionCount) { if (key == null) { return m_random.nextInt(Integer.MAX_VALUE) % partitionCount; } else { return (key.hashCode() == Integer.MIN_VALUE ? 0 : Math.abs(key.hashCode())) % partitionCount; } } }
HashPartitioningStrategy implements PartitioningStrategy { @Override public int computePartitionNo(String key, int partitionCount) { if (key == null) { return m_random.nextInt(Integer.MAX_VALUE) % partitionCount; } else { return (key.hashCode() == Integer.MIN_VALUE ? 0 : Math.abs(key.hashCode())) % partitionCount; } }  }
HashPartitioningStrategy implements PartitioningStrategy { @Override public int computePartitionNo(String key, int partitionCount) { if (key == null) { return m_random.nextInt(Integer.MAX_VALUE) % partitionCount; } else { return (key.hashCode() == Integer.MIN_VALUE ? 0 : Math.abs(key.hashCode())) % partitionCount; } }  @Override int computePartitionNo(String key, int partitionCount); }
HashPartitioningStrategy implements PartitioningStrategy { @Override public int computePartitionNo(String key, int partitionCount) { if (key == null) { return m_random.nextInt(Integer.MAX_VALUE) % partitionCount; } else { return (key.hashCode() == Integer.MIN_VALUE ? 0 : Math.abs(key.hashCode())) % partitionCount; } }  @Override int computePartitionNo(String key, int partitionCount);  }