Skip to content

Commit

Permalink
address the comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
horizonzy committed Jan 26, 2024
1 parent 8d21ea4 commit 1b74157
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void batchReadEntries(BookieId addr, long ledgerId, long startEntryId, in
}

try {
ByteBufList data = mockBookies.batchReadEntry(addr, flags, ledgerId, startEntryId,
ByteBufList data = mockBookies.batchReadEntries(addr, flags, ledgerId, startEntryId,
maxCount, maxSize);
return FutureUtils.value(data);
} catch (BKException bke) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public ByteBuf readEntry(BookieId bookieId, int flags, long ledgerId, long entry
return entry;
}

public ByteBufList batchReadEntry(BookieId bookieId, int flags, long ledgerId, long startEntryId,
public ByteBufList batchReadEntries(BookieId bookieId, int flags, long ledgerId, long startEntryId,
int maxCount, long maxSize) throws BKException {
MockLedgerData ledger = getBookieData(bookieId).get(ledgerId);

Expand All @@ -142,24 +142,17 @@ public ByteBufList batchReadEntry(BookieId bookieId, int flags, long ledgerId, l
}
long frameSize = 24 + 8 + 4;
for (long i = startEntryId; i < startEntryId + maxCount; i++) {
try {
ByteBuf entry = ledger.getEntry(i);
frameSize += entry.readableBytes() + 4;
if (data == null) {
data = ByteBufList.get(entry);
} else {
if (frameSize > maxSize) {
entry.release();
break;
}
data.add(entry);
}
} catch (Throwable e) {
if (data == null) {
throw e;
}
break;
}
ByteBuf entry = ledger.getEntry(i);
frameSize += entry.readableBytes() + 4;
if (data == null) {
data = ByteBufList.get(entry);
} else {
if (frameSize > maxSize) {
entry.release();
break;
}
data.add(entry);
}
}
return data;
}
Expand Down

0 comments on commit 1b74157

Please sign in to comment.