Make BitmapIndexImpl.CompressedBitmap public

PackWriterBitmapPreparer (which is in another package) is already well
aware of the mapping between EWAHCompressedBitmaps and the
higher-level CompressedBitmap objects of the BitmapIndexImpl API.
Making the CompressedBitmap type public makes the translation more
obvious and wouldn't break any abstractions that aren't already
broken.  So expose it.

This is all under org.eclipse.jgit.internal so there are no API
stability guarantees --- we can change the API if internals change
(for example if some day there are bitmaps spanning multiple packs).

In particular this means the confusing toBitmap helper can be removed.

Change-Id: Ifb2e8804a6d5ee46e82a76d276c4f8507eaa2a4c
This commit is contained in:
Jonathan Nieder 2015-11-09 08:48:46 -08:00
parent 683bd09092
commit 86af34e150
2 changed files with 11 additions and 14 deletions

View File

@ -93,17 +93,6 @@ public CompressedBitmap getBitmap(AnyObjectId objectId) {
return new CompressedBitmap(compressed, this);
}
public CompressedBitmap toBitmap(PackBitmapIndex i,
EWAHCompressedBitmap b) {
if (i != packIndex) {
throw new IllegalArgumentException();
}
if (b == null) {
return null;
}
return new CompressedBitmap(b, this);
}
@Override
public CompressedBitmapBuilder newBitmapBuilder() {
return new CompressedBitmapBuilder(this);
@ -327,11 +316,18 @@ private EWAHCompressedBitmap ewahBitmap(Bitmap other) {
}
}
static final class CompressedBitmap implements Bitmap {
/**
* Wrapper for a {@link EWAHCompressedBitmap} and {@link PackBitmapIndex}.
* <p>
* For a EWAHCompressedBitmap {@code bitmap} representing a vector of
* bits, {@code new CompressedBitmap(bitmap, bitmapIndex)} represents the
* objects at those positions in {@code bitmapIndex.packIndex}.
*/
public static final class CompressedBitmap implements Bitmap {
final EWAHCompressedBitmap bitmap;
final BitmapIndexImpl bitmapIndex;
CompressedBitmap(EWAHCompressedBitmap bitmap, BitmapIndexImpl bitmapIndex) {
public CompressedBitmap(EWAHCompressedBitmap bitmap, BitmapIndexImpl bitmapIndex) {
this.bitmap = bitmap;
this.bitmapIndex = bitmapIndex;
}

View File

@ -60,6 +60,7 @@
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl;
import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.CompressedBitmap;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexRemapper;
@ -390,7 +391,7 @@ private CommitSelectionHelper setupTipCommitBitmaps(RevWalk rw,
if (!reuse.contains(rc)) {
EWAHCompressedBitmap bitmap = bitmapRemapper.ofObjectType(
bitmapRemapper.getBitmap(rc), Constants.OBJ_COMMIT);
reuse.or(commitBitmapIndex.toBitmap(writeBitmaps, bitmap));
reuse.or(new CompressedBitmap(bitmap, commitBitmapIndex));
}
}