Merge "PackBitmapIndex: Not buffer inflated bitmap during bitmap creation."

This commit is contained in:
Terry Parker 2020-06-19 21:23:56 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 641069971d
2 changed files with 17 additions and 3 deletions

View File

@ -59,12 +59,26 @@ static final class StoredBitmap extends ObjectIdOwnerMap.Entry {
* @return the full bitmap
*/
EWAHCompressedBitmap getBitmap() {
EWAHCompressedBitmap bitmap = getBitmapWithoutCaching();
// Cache the result.
bitmapContainer = bitmap;
return bitmap;
}
/**
* Compute and return the full bitmap, do NOT cache the expanded bitmap,
* which saves memory and should only be used during bitmap creation in
* garbage collection.
*
* @return the full bitmap
*/
EWAHCompressedBitmap getBitmapWithoutCaching() {
// Fast path to immediately return the expanded result.
Object r = bitmapContainer;
if (r instanceof EWAHCompressedBitmap)
return (EWAHCompressedBitmap) r;
// Expand the bitmap and cache the result.
// Expand the bitmap but not cache the result.
XorCompressedBitmap xb = (XorCompressedBitmap) r;
EWAHCompressedBitmap out = xb.bitmap;
for (;;) {
@ -72,7 +86,6 @@ EWAHCompressedBitmap getBitmap() {
if (r instanceof EWAHCompressedBitmap) {
out = out.xor((EWAHCompressedBitmap) r);
out.trim();
bitmapContainer = out;
return out;
}
xb = (XorCompressedBitmap) r;

View File

@ -156,7 +156,8 @@ public EWAHCompressedBitmap getBitmap(AnyObjectId objectId) {
return null;
inflated.clear();
for (IntIterator i = oldBitmap.getBitmap().intIterator(); i.hasNext();)
for (IntIterator i = oldBitmap.getBitmapWithoutCaching()
.intIterator(); i.hasNext();)
inflated.set(prevToNewMapping[i.next()]);
bitmap = inflated.toEWAHCompressedBitmap();
bitmap.trim();