Copilot commented on code in PR #8325:
URL: https://github.com/apache/hbase/pull/8325#discussion_r3406089791
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessService.java:
##########
@@ -444,4 +448,72 @@ default void notifyFileCachingCompleted(Path fileName, int
totalBlockCount, int
long size) {
// noop
}
+
+ /**
+ * Executes the supplied action when this cache service is enabled.
+ * <p>
+ * This helper is intended to preserve the old {@code
getBlockCache().ifPresent(...)} style for
+ * call sites that should do nothing when block cache is disabled. It keeps
callers independent of
+ * concrete implementations such as {@code NoOpCacheAccessService} while
still allowing disabled
+ * cache wiring to behave like an absent cache.
+ * </p>
+ * <p>
+ * Implementations normally do not need to override this method. The default
implementation checks
+ * {@link #isCacheEnabled()} and invokes the supplied action only when cache
access is enabled.
+ * </p>
+ * @param action action to execute with this cache service when enabled
+ */
+ default void ifEnabled(Consumer<CacheAccessService> action) {
+ Objects.requireNonNull(action, "action must not be null");
+ if (isCacheEnabled()) {
+ action.accept(this);
+ }
+ }
+
+ /**
+ * Returns whether blocks from the given HFile should be cached. TODO: this
method is a temporary
+ * adapter for file-level admission decisions. It will be removed and
replaced by a more general
+ * admission API in the future.
+ * <p>
+ * This is a file-level admission hook used by cache population paths.
Implementations may use
+ * file metadata, configuration, data tiering state, or
implementation-specific bookkeeping to
+ * decide whether the file should be admitted into cache.
+ * </p>
+ * <p>
+ * The returned {@link Optional} is empty when the cache service does not
support file-level
+ * admission decisions. In that case, callers should preserve existing
default behavior, typically
+ * treating the result as "no opinion" rather than as a rejection.
+ * </p>
+ * @param hFileInfo HFile metadata used for the admission decision
+ * @param conf configuration
+ * @return empty if unsupported; otherwise whether the file should be cached
+ */
+ default Optional<Boolean> shouldCacheFile(HFileInfo hFileInfo, Configuration
conf) {
+ return Optional.empty();
+ }
+
+ /**
+ * Returns whether the block represented by the given key and timestamp
should be cached. TODO:
+ * this method is a temporary adapter for file-level admission decisions. It
will be removed and
+ * replaced by a more general admission API in the future.
+ * <p>
+ * <p>
+ * This is a block-level admission hook used by cache population paths.
Implementations may use
Review Comment:
Javadoc for shouldCacheBlock has a copy/paste error (mentions "file-level"
admission for a block-level hook) and contains a duplicate `<p>` tag, which
makes the generated Javadoc confusing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]