segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/SegmentKeyCache.java
/**
         * Locates the offset of the given Key Hash in the given Cache Entry data.
         *
         * @param keyHash The Key Hash to look up.
         * @param data    The array to look into.
         * @return The offset of the CacheValue associated with the KeyHash, or -1 if not found.
         */
Locates the offset of the given Key Hash in the given Cache Entry data.
@param keyHash The Key Hash to look up.
@param data    The array to look into.
@return The offset of the CacheValue associated with the KeyHash, or -1 if not found.
Locates the offset of the given Key Hash in the given Cache Entry data . @param keyHash The Key Hash to look up . @param data The array to look into . @return The offset of the CacheValue associated with the KeyHash or - 1 if not found .
private int locate(UUID keyHash, ArrayView data) {
            if (data != null && data.getLength() > 0) {
                final int count = data.getInt(0);
                int offset = Integer.BYTES;
                for (int i = 0; i < count; i++) {
                    boolean match = keyHash.getMostSignificantBits() == data.getLong(offset)
                            && keyHash.getLeastSignificantBits() == data.getLong(offset + Long.BYTES);
                    if (match) {
                        return offset + HASH_LENGTH; 
                    }
                    offset += HASH_LENGTH + VALUE_SERIALIZATION_LENGTH;
                }
            }
            return -1;
        }
private int locate ( UUID keyHash , ArrayView data ) { if ( data != null && data . getLength ( ) > 0 ) { final int count = data . getInt ( 0 ) ; int offset = Integer . BYTES ; for ( int i = 0 ; i < count ; i ++ ) { boolean match = keyHash . getMostSignificantBits ( ) == data . getLong ( offset ) && keyHash . getLeastSignificantBits ( ) == data . getLong ( offset + Long . BYTES ) ; if ( match ) { return offset + HASH_LENGTH ; } offset += HASH_LENGTH + VALUE_SERIALIZATION_LENGTH ; } } return - 1 ; }
Locates the offset of the given Key Hash in the given Cache Entry data.
Locates the offset of the given Key Hash in the given Cache Entry data .
// Check if the sought key matches the key at this index. // We return the offset of the value, not the key. // No match; skip to the next entry.