summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2023-12-14 09:25:06 -0800
committerIvan Frade <ifrade@google.com>2023-12-14 15:42:44 -0800
commitb2abab271a3c8093cc8c2cf3d5daea7ed408b78c (patch)
treeaaf35377f3e419d35d9fe9d8e81f1048a543f1e7
parente25bf957387b944dac0a12fe6e6ed8b284db81bb (diff)
downloadjgit-b2abab271a3c8093cc8c2cf3d5daea7ed408b78c.tar.gz
jgit-b2abab271a3c8093cc8c2cf3d5daea7ed408b78c.zip
DfsReader: give subclasses visiblity over the pack bitmap index
Subclasses intercept many methods in DfsReader to capture metrics, but they cannot record stats from PackBitmapIndex, as it is wrapped inside a BitmapIndex. Move the creation of the BitmapIndex to a protected method. Subclasses can override it to e.g. read metrics from the index or set listeners to the BitmapIndex. Change-Id: I86c13b3ef88663d7faf59f2ec77df0a36b1627ed
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
index 3f0adcba1a..c722c06e9c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java
@@ -28,6 +28,7 @@ import java.util.Set;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException;
@@ -120,11 +121,23 @@ public class DfsReader extends ObjectReader implements ObjectReuseAsIs {
for (DfsPackFile pack : db.getPacks()) {
PackBitmapIndex bitmapIndex = pack.getBitmapIndex(this);
if (bitmapIndex != null)
- return new BitmapIndexImpl(bitmapIndex);
+ return createBitmapIndex(bitmapIndex);
}
return null;
}
+ /**
+ * Give subclasses a chance to record pack index stats
+ *
+ * @param packBitmapIndex
+ * packBitmapIndex found in a pack (never null)
+ * @return an instance of BitmapIndex
+ */
+ protected BitmapIndex createBitmapIndex(
+ @NonNull PackBitmapIndex packBitmapIndex) {
+ return new BitmapIndexImpl(packBitmapIndex);
+ }
+
@Override
public Optional<CommitGraph> getCommitGraph() throws IOException {
for (DfsPackFile pack : db.getPacks()) {