Class ByteWindow

java.lang.Object
org.eclipse.jgit.internal.storage.file.ByteWindow
Direct Known Subclasses:
ByteArrayWindow, ByteBufferWindow

abstract class ByteWindow extends Object
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
    Modifier and Type
    Field
    Description
    protected final long
     
    protected final Pack
     
    protected final long
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ByteWindow(Pack p, long s, int n)
    Constructor for ByteWindow.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final boolean
    contains(Pack neededPack, long neededPos)
     
    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
    setInput(int pos, Inflater inf)
    Set the input
    (package private) final int
    setInput(long pos, Inflater inf)
     
    (package private) final int
     
    (package private) abstract void
    write(PackOutputStream out, long pos, int cnt)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pack

      protected final Pack pack
    • start

      protected final long start
    • end

      protected final long end
  • Constructor Details

    • ByteWindow

      protected ByteWindow(Pack p, long s, int n)
      Constructor for ByteWindow.
      Parameters:
      p - a Pack.
      s - where the byte window starts in the pack file
      n - size of the byte window
  • Method Details

    • size

      final int size()
    • contains

      final boolean contains(Pack neededPack, long neededPos)
    • 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 within dstbuf to start copying into.
      cnt - number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offset pos.
      Returns:
      number of bytes actually copied; this may be less than cnt if cnt 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 within dstbuf to start copying into.
      cnt - number of bytes to copy. This value may exceed the number of bytes remaining in the window starting at offset pos.
      Returns:
      number of bytes actually copied; this may be less than cnt if cnt exceeded the number of bytes available.
    • write

      abstract void write(PackOutputStream out, long pos, int cnt) throws IOException
      Throws:
      IOException
    • setInput

      final int setInput(long pos, Inflater inf) throws DataFormatException
      Throws:
      DataFormatException
    • setInput

      protected abstract int setInput(int pos, Inflater inf) throws DataFormatException
      Set the input
      Parameters:
      pos - position
      inf - an Inflater object.
      Returns:
      size of the byte window
      Throws:
      DataFormatException - if any.