divijvaidya commented on code in PR #14243:
URL: https://github.com/apache/kafka/pull/14243#discussion_r1315541873
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -110,12 +111,12 @@ public class RemoteIndexCache implements Closeable {
*
* We use {@link Caffeine} cache instead of implementing a thread safe LRU
cache on our own.
*/
- private final Cache<Uuid, Entry> internalCache;
+ private Cache<Uuid, Entry> internalCache;
Review Comment:
please move this below all the `final` member variables so that all final
variables are kept clubbed together. Helps in readibility. Please don't forget
to move the java doc along.
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -77,6 +77,7 @@ public class RemoteIndexCache implements Closeable {
private static final String TMP_FILE_SUFFIX = ".tmp";
public static final String REMOTE_LOG_INDEX_CACHE_CLEANER_THREAD =
"remote-log-index-cleaner";
public static final String DIR_NAME = "remote-log-index-cache";
+ public static final long DEFAULT_REMOTE_INDEX_CACHE_SIZE_BYTES = 1024 *
1024L;
Review Comment:
do we need this at public access?
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/RemoteIndexCache.java:
##########
@@ -669,4 +705,8 @@ public static String
remoteTransactionIndexFileName(RemoteLogSegmentMetadata rem
return generateFileNamePrefixForIndex(remoteLogSegmentMetadata) +
LogFileUtils.TXN_INDEX_FILE_SUFFIX;
}
+ public static int estimatedEntrySize(Entry entry) {
+ return entry.offsetIndex.sizeInBytes() + entry.timeIndex.sizeInBytes()
+ (int) entry.txnIndex.file().length();
Review Comment:
I should have been more clear here. Please keep
`entry.offsetIndex.sizeInBytes() + entry.timeIndex.sizeInBytes()` since this is
the most efficient way to calculate size since it's in-memory computation.
Please use Files.size() instead of `(int) entry.txnIndex.file().length();`
since txnIndex does not have a `sizeInBytes` method similar to other two.
--
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]