diff --git a/s3stream/src/main/java/com/automq/stream/s3/index/LocalStreamRangeIndexCache.java b/s3stream/src/main/java/com/automq/stream/s3/index/LocalStreamRangeIndexCache.java index 2e4cb02b07..86d3abc770 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/index/LocalStreamRangeIndexCache.java +++ b/s3stream/src/main/java/com/automq/stream/s3/index/LocalStreamRangeIndexCache.java @@ -274,7 +274,7 @@ public static ByteBuf toBuffer(Map streamRangeIndexMap) + Integer.BYTES // stream num + streamRangeIndexMap.values().stream().mapToInt(index -> Long.BYTES // stream id + Integer.BYTES // range index num - + index.getRangeIndexList().size() * RangeIndex.SIZE).sum(); + + index.getRangeIndexList().size() * (3 * Long.BYTES)).sum(); ByteBuf buffer = ByteBufAlloc.byteBuffer(capacity); try { buffer.writeShort(VERSION); diff --git a/s3stream/src/main/java/com/automq/stream/s3/index/NodeRangeIndexCache.java b/s3stream/src/main/java/com/automq/stream/s3/index/NodeRangeIndexCache.java index b1306c6c66..b092c97872 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/index/NodeRangeIndexCache.java +++ b/s3stream/src/main/java/com/automq/stream/s3/index/NodeRangeIndexCache.java @@ -87,7 +87,7 @@ public CompletableFuture searchObjectId(long streamId, long startOffset) { public synchronized CompletableFuture size() { if (sizeCf == null) { sizeCf = this.streamRangeIndexMapCf.thenApply(v -> v.values().stream() - .mapToInt(rangeIndices -> Long.BYTES + ZGC_OBJECT_HEADER_SIZE_BYTES + rangeIndices.size() * RangeIndex.SIZE).sum()); + .mapToInt(rangeIndices -> Long.BYTES + ZGC_OBJECT_HEADER_SIZE_BYTES + rangeIndices.size() * RangeIndex.OBJECT_SIZE).sum()); } return sizeCf; } diff --git a/s3stream/src/main/java/com/automq/stream/s3/index/RangeIndex.java b/s3stream/src/main/java/com/automq/stream/s3/index/RangeIndex.java index 168f4df6d0..a6548a2e68 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/index/RangeIndex.java +++ b/s3stream/src/main/java/com/automq/stream/s3/index/RangeIndex.java @@ -14,7 +14,7 @@ import com.google.common.base.Objects; public class RangeIndex implements Comparable { - public static final int SIZE = 3 * Long.BYTES + NodeRangeIndexCache.ZGC_OBJECT_HEADER_SIZE_BYTES; + public static final int OBJECT_SIZE = 3 * Long.BYTES + NodeRangeIndexCache.ZGC_OBJECT_HEADER_SIZE_BYTES; private final long startOffset; private final long endOffset; private final long objectId; diff --git a/s3stream/src/test/java/com/automq/stream/s3/index/NodeRangeIndexCacheTest.java b/s3stream/src/test/java/com/automq/stream/s3/index/NodeRangeIndexCacheTest.java index c856513cd1..934f5bcc09 100644 --- a/s3stream/src/test/java/com/automq/stream/s3/index/NodeRangeIndexCacheTest.java +++ b/s3stream/src/test/java/com/automq/stream/s3/index/NodeRangeIndexCacheTest.java @@ -111,7 +111,7 @@ private List createRangeIndex(int size) { int curr = 0; while (curr < size) { index.add(new RangeIndex(0, 0, 0)); - curr += RangeIndex.SIZE; + curr += RangeIndex.OBJECT_SIZE; } return index; }