segmentstore/server/src/main/java/io/pravega/segmentstore/server/tables/SegmentKeyCache.java
/**
     * Updates the contents of a Cache Entry associated with the given Segment Id and KeyHash. This method cannot be
     * used to remove values.
     *
     * This method should be used for processing existing keys (that have already been indexed), as opposed from processing
     * new (un-indexed) keys.
     *
     * @param keyHash       A UUID representing the Key Hash to look up.
     * @param segmentOffset The segment offset where this Key has its latest value.
     * @return Either segmentOffset, or the offset which contains the most up-to-date information about this KeyHash.
     * If this value does not equal segmentOffset, it means some other concurrent update changed this value, and that
     * value prevailed. This value could be negative (see segmentOffset doc).
     */
Updates the contents of a Cache Entry associated with the given Segment Id and KeyHash. This method cannot be
used to remove values.

This method should be used for processing existing keys (that have already been indexed), as opposed from processing
new (un-indexed) keys.

@param keyHash       A UUID representing the Key Hash to look up.
@param segmentOffset The segment offset where this Key has its latest value.
@return Either segmentOffset, or the offset which contains the most up-to-date information about this KeyHash.
If this value does not equal segmentOffset, it means some other concurrent update changed this value, and that
value prevailed. This value could be negative .
Updates the contents of a Cache Entry associated with the given Segment Id and KeyHash . This method cannot be used to remove values . This method should be used for processing existing keys ( that have already been indexed ) as opposed from processing new ( un - indexed ) keys . @param keyHash A UUID representing the Key Hash to look up . @param segmentOffset The segment offset where this Key has its latest value . @return Either segmentOffset or the offset which contains the most up - to - date information about this KeyHash . If this value does not equal segmentOffset it means some other concurrent update changed this value and that value prevailed . This value could be negative .
long includeExistingKey(UUID keyHash, long segmentOffset, int generation) {
        Preconditions.checkArgument(segmentOffset >= 0, "segmentOffset must be non-negative.");
        short hashGroup = getHashGroup(keyHash);
        CacheEntry entry;
        synchronized (this) {
            CacheBucketOffset tailOffset = this.tailOffsets.get(keyHash);
            if (tailOffset != null && tailOffset.getSegmentOffset() >= segmentOffset) {
                return tailOffset.getSegmentOffset();
            }
            entry = this.cacheEntries.computeIfAbsent(hashGroup, hg -> new CacheEntry(hashGroup, generation));
        }
        if (!entry.update(keyHash, segmentOffset, generation)) {
            evictEntry(entry);
        }
        return segmentOffset;
    }
long includeExistingKey ( UUID keyHash , long segmentOffset , int generation ) { Preconditions . checkArgument ( segmentOffset >= 0 , "segmentOffset must be non-negative." ) ; short hashGroup = getHashGroup ( keyHash ) ; CacheEntry entry ; synchronized ( this ) { CacheBucketOffset tailOffset = this . tailOffsets . get ( keyHash ) ; if ( tailOffset != null && tailOffset . getSegmentOffset ( ) >= segmentOffset ) { return tailOffset . getSegmentOffset ( ) ; } entry = this . cacheEntries . computeIfAbsent ( hashGroup , hg -> new CacheEntry ( hashGroup , generation ) ) ; } if ( ! entry . update ( keyHash , segmentOffset , generation ) ) { evictEntry ( entry ) ; } return segmentOffset ; }
Updates the contents of a Cache Entry associated with the given Segment Id and KeyHash.
Updates the contents of a Cache Entry associated with the given Segment Id and KeyHash .
// There already exists a higher offset for this Key Hash. No need to do more. // Update the cache entry directly.