Skip to content

Commit

Permalink
HBASE-28821: Optimise the memory-utilisation during persistence of bu…
Browse files Browse the repository at this point in the history
…cketcache. (#6215)

Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
  • Loading branch information
jhungund authored Sep 11, 2024
1 parent 9df0825 commit f8182f5
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ public static void serializeAsPB(BucketCache cache, FileOutputStream fos, long c
fos.write(Bytes.toBytes(chunkSize));
fos.write(Bytes.toBytes(numChunks));

BucketCacheProtos.BackingMapEntry.Builder entryBuilder =
BucketCacheProtos.BackingMapEntry.newBuilder();
for (Map.Entry<BlockCacheKey, BucketEntry> entry : cache.backingMap.entrySet()) {
blockCount++;
builder.addEntry(
BucketCacheProtos.BackingMapEntry.newBuilder().setKey(BucketProtoUtils.toPB(entry.getKey()))
.setValue(BucketProtoUtils.toPB(entry.getValue())).build());
entryBuilder.clear();
entryBuilder.setKey(BucketProtoUtils.toPB(entry.getKey()));
entryBuilder.setValue(BucketProtoUtils.toPB(entry.getValue()));
builder.addEntry(entryBuilder.build());

if (blockCount % chunkSize == 0 || (blockCount == backingMapSize)) {
chunkCount++;
if (chunkCount == 1) {
Expand All @@ -88,7 +92,7 @@ public static void serializeAsPB(BucketCache cache, FileOutputStream fos, long c
builder.build().writeDelimitedTo(fos);
}
if (blockCount < backingMapSize) {
builder = BucketCacheProtos.BackingMap.newBuilder();
builder.clear();
}
}
}
Expand Down

0 comments on commit f8182f5

Please sign in to comment.