Interface BinaryDataFile

All Superinterfaces:
org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync
All Known Implementing Classes:
BinaryDataFileMem, BinaryDataFileRandomAccess, BinaryDataFileSync, BinaryDataFileWrapper, BinaryDataFileWriteBuffered

public interface BinaryDataFile extends org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync
An append-only, read-anywhere, binary file. A BinaryDataFile does not record the length and assumes the entries are self-defining.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    default boolean
    Return whether this is an empty file or not
    boolean
    Is it open?
    long
    Return the length of the file (including any buffered writes)
    void
    Open the file
    default int
    read(long posn, byte[] b)
    Read into a byte array, returning the number of bytes read.
    int
    read(long posn, byte[] b, int start, int length)
    Read into a byte array, returning the number of bytes read.
    void
     
    void
    truncate(long length)
    Truncate the file
    default long
    write(byte[] b)
    Write bytes - bytes are always written to the end of the file.
    long
    write(byte[] b, int start, int length)
    Write bytes - bytes are always written to the end of the file.
  • Method Details

    • open

      void open()
      Open the file
    • isOpen

      boolean isOpen()
      Is it open?
    • read

      default int read(long posn, byte[] b)
      Read into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.
      Parameters:
      posn - Location of the read operation.
      b - byte array
      Returns:
      The number of bytes read
    • read

      int read(long posn, byte[] b, int start, int length)
      Read into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.
      Parameters:
      posn - Location of the read operation.
      b -
      start - of bytesarray to read into
      length - Maximum number of bytes to read.
      Returns:
      The number of bytes read
    • write

      default long write(byte[] b)
      Write bytes - bytes are always written to the end of the file. Return the location where the write started.
    • write

      long write(byte[] b, int start, int length)
      Write bytes - bytes are always written to the end of the file. Return the location where the write started.
    • length

      long length()
      Return the length of the file (including any buffered writes)
    • truncate

      void truncate(long length)
      Truncate the file
    • isEmpty

      default boolean isEmpty()
      Return whether this is an empty file or not
    • sync

      void sync()
      Specified by:
      sync in interface org.apache.jena.atlas.lib.Sync
    • close

      void close()
      Specified by:
      close in interface org.apache.jena.atlas.lib.Closeable