@ Override final int findKey ( final byte [ ] key ) { final int keyLen = key . length ; 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 ; } if ( arraysEqual ( key , 0 , keysArr_ , entryIndex * keyLen , keyLen ) ) { //check for key match return entryIndex ; } entryIndex = ( entryIndex + stride ) % tableEntries_ ; } while ( entryIndex != loopIndex ) ; throw new SketchesArgumentException ( "Key not found and no empty slots!" ) ; }
Returns the entry index for the given key given the array of keys if found . Otherwise returns the one s complement of first empty entry found ;