PackBitmapIndexBuilder.StoredEntry: add getter for objectId If you only have access to the PackBitmapIndexBuilder there is no way to get the ObjectId from a StoredEntry instance without also having access to a reverse pack index. The StoredEntry can provide the idxPosition, but the PackBitmapIndexBuilder's getObject method requires a ridxPosition in order to find an ObjectId. Providing an ObjectId from the StoredEntry gives this information directly and also allows a caller to get the ridxPosition if desired by calling PackBitmapIndexBuilder.findPosition(objectId) without needing an index object. This closes the operations of the PackBitmapIndexBuilder such that any method can be called by using information provided by the other methods. Change-Id: I5a11479b9635cd6b5e7aaff2f862cd41069ac469
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java index 7646c19..1da8055 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
@@ -191,8 +191,8 @@ private StoredEntry generateStoredEntry(StoredBitmap bitmapToWrite) { throw new IllegalStateException(); } bestBitmap.trim(); - StoredEntry result = new StoredEntry(entry.idxPosition, bestBitmap, - bestXorOffset, bitmapToWrite.getFlags()); + StoredEntry result = new StoredEntry(entry, entry.idxPosition, + bestBitmap, bestXorOffset, bitmapToWrite.getFlags()); return result; } @@ -330,6 +330,8 @@ public List<StoredEntry> getCompressedBitmaps() { /** Data object for the on disk representation of a bitmap entry. */ public static final class StoredEntry { + private final ObjectId objectId; + private final long idxPosition; private final EWAHCompressedBitmap bitmap; @@ -341,6 +343,8 @@ public static final class StoredEntry { /** * Create a StoredEntry * + * @param objectId + * objectId of the object associated with the bitmap * @param idxPosition * position of this object into the pack index (i.e. sorted * by sha1) @@ -353,8 +357,9 @@ public static final class StoredEntry { * @param flags * flags for this bitmap */ - public StoredEntry(long idxPosition, EWAHCompressedBitmap bitmap, - int xorOffset, int flags) { + public StoredEntry(ObjectId objectId, long idxPosition, + EWAHCompressedBitmap bitmap, int xorOffset, int flags) { + this.objectId = objectId; this.idxPosition = idxPosition; this.bitmap = bitmap; this.xorOffset = xorOffset; @@ -395,6 +400,13 @@ public int getFlags() { public long getIdxPosition() { return idxPosition; } + + /** + * @return the objectId of the object associated with this bitmap + */ + public ObjectId getObjectId() { + return objectId; + } } private static final class PositionEntry extends ObjectIdOwnerMap.Entry {