Class ByteWindow
java.lang.Object
org.eclipse.jgit.internal.storage.file.ByteWindow
- Direct Known Subclasses:
ByteArrayWindow
,ByteBufferWindow
A window of data currently stored within a cache.
All bytes in the window can be assumed to be "immediately available", that is they are very likely already in memory, unless the operating system's memory is very low and has paged part of this process out to disk. Therefore copying bytes from a window is very inexpensive.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ByteWindow
(Pack p, long s, int n) Constructor for ByteWindow. -
Method Summary
Modifier and TypeMethodDescription(package private) final boolean
protected abstract int
copy
(int pos, byte[] dstbuf, int dstoff, int cnt) Copy bytes from the window to a caller supplied buffer.(package private) final int
copy
(long pos, byte[] dstbuf, int dstoff, int cnt) Copy bytes from the window to a caller supplied buffer.protected abstract int
Set the input(package private) final int
(package private) final int
size()
(package private) abstract void
write
(PackOutputStream out, long pos, int cnt)
-
Field Details
-
pack
-
start
protected final long start -
end
protected final long end
-
-
Constructor Details
-
ByteWindow
Constructor for ByteWindow.- Parameters:
p
- aPack
.s
- where the byte window starts in the pack filen
- size of the byte window
-
-
Method Details
-
size
final int size() -
contains
-
copy
final int copy(long pos, byte[] dstbuf, int dstoff, int cnt) Copy bytes from the window to a caller supplied buffer.- Parameters:
pos
- offset within the file to start copying from.dstbuf
- destination buffer to copy into.dstoff
- offset withindstbuf
to start copying into.cnt
- number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offsetpos
.- Returns:
- number of bytes actually copied; this may be less than
cnt
ifcnt
exceeded the number of bytes available.
-
copy
protected abstract int copy(int pos, byte[] dstbuf, int dstoff, int cnt) Copy bytes from the window to a caller supplied buffer.- Parameters:
pos
- offset within the window to start copying from.dstbuf
- destination buffer to copy into.dstoff
- offset withindstbuf
to start copying into.cnt
- number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offsetpos
.- Returns:
- number of bytes actually copied; this may be less than
cnt
ifcnt
exceeded the number of bytes available.
-
write
- Throws:
IOException
-
setInput
- Throws:
DataFormatException
-
setInput
Set the input- Parameters:
pos
- positioninf
- anInflater
object.- Returns:
- size of the byte window
- Throws:
DataFormatException
- if any.
-