Class BinaryDataFileWriteBuffered

java.lang.Object
org.apache.jena.dboe.base.file.BinaryDataFileWriteBuffered
All Implemented Interfaces:
org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync, BinaryDataFile

public class BinaryDataFileWriteBuffered extends Object implements BinaryDataFile
Implementation of BinaryDataFile adding write buffering to another BinaryDataFile file, such as a BinaryDataFileRandomAccess.
  • Thread-safe.
  • No read buffering provided.
  • The write buffer is flushed when switching to read.
    • Constructor Details

      • BinaryDataFileWriteBuffered

        public BinaryDataFileWriteBuffered(BinaryDataFile other)
      • BinaryDataFileWriteBuffered

        public BinaryDataFileWriteBuffered(BinaryDataFile other, int bufferSize)
    • Method Details

      • open

        public void open()
        Description copied from interface: BinaryDataFile
        Open the file
        Specified by:
        open in interface BinaryDataFile
      • close

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

        public boolean isOpen()
        Description copied from interface: BinaryDataFile
        Is it open?
        Specified by:
        isOpen in interface BinaryDataFile
      • length

        public long length()
        Description copied from interface: BinaryDataFile
        Return the length of the file (including any buffered writes)
        Specified by:
        length in interface BinaryDataFile
      • truncate

        public void truncate(long posn)
        Description copied from interface: BinaryDataFile
        Truncate the file
        Specified by:
        truncate in interface BinaryDataFile
      • read

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

        public long write(byte[] buf, int off, int len)
        Description copied from interface: BinaryDataFile
        Write bytes - bytes are always written to the end of the file. Return the location where the write started.
        Specified by:
        write in interface BinaryDataFile
      • sync

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