Make retrieveCompressed() a method of Bitmap interface to avoid type casting and later reuse in improving the memory footprint of GC's bitmap generation phase. Change-Id: I098d85105cf17af845d43b8c71b4ca48b02fd7da Signed-off-by: Yunjie Li <yunjieli@google.com>tags/v5.8.0.202006091008-r
@@ -252,6 +252,11 @@ public class BitmapIndexImpl implements BitmapIndex { | |||
return bitmapIndex; | |||
} | |||
@Override | |||
public EWAHCompressedBitmap retrieveCompressed() { | |||
return build().retrieveCompressed(); | |||
} | |||
private EWAHCompressedBitmap ewahBitmap(Bitmap other) { | |||
if (other instanceof CompressedBitmap) { | |||
CompressedBitmap b = (CompressedBitmap) other; | |||
@@ -372,7 +377,8 @@ public class BitmapIndexImpl implements BitmapIndex { | |||
}; | |||
} | |||
EWAHCompressedBitmap getEwahCompressedBitmap() { | |||
@Override | |||
public EWAHCompressedBitmap retrieveCompressed() { | |||
return bitmap; | |||
} | |||
@@ -17,11 +17,9 @@ import java.util.List; | |||
import java.util.NoSuchElementException; | |||
import org.eclipse.jgit.internal.JGitText; | |||
import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.CompressedBitmap; | |||
import org.eclipse.jgit.internal.storage.pack.ObjectToPack; | |||
import org.eclipse.jgit.lib.AnyObjectId; | |||
import org.eclipse.jgit.lib.BitmapIndex.Bitmap; | |||
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; | |||
import org.eclipse.jgit.lib.Constants; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.ObjectIdOwnerMap; | |||
@@ -134,16 +132,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { | |||
* the flags to be stored with the bitmap | |||
*/ | |||
public void addBitmap(AnyObjectId objectId, Bitmap bitmap, int flags) { | |||
if (bitmap instanceof BitmapBuilder) | |||
bitmap = ((BitmapBuilder) bitmap).build(); | |||
EWAHCompressedBitmap compressed; | |||
if (bitmap instanceof CompressedBitmap) | |||
compressed = ((CompressedBitmap) bitmap).getEwahCompressedBitmap(); | |||
else | |||
throw new IllegalArgumentException(bitmap.getClass().toString()); | |||
addBitmap(objectId, compressed, flags); | |||
addBitmap(objectId, bitmap.retrieveCompressed(), flags); | |||
} | |||
/** |
@@ -14,6 +14,8 @@ import java.util.Iterator; | |||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndex; | |||
import com.googlecode.javaewah.EWAHCompressedBitmap; | |||
/** | |||
* A compressed bitmap representation of the entire object graph. | |||
* | |||
@@ -81,6 +83,14 @@ public interface BitmapIndex { | |||
*/ | |||
@Override | |||
Iterator<BitmapObject> iterator(); | |||
/** | |||
* Returns the corresponding raw compressed EWAH bitmap of the bitmap. | |||
* | |||
* @return the corresponding {@code EWAHCompressedBitmap} | |||
* @since 5.8 | |||
*/ | |||
EWAHCompressedBitmap retrieveCompressed(); | |||
} | |||
/** |