private static int indexOf(byte[] haystack, byte needle) { return indexOf(haystack, 0, needle); }
/** * Calculate the slot from the given key. * * @param key must not be {@literal null}. * @return */ public static int calculateSlot(byte[] key) { Assert.notNull(key, "Key must not be null!"); byte[] finalKey = key; int start = indexOf(key, SUBKEY_START); if (start != -1) { int end = indexOf(key, start + 1, SUBKEY_END); if (end != -1 && end != start + 1) { finalKey = new byte[end - (start + 1)]; System.arraycopy(key, start + 1, finalKey, 0, finalKey.length); } } return crc16(finalKey) % SLOT_COUNT; }
private static int indexOf(byte[] haystack, byte needle) { return indexOf(haystack, 0, needle); }
private static int indexOf(byte[] haystack, byte needle) { return indexOf(haystack, 0, needle); }
/** * Calculate the slot from the given key. * * @param key must not be {@literal null}. * @return */ public static int calculateSlot(byte[] key) { Assert.notNull(key, "Key must not be null!"); byte[] finalKey = key; int start = indexOf(key, SUBKEY_START); if (start != -1) { int end = indexOf(key, start + 1, SUBKEY_END); if (end != -1 && end != start + 1) { finalKey = new byte[end - (start + 1)]; System.arraycopy(key, start + 1, finalKey, 0, finalKey.length); } } return crc16(finalKey) % SLOT_COUNT; }
/** * Calculate the slot from the given key. * * @param key must not be {@literal null}. * @return */ public static int calculateSlot(byte[] key) { Assert.notNull(key, "Key must not be null!"); byte[] finalKey = key; int start = indexOf(key, SUBKEY_START); if (start != -1) { int end = indexOf(key, start + 1, SUBKEY_END); if (end != -1 && end != start + 1) { finalKey = new byte[end - (start + 1)]; System.arraycopy(key, start + 1, finalKey, 0, finalKey.length); } } return crc16(finalKey) % SLOT_COUNT; }