diff options
author | Sam Delmerico <delmerico@google.com> | 2024-04-09 16:56:38 -0700 |
---|---|---|
committer | Sam Delmerico <delmerico@google.com> | 2024-04-12 08:26:19 -0700 |
commit | 735dc893638531c00355c81ec87459cb2f8661e9 (patch) | |
tree | c9bd20532f84babe791e32529aeadeb9c31ca613 /org.eclipse.jgit/src | |
parent | 718d121bb38860e66f6e34a4045aa6d5d9490e8a (diff) | |
download | jgit-735dc893638531c00355c81ec87459cb2f8661e9.tar.gz jgit-735dc893638531c00355c81ec87459cb2f8661e9.zip |
PackBitmapIndex: clarify naming of getObject inputs
The documentation for the getObject function seems to be a little
outdated. This commit clarifies that this function accepts an offset
based on the ordering of objects in the pack.
Change-Id: Icffaf4fb72155c415f5fd248e721cab87a1a083e
Diffstat (limited to 'org.eclipse.jgit/src')
3 files changed, 24 insertions, 19 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java index 4c3f6c1eb4..cbda8fc77c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java @@ -154,7 +154,9 @@ public interface PackBitmapIndex { * Get the object at the bitmap position. * * @param position - * the id for which the object will be found. + * the offset in the bitmap which corresponds to an object of + * interest. This position is the same as the order of the object + * in the {@link PackFile}. * @return the ObjectId. * @throws java.lang.IllegalArgumentException * when the item is not found. 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 03d6948e90..7646c1909b 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 @@ -106,7 +106,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { .signum(a.getOffset() - b.getOffset())); for (int i = 0; i < entries.size(); i++) { PositionEntry e = positionEntries.get(entries.get(i)); - e.offsetPosition = i; + e.ridxPosition = i; byOffset.add(e); } } @@ -191,7 +191,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { throw new IllegalStateException(); } bestBitmap.trim(); - StoredEntry result = new StoredEntry(entry.namePosition, bestBitmap, + StoredEntry result = new StoredEntry(entry.idxPosition, bestBitmap, bestXorOffset, bitmapToWrite.getFlags()); return result; @@ -235,7 +235,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { PositionEntry entry = positionEntries.get(objectId); if (entry == null) return -1; - return entry.offsetPosition; + return entry.ridxPosition; } @Override @@ -330,16 +330,20 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { /** Data object for the on disk representation of a bitmap entry. */ public static final class StoredEntry { - private final long objectId; + private final long idxPosition; + private final EWAHCompressedBitmap bitmap; + private final int xorOffset; + private final int flags; /** * Create a StoredEntry * - * @param objectId - * offset of this object into the pack index + * @param idxPosition + * position of this object into the pack index (i.e. sorted + * by sha1) * @param bitmap * bitmap associated with this object * @param xorOffset @@ -349,9 +353,9 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { * @param flags * flags for this bitmap */ - public StoredEntry(long objectId, EWAHCompressedBitmap bitmap, + public StoredEntry(long idxPosition, EWAHCompressedBitmap bitmap, int xorOffset, int flags) { - this.objectId = objectId; + this.idxPosition = idxPosition; this.bitmap = bitmap; this.xorOffset = xorOffset; this.flags = flags; @@ -385,23 +389,22 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex { } /** - * Get the ObjectId - * - * @return the ObjectId + * @return the position of the object with this bitmap in the primary + * index (i.e. ordered by sha1) */ - public long getObjectId() { - return objectId; + public long getIdxPosition() { + return idxPosition; } } private static final class PositionEntry extends ObjectIdOwnerMap.Entry { - final int namePosition; + final int idxPosition; - int offsetPosition; + int ridxPosition; - PositionEntry(AnyObjectId objectId, int namePosition) { + PositionEntry(AnyObjectId objectId, int idxPosition) { super(objectId); - this.namePosition = namePosition; + this.idxPosition = idxPosition; } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java index 84326d5e62..38d7c90894 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java @@ -115,7 +115,7 @@ public class PackBitmapIndexWriterV1 implements PackBitmapIndexWriter { private void writeBitmapEntry(StoredEntry entry) throws IOException { // Write object, XOR offset, and bitmap - dataOutput.writeInt((int) entry.getObjectId()); + dataOutput.writeInt((int) entry.getIdxPosition()); out.write(entry.getXorOffset()); out.write(entry.getFlags()); writeBitmap(entry.getBitmap()); |