]> source.dussan.org Git - jgit.git/commitdiff
PackBitmapIndex: clarify naming of getObject inputs 08/1192808/11
authorSam Delmerico <delmerico@google.com>
Tue, 9 Apr 2024 23:56:38 +0000 (16:56 -0700)
committerSam Delmerico <delmerico@google.com>
Fri, 12 Apr 2024 15:26:19 +0000 (08:26 -0700)
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

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java

index 4c3f6c1eb484a61632a57c091d2fb0889e2fdd34..cbda8fc77c1d24b90d07b249f0e245df87f67368 100644 (file)
@@ -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.
index 03d6948e90d6e85ea4e86d77b7a87211bfe5d4dc..7646c1909bf70e2568eb1636d666610b5dd70352 100644 (file)
@@ -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;
                }
        }
 }
index 84326d5e6201e6b9160ea077a82f39279e82ad22..38d7c9089401f0936570eb95d84db389dc45d2d0 100644 (file)
@@ -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());