### Question:
SaltingUtil { public static byte getSaltingByte(byte[] value, int offset, int length, int bucketNum) { int hash = calculateHashCode(value, offset, length); return (byte) Math.abs(hash % bucketNum); }  static List<KeyRange> generateAllSaltingRanges(int bucketNum); static byte[][] getSalteByteSplitPoints(int saltBucketNum); static byte[] getSaltedKey(ImmutableBytesWritable key, int bucketNum); static byte getSaltingByte(byte[] value, int offset, int length, int bucketNum); static KeyRange addSaltByte(byte[] startKey, KeyRange minMaxRange); static void addRegionStartKeyToScanStartAndStopRows(byte[] startKey, byte[] endKey, Scan scan); static final int NUM_SALTING_BYTES; static final Integer MAX_BUCKET_NUM; static final String SALTING_COLUMN_NAME; static final String SALTED_ROW_KEY_NAME; static final PColumnImpl SALTING_COLUMN; static final RowKeySchema VAR_BINARY_SALTED_SCHEMA; }### Answer:
@Test public void testGetSaltingByte() { Set<Byte> saltBytes = Sets.newHashSet(); for (int i = 0; i < 100; i++) { saltBytes.add(SaltingUtil.getSaltingByte(Bytes.toBytes(i), 0, Bytes.SIZEOF_INT, 3)); } assertEquals(ImmutableSet.of((byte)0, (byte)1, (byte)2), saltBytes); }
@Test public void testGetSaltingByte_EdgeCaseHashCode() { byte[] rowKey = new byte[] { -106, 0, -10, 0, 19, -2 }; byte saltingByte = SaltingUtil.getSaltingByte(rowKey, 0, rowKey.length, 3); assertTrue("Salting byte should be 0 or 1 or 2 but was " + saltingByte, ImmutableSet.of((byte)0, (byte)1, (byte)2).contains(saltingByte)); }