Interface BufferChannel

All Superinterfaces:
org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync
All Known Implementing Classes:
BufferChannelFile, BufferChannelMem

public interface BufferChannel extends org.apache.jena.atlas.lib.Sync, org.apache.jena.atlas.lib.Closeable
Interface to storage : a simplified version of FileChannel. Read and write bytes, passed via ByteBuffers, addressed by file location. This interface is not suitable for memory mapped I/O - there is no ability to use slices of a memory mapped file. This interface does not insert size of ByteBuffer - size of ByteBuffer passed to read controls the number of bytes read. Having our own abstraction enables us to implement memory-backed versions.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Return another channel to the same storage but with independent position.
    Filename for this BufferChannel (maybe null)
    useful display string
    boolean
    Is it empty?
    long
    return the position
    void
    position(long pos)
    set the position
    int
    read(ByteBuffer buffer)
    Read into a ByteBuffer.
    int
    read(ByteBuffer buffer, long loc)
    Read into a ByteBuffer, starting at position loc.
    long
    Length of storage, in bytes.
    void
    truncate(long size)
    Truncate the file.
    int
    write(ByteBuffer buffer)
    Write from ByteBuffer, starting at position loc.
    int
    write(ByteBuffer buffer, long loc)
    Write from ByteBuffer, starting at position loc.

    Methods inherited from interface org.apache.jena.atlas.lib.Closeable

    close

    Methods inherited from interface org.apache.jena.atlas.lib.Sync

    sync
  • Method Details

    • duplicate

      BufferChannel duplicate()
      Return another channel to the same storage but with independent position. Chaos may result due to concurrent use.
    • position

      long position()
      return the position
    • position

      void position(long pos)
      set the position
    • read

      int read(ByteBuffer buffer)
      Read into a ByteBuffer. Returns the number of bytes read. -1 for end of file.
    • read

      int read(ByteBuffer buffer, long loc)
      Read into a ByteBuffer, starting at position loc. Return the number of bytes read. loc must be within the file.
    • write

      int write(ByteBuffer buffer)
      Write from ByteBuffer, starting at position loc. Return the number of bytes written
    • write

      int write(ByteBuffer buffer, long loc)
      Write from ByteBuffer, starting at position loc. Return the number of bytes written. loc must be within 0 to length - writing at length is append
    • truncate

      void truncate(long size)
      Truncate the file.
      See Also:
    • size

      long size()
      Length of storage, in bytes.
    • isEmpty

      boolean isEmpty()
      Is it empty?
    • getLabel

      String getLabel()
      useful display string
    • getFilename

      String getFilename()
      Filename for this BufferChannel (maybe null)