diff options
author | Sam Delmerico <delmerico@google.com> | 2024-04-10 11:03:46 -0700 |
---|---|---|
committer | Sam Delmerico <delmerico@google.com> | 2024-04-12 08:26:30 -0700 |
commit | 1790ff518bf786de8e4ced6fc9dd59d026c9ea77 (patch) | |
tree | 88ab666915bc06a14c0dd4d3272926abfe2cd0cb /org.eclipse.jgit | |
parent | 735dc893638531c00355c81ec87459cb2f8661e9 (diff) | |
download | jgit-1790ff518bf786de8e4ced6fc9dd59d026c9ea77.tar.gz jgit-1790ff518bf786de8e4ced6fc9dd59d026c9ea77.zip |
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
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java | 20 |
1 files changed, 16 insertions, 4 deletions
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 7646c1909b..1da805503d 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 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { 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 class PackBitmapIndexBuilder extends BasePackBitmapIndex { /** 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 class PackBitmapIndexBuilder extends BasePackBitmapIndex { /** * 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 class PackBitmapIndexBuilder extends BasePackBitmapIndex { * @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 class PackBitmapIndexBuilder extends BasePackBitmapIndex { 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 { |