From 86af34e150ab58d454eb6c13ffe40a3fe94fdb1b Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 9 Nov 2015 08:48:46 -0800 Subject: [PATCH] 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 --- .../storage/file/BitmapIndexImpl.java | 22 ++++++++----------- .../pack/PackWriterBitmapPreparer.java | 3 ++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java index 3873c3728..2c4af7068 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java @@ -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}. + *

+ * 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; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java index 63da51879..77311abaa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java @@ -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)); } }