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, the 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:
    BlockAccess, FileChannel
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      BufferChannel duplicate()
      Return another channel to the same storage but with independent position.
      java.lang.String getFilename()
      Filename for this BufferChannel (maybe null)
      java.lang.String getLabel()
      useful display string
      boolean isEmpty()
      Is it empty?
      long position()
      return the position
      void position​(long pos)
      set the position
      int read​(java.nio.ByteBuffer buffer)
      Read into a ByteBuffer.
      int read​(java.nio.ByteBuffer buffer, long loc)
      Read into a ByteBuffer, starting at position loc.
      long size()
      Length of storage, in bytes.
      void truncate​(long size)
      Truncate the file.
      int write​(java.nio.ByteBuffer buffer)
      Write from ByteBuffer, starting at the current position.
      int write​(java.nio.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 Detail

      • 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​(java.nio.ByteBuffer buffer)
        Read into a ByteBuffer. Returns the number of bytes read. -1 for end of file.
      • read

        int read​(java.nio.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​(java.nio.ByteBuffer buffer)
        Write from ByteBuffer, starting at the current position. Return the number of bytes written
      • write

        int write​(java.nio.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:
        FileChannel.truncate(long)
      • size

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

        boolean isEmpty()
        Is it empty?
      • getLabel

        java.lang.String getLabel()
        useful display string
      • getFilename

        java.lang.String getFilename()
        Filename for this BufferChannel (maybe null)