Skip to content

Commit

Permalink
fix(metadata): fix sparse index serialization capacity (#1814)
Browse files Browse the repository at this point in the history
Signed-off-by: Shichao Nie <[email protected]>
  • Loading branch information
SCNieh authored Aug 15, 2024
1 parent 02e7bab commit 34eb8c1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static ByteBuf toBuffer(Map<Long, SparseRangeIndex> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public CompletableFuture<Long> searchObjectId(long streamId, long startOffset) {
public synchronized CompletableFuture<Integer> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.google.common.base.Objects;

public class RangeIndex implements Comparable<RangeIndex> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private List<RangeIndex> 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;
}
Expand Down

0 comments on commit 34eb8c1

Please sign in to comment.