aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2024-11-01 08:58:27 -0700
committerIvan Frade <ifrade@google.com>2024-11-01 15:59:21 -0700
commitee44c6ea9c49f98efd4ae6d11d283fcac8edc3c3 (patch)
treec22478561d5ed53d9e57fe54beb1f4647b3bd8e9 /org.eclipse.jgit/src
parent4ec2413e14043f6d9a0ebd6616fdef2464fe4880 (diff)
downloadjgit-ee44c6ea9c49f98efd4ae6d11d283fcac8edc3c3.tar.gz
jgit-ee44c6ea9c49f98efd4ae6d11d283fcac8edc3c3.zip
DfsPackCompactor: write object size index
Currently the compactor is not writing the object size index for packs. As it is using PackWriter to generate the packs, it needs to explicitely call the writes of each extension. Invoke writeObjectSizeIndex in the compactor. The pack writer will write one if the configuration says so. Change-Id: I8d6bbbb5bd67bfc7dd511aa76463512b1e86a45d
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
index b32cddae77..f9c01b9d6e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackCompactor.java
@@ -12,6 +12,7 @@ package org.eclipse.jgit.internal.storage.dfs;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.COMPACT;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC;
+import static org.eclipse.jgit.internal.storage.pack.PackExt.OBJECT_SIZE_INDEX;
import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK;
import static org.eclipse.jgit.internal.storage.pack.PackExt.REFTABLE;
import static org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation.PACK_DELTA;
@@ -44,6 +45,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.storage.pack.PackConfig;
import org.eclipse.jgit.storage.pack.PackStatistics;
import org.eclipse.jgit.util.BlockList;
+import org.eclipse.jgit.util.io.CountingOutputStream;
/**
* Combine several pack files into one pack.
@@ -247,6 +249,7 @@ public class DfsPackCompactor {
try {
writePack(objdb, outDesc, pw, pm);
writeIndex(objdb, outDesc, pw);
+ writeObjectSizeIndex(objdb, outDesc, pw);
PackStatistics stats = pw.getStatistics();
@@ -459,6 +462,20 @@ public class DfsPackCompactor {
pw.writeIndex(objdb.getPackIndexWriter(pack, pw.getIndexVersion()));
}
+ private static void writeObjectSizeIndex(DfsObjDatabase objdb,
+ DfsPackDescription pack,
+ PackWriter pw) throws IOException {
+ try (DfsOutputStream out = objdb.writeFile(pack, OBJECT_SIZE_INDEX)) {
+ CountingOutputStream cnt = new CountingOutputStream(out);
+ pw.writeObjectSizeIndex(cnt);
+ if (cnt.getCount() > 0) {
+ pack.addFileExt(OBJECT_SIZE_INDEX);
+ pack.setFileSize(OBJECT_SIZE_INDEX, cnt.getCount());
+ pack.setBlockSize(OBJECT_SIZE_INDEX, out.blockSize());
+ }
+ }
+ }
+
static ReftableConfig configureReftable(ReftableConfig cfg,
DfsOutputStream out) {
int bs = out.blockSize();