Create a cached window file API.
commitd3614a3e2dfefcf83956e6e6280e741f505f093f
authorShawn O. Pearce <spearce@spearce.org>
Wed, 29 Nov 2006 01:41:51 +0000 (28 20:41 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 29 Nov 2006 01:41:51 +0000 (28 20:41 -0500)
treece17e640749cdff8a06b28435c349a638d1cbebf
parenta4e486719ce78b8050373e6534dfaf4a1572b269
Create a cached window file API.

To efficiently read pack files from disk we need to access different
sections of the file repeatedly, and we need random access while we
do that.  Using a small buffer on top of a seekable file (like we have
been doing) is very slow, as we have to keep rereading relevant parts
of the file and we never get to ammortize the operating system IO costs
over the total bytes being accessed.

So instead we want to use a strategy like what core-git will likely
move to:  maintain a cache of large chunks of the file, where those
large chunks are either read directly into byte[]s or were mapped
using the operating system's virtual memory manager.

This is probably something that should just be shipped with Java,
but doesn't.  I explicitly stayed away from using java.util collections
such as LinkedHashMap as I really don't want to pay an object allocation
penalty (on the search key) on every lookup in the cache, as that part
will be a critical part of our pack data access loop.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/ByteBufferWindow.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/ByteWindow.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/WindowProvider.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java [new file with mode: 0644]