Browse Source

Correctly name DeltaBaseCache

This class is used only to cache the unpacked form of an object that
was used as a base for another object.  The theory goes that if an
object is used as a delta base for A, it will probably also be a
delta base for B, C, D, E, etc. and therefore having an unpacked copy
of it on hand will make delta resolution for the others very fast.

However since objects are usually only accessed once, we don't want
to cache everything we unpack, just things that we are likely to
need again.  The only things we need again are the delta bases.
Hence, its a delta base cache.

This gets us the class name UnpackedObjectCache back, so we can
use it to actually create a cache of unpacked object information.

Change-Id: I121f356cf4eca7b80126497264eac22bd5825a1d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
tags/v0.9.1
Shawn O. Pearce 13 years ago
parent
commit
eb64ccad6d

org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObjectCache.java → org.eclipse.jgit/src/org/eclipse/jgit/storage/file/DeltaBaseCache.java View File

@@ -45,7 +45,7 @@ package org.eclipse.jgit.storage.file;

import java.lang.ref.SoftReference;

class UnpackedObjectCache {
class DeltaBaseCache {
private static final int CACHE_SZ = 1024;

private static final SoftReference<Entry> DEAD;
@@ -164,7 +164,7 @@ class UnpackedObjectCache {
e.sz = 0;
}

private UnpackedObjectCache() {
private DeltaBaseCache() {
throw new UnsupportedOperationException();
}


+ 3
- 11
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java View File

@@ -220,7 +220,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
* Close the resources utilized by this repository
*/
public void close() {
UnpackedObjectCache.purge(this);
DeltaBaseCache.purge(this);
WindowCache.purge(this);
synchronized (this) {
loadedIdx = null;
@@ -274,14 +274,6 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
return getReverseIdx().findObject(offset);
}

private final UnpackedObjectCache.Entry readCache(final long position) {
return UnpackedObjectCache.get(this, position);
}

private final void saveCache(final long position, final byte[] data, final int type) {
UnpackedObjectCache.store(this, position, data, type);
}

private final byte[] decompress(final long position, final long totalSize,
final WindowCursor curs) throws IOException, DataFormatException {
final byte[] dstbuf = new byte[(int) totalSize];
@@ -700,7 +692,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
byte[] data;
int type;

UnpackedObjectCache.Entry e = readCache(posBase);
DeltaBaseCache.Entry e = DeltaBaseCache.get(this, posBase);
if (e != null) {
data = e.data;
type = e.type;
@@ -715,7 +707,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
}
data = p.getCachedBytes();
type = p.getType();
saveCache(posBase, data, type);
DeltaBaseCache.store(this, posBase, data, type);
}

// At this point we have the base, and its small, and the delta

+ 1
- 1
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCache.java View File

@@ -187,7 +187,7 @@ public class WindowCache {
oc.removeAll();
cache = nc;
streamFileThreshold = cfg.getStreamFileThreshold();
UnpackedObjectCache.reconfigure(cfg);
DeltaBaseCache.reconfigure(cfg);
}

static int getStreamFileThreshold() {

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java View File

@@ -146,7 +146,7 @@ public class WindowCacheConfig {
}

/**
* @return maximum number of bytes to cache in {@link UnpackedObjectCache}
* @return maximum number of bytes to cache in {@link DeltaBaseCache}
* for inflated, recently accessed objects, without delta chains.
* <b>Default 10 MB.</b>
*/
@@ -157,7 +157,7 @@ public class WindowCacheConfig {
/**
* @param newLimit
* maximum number of bytes to cache in
* {@link UnpackedObjectCache} for inflated, recently accessed
* {@link DeltaBaseCache} for inflated, recently accessed
* objects, without delta chains.
*/
public void setDeltaBaseCacheLimit(final int newLimit) {

Loading…
Cancel
Save