]> source.dussan.org Git - jgit.git/commitdiff
Simplfy caching of DfsPackDescription from PackWriter.Statistics 78/11178/2
authorShawn Pearce <spearce@spearce.org>
Thu, 14 Mar 2013 23:10:44 +0000 (16:10 -0700)
committerShawn Pearce <spearce@spearce.org>
Thu, 14 Mar 2013 23:36:04 +0000 (16:36 -0700)
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

org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackCompactor.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java

index 76b36a416a80fc2789096c155f9a43d60efd0fc3..40555dde1624ffe64cfbd308cf35234fb2ebfd4e 100644 (file)
@@ -403,9 +403,6 @@ public class DfsGarbageCollector {
 
                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);
 
index 904ba4efc03e116c119212d8a67375136996367d..3f6a02214112784f53221fcd836ea5a3a1c1cd6a 100644 (file)
@@ -283,20 +283,19 @@ public class DfsPackCompactor {
                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 {
index 746a64aed53c384395fa7e9ca1746e13d4298663..c4a531e7be1ae4cb089d384b1f40d218173aab6d 100644 (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 class DfsPackDescription implements Comparable<DfsPackDescription> {
 
        DfsPackDescription setPackStats(PackWriter.Statistics stats) {
                this.stats = stats;
+               setFileSize(PACK, stats.getTotalBytes());
+               setObjectCount(stats.getTotalObjects());
+               setDeltaCount(stats.getTotalDeltas());
                return this;
        }