diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-02-15 09:40:16 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-02-15 16:32:51 -0800 |
commit | 14f99dc29d67fa4d2cb227ab906c5c8379499f6b (patch) | |
tree | 546b40cec6f5d373b9a862dc5ae5c30cd166b867 /org.eclipse.jgit | |
parent | 1f7982f64236f88f499193224c49e0a244e5d76a (diff) | |
download | jgit-14f99dc29d67fa4d2cb227ab906c5c8379499f6b.tar.gz jgit-14f99dc29d67fa4d2cb227ab906c5c8379499f6b.zip |
PackWriter: Try for accurate delta reuse on cached pack
If a cached pack is used, it might know how many deltas are contained
within it. Record that count as part of our reusedDeltas field
for the stats line we show clients.
Change-Id: I1c61fb817305a95eeac654cccf132cba20b2339c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/CachedPack.java | 21 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/CachedPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/CachedPack.java index c369e653ef..580fa78416 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/CachedPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/CachedPack.java @@ -72,6 +72,27 @@ public abstract class CachedPack { public abstract long getObjectCount() throws IOException; /** + * Get the number of delta objects stored in this pack. + * <p> + * This is an optional method, not every cached pack storage system knows + * the precise number of deltas stored within the pack. This number must be + * smaller than {@link #getObjectCount()} as deltas are not supposed to span + * across pack files. + * <p> + * This method must be fast, if the only way to determine delta counts is to + * scan the pack file's contents one object at a time, implementors should + * return 0 and avoid the high cost of the scan. + * + * @return the number of deltas; 0 if the number is not known or there are + * no deltas. + * @throws IOException + * if the delta count cannot be read. + */ + public long getDeltaCount() throws IOException { + return 0; + } + + /** * Determine if the pack contains the requested objects. * * @param <T> diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java index 3b1016926f..b8b2767677 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java @@ -588,6 +588,7 @@ public class PackWriter { for (CachedPack pack : cachedPacks) { stats.reusedObjects += pack.getObjectCount(); + stats.reusedDeltas += pack.getDeltaCount(); reuseSupport.copyPackAsIs(out, pack); } writeChecksum(out); |