private static final int findEmpty ( final byte [ ] key , final int tableEntries , final byte [ ] stateArr ) { final long [ ] hash = MurmurHash3 . hash ( key , SEED ) ; int entryIndex = getIndex ( hash [ 0 ] , tableEntries ) ; final int stride = getStride ( hash [ 1 ] , tableEntries ) ; final int loopIndex = entryIndex ; do { if ( isBitClear ( stateArr , entryIndex ) ) { //check if slot is empty return entryIndex ; } entryIndex = ( entryIndex + stride ) % tableEntries ; } while ( entryIndex != loopIndex ) ; throw new SketchesArgumentException ( "No empty slots." ) ; }
Find the first empty slot for the given key . Only used by resize where it is known that the key does not exist in the table . Throws an exception if no empty slots .