Browse Source

Simplfy caching of DfsPackDescription from PackWriter.Statistics

Let the pack description copy the relevant stats values. This
moves it out of the garbage collector and compactor algorithms,
co-locating with something that might care.

Remove some unnecessary code from the DfsPackCompactor, the stats
tracks the same information and can supply it.

Change-Id: Id64ab38d507c0ed19ae0d106862d175b7364eba3
stable-3.0
Shawn Pearce 12 years ago
parent
commit
fc6b898cbe
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackCompactor.java
  3. 5
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java

3
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java

@ -403,9 +403,6 @@ public class DfsGarbageCollector {
PackWriter.Statistics stats = pw.getStatistics(); PackWriter.Statistics stats = pw.getStatistics();
pack.setPackStats(stats); pack.setPackStats(stats);
pack.setFileSize(PACK, stats.getTotalBytes());
pack.setObjectCount(stats.getTotalObjects());
pack.setDeltaCount(stats.getTotalDeltas());
objectsPacked += stats.getTotalObjects(); objectsPacked += stats.getTotalObjects();
newPackStats.add(stats); newPackStats.add(stats);

11
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackCompactor.java

@ -283,20 +283,19 @@ public class DfsPackCompactor {
pm.endTask(); pm.endTask();
} }
private void writePack(DfsObjDatabase objdb, DfsPackDescription pack, private static void writePack(DfsObjDatabase objdb,
DfsPackDescription pack,
PackWriter pw, ProgressMonitor pm) throws IOException { PackWriter pw, ProgressMonitor pm) throws IOException {
DfsOutputStream out = objdb.writeFile(pack, PACK); DfsOutputStream out = objdb.writeFile(pack, PACK);
try { try {
CountingOutputStream cnt = new CountingOutputStream(out); pw.writePack(pm, pm, out);
pw.writePack(pm, pm, cnt);
pack.setObjectCount(pw.getObjectCount());
pack.setFileSize(PACK, cnt.getCount());
} finally { } finally {
out.close(); out.close();
} }
} }
private void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack, private static void writeIndex(DfsObjDatabase objdb,
DfsPackDescription pack,
PackWriter pw) throws IOException { PackWriter pw) throws IOException {
DfsOutputStream out = objdb.writeFile(pack, INDEX); DfsOutputStream out = objdb.writeFile(pack, INDEX);
try { try {

5
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java

@ -43,6 +43,8 @@
package org.eclipse.jgit.storage.dfs; package org.eclipse.jgit.storage.dfs;
import static org.eclipse.jgit.storage.pack.PackExt.PACK;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -248,6 +250,9 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
DfsPackDescription setPackStats(PackWriter.Statistics stats) { DfsPackDescription setPackStats(PackWriter.Statistics stats) {
this.stats = stats; this.stats = stats;
setFileSize(PACK, stats.getTotalBytes());
setObjectCount(stats.getTotalObjects());
setDeltaCount(stats.getTotalDeltas());
return this; return this;
} }

Loading…
Cancel
Save