Browse Source

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
stable-4.2
Jonathan Nieder 9 years ago
parent
commit
86af34e150
  1. 22
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

22
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java

@ -93,17 +93,6 @@ public class BitmapIndexImpl implements BitmapIndex {
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 @@ public class BitmapIndexImpl implements BitmapIndex {
}
}
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;
}

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

@ -60,6 +60,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
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 @@ class PackWriterBitmapPreparer {
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));
}
}

Loading…
Cancel
Save