Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
poorbarcode committed Feb 5, 2025
1 parent 6e24c3f commit ce12cad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3853,7 +3853,7 @@ private static long estimateEntryCountBySize(long bytesSize, Position readPositi
posToRead = ml.getNextValidPosition(PositionFactory.create(posToRead.getLedgerId(), Long.MAX_VALUE));
}
}
return Math.max(result, 1); // TODO 告诉 RangeEntryCache 这次申请的预估出来的 permits。
return Math.max(result, 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
*/
public class RangeEntryCacheImpl implements EntryCache {

/**
* Overhead per-entry to take into account the envelope.
*/
public static final long BOOKKEEPER_READ_OVERHEAD_PER_ENTRY = 64;
private static final int DEFAULT_ESTIMATED_ENTRY_SIZE = 10 * 1024;
private static final boolean DEFAULT_CACHE_INDIVIDUAL_READ_ENTRY = false;

private final RangeEntryCacheManagerImpl manager;
Expand Down Expand Up @@ -407,15 +402,19 @@ void doAsyncReadEntriesByPosition(ReadHandle lh, Position firstPosition, Positio
cachedEntries.forEach(entry -> entry.release());
}

// Read all the entries from bookkeeper TODO 优化为只读部分。
// Read all the entries from bookkeeper
pendingReadsManager.readEntries(lh, firstPosition.getEntryId(), lastPosition.getEntryId(),
shouldCacheEntry, callback, ctx);
}
}

@VisibleForTesting
public long getEstimatedEntrySize(ReadHandle lh) {
return Math.max(1, lh.getLength() / lh.getLastAddConfirmed());
if (lh.getLength() == 0 || lh.getLastAddConfirmed() < 0) {
// No entries stored.
return 1;
}
return Math.max(1, lh.getLength() / (lh.getLastAddConfirmed() + 1));
}

/**
Expand Down

0 comments on commit ce12cad

Please sign in to comment.