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
This commit is contained in:
Shawn Pearce 2013-03-14 16:10:44 -07:00
parent 8e2a24a3b6
commit fc6b898cbe
3 changed files with 10 additions and 9 deletions

View File

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

View File

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

View File

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