|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.jgit.lib.WindowCache
public class WindowCache
Caches slices of a PackFile in memory for faster read access.
The WindowCache serves as a Java based "buffer cache", loading segments of a PackFile into the JVM heap prior to use. As JGit often wants to do reads of only tiny slices of a file, the WindowCache tries to smooth out these tiny reads into larger block-sized IO operations.
| Nested Class Summary | |
|---|---|
protected static class |
org.eclipse.jgit.lib.OffsetCache.Ref<V>
A soft reference wrapped around a cached object. |
| Field Summary | |
|---|---|
protected java.lang.ref.ReferenceQueue<V> |
queue
ReferenceQueue that createRef(PackFile, long, Object) must use. |
| Method Summary | |
|---|---|
protected void |
clear(org.eclipse.jgit.lib.WindowCache.WindowRef ref)
Update accounting information now that an object has left the cache. |
protected org.eclipse.jgit.lib.WindowCache.WindowRef |
createRef(PackFile p,
long o,
org.eclipse.jgit.lib.ByteWindow v)
Construct a Ref (SoftReference) around a cached entity. |
protected int |
hash(int packHash,
long off)
Compute the hash code value for a (PackFile,position) tuple. |
protected boolean |
isFull()
Determine if the cache is full and requires eviction of entries. |
protected org.eclipse.jgit.lib.ByteWindow |
load(PackFile pack,
long offset)
Materialize an object that doesn't yet exist in the cache. |
static void |
reconfigure(int packedGitLimit,
int packedGitWindowSize,
boolean packedGitMMAP,
int deltaBaseCacheLimit)
Deprecated. Use WindowCacheConfig instead. |
static void |
reconfigure(WindowCacheConfig cfg)
Modify the configuration of the window cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.lang.ref.ReferenceQueue<V> queue
createRef(PackFile, long, Object) must use.
| Method Detail |
|---|
public static void reconfigure(int packedGitLimit,
int packedGitWindowSize,
boolean packedGitMMAP,
int deltaBaseCacheLimit)
WindowCacheConfig instead.
The new configuration is applied immediately. If the new limits are smaller than what what is currently cached, older entries will be purged as soon as possible to allow the cache to meet the new limit.
packedGitLimit - maximum number of bytes to hold within this instance.packedGitWindowSize - number of bytes per window within the cache.packedGitMMAP - true to enable use of mmap when creating windows.deltaBaseCacheLimit - number of bytes to hold in the delta base cache.public static void reconfigure(WindowCacheConfig cfg)
The new configuration is applied immediately. If the new limits are smaller than what what is currently cached, older entries will be purged as soon as possible to allow the cache to meet the new limit.
cfg - the new window cache configuration.
java.lang.IllegalArgumentException - the cache configuration contains one or more invalid
settings, usually too low of a limit.
protected int hash(int packHash,
long off)
(PackFile,position) tuple.
For example, return packHash + (int) (position >>> 4).
Implementors must override with a suitable hash (for example, a different
right shift on the position).
packHash - hash code for the file being accessed.off - position within the file being accessed.
protected org.eclipse.jgit.lib.ByteWindow load(PackFile pack,
long offset)
throws java.io.IOException
This method is invoked by getOrLoad(PackFile, long) when the
specified entity does not yet exist in the cache. Internal locking
ensures that at most one thread can call this method for each unique
(pack,position), but multiple threads can call this method
concurrently for different (pack,position) tuples.
pack - the file to materialize the entry from.offset - offset within the file of the entry.
java.io.IOException - the method was unable to materialize the object for this
input pair. The usual reasons would be file corruption, file
not found, out of file descriptors, etc.
protected org.eclipse.jgit.lib.WindowCache.WindowRef createRef(PackFile p,
long o,
org.eclipse.jgit.lib.ByteWindow v)
Implementing this is only necessary if the subclass is performing
resource accounting during load(PackFile, long) and
clear(Ref) requires some information to update the accounting.
Implementors MUST ensure that the returned reference uses the
queue ReferenceQueue, otherwise clear(Ref) will not be
invoked at the proper time.
p - the file to materialize the entry from.o - offset within the file of the entry.v - the object returned by load(PackFile, long).
v.protected void clear(org.eclipse.jgit.lib.WindowCache.WindowRef ref)
This method is invoked exactly once for the combined
load(PackFile, long) and
createRef(PackFile, long, Object) invocation pair that was used
to construct and insert an object into the cache.
ref - the reference wrapped around the object. Implementations must
be prepared for ref.get() to return null.protected boolean isFull()
By default this method returns false. Implementors may override to
consult with the accounting updated by load(PackFile, long),
createRef(PackFile, long, Object) and clear(Ref).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||