Package org.apache.jena.dboe.base.file
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 java.lang.Object implements BinaryDataFile
Implementation ofBinaryDataFileadding write buffering to anotherBinaryDataFilefile, such as aBinaryDataFileRandomAccess.- Thread-safe.
- No read buffering provided.
- The write buffer is flushed when switching to read.
-
-
Constructor Summary
Constructors Constructor Description BinaryDataFileWriteBuffered(BinaryDataFile other)BinaryDataFileWriteBuffered(BinaryDataFile other, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanisOpen()Is it open?longlength()Return the length of the file (including any buffered writes)voidopen()Open the fileintread(long posn, byte[] b, int start, int length)Read into a byte array, returning the number of bytes read.voidsync()voidtruncate(long posn)Truncate the filelongwrite(byte[] buf, int off, int len)Write bytes - bytes are always written to the end of the file.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jena.dboe.base.file.BinaryDataFile
isEmpty, read, write
-
-
-
-
Constructor Detail
-
BinaryDataFileWriteBuffered
public BinaryDataFileWriteBuffered(BinaryDataFile other)
-
BinaryDataFileWriteBuffered
public BinaryDataFileWriteBuffered(BinaryDataFile other, int bufferSize)
-
-
Method Detail
-
open
public void open()
Description copied from interface:BinaryDataFileOpen the file- Specified by:
openin interfaceBinaryDataFile
-
close
public void close()
- Specified by:
closein interfaceBinaryDataFile- Specified by:
closein interfaceorg.apache.jena.atlas.lib.Closeable
-
isOpen
public boolean isOpen()
Description copied from interface:BinaryDataFileIs it open?- Specified by:
isOpenin interfaceBinaryDataFile
-
length
public long length()
Description copied from interface:BinaryDataFileReturn the length of the file (including any buffered writes)- Specified by:
lengthin interfaceBinaryDataFile
-
truncate
public void truncate(long posn)
Description copied from interface:BinaryDataFileTruncate the file- Specified by:
truncatein interfaceBinaryDataFile
-
read
public int read(long posn, byte[] b, int start, int length)Description copied from interface:BinaryDataFileRead 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:
readin interfaceBinaryDataFile- Parameters:
posn- Location of the read operation.start- of bytesarray to read intolength- 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:BinaryDataFileWrite bytes - bytes are always written to the end of the file. Return the location where the write started.- Specified by:
writein interfaceBinaryDataFile
-
sync
public void sync()
- Specified by:
syncin interfaceBinaryDataFile- Specified by:
syncin interfaceorg.apache.jena.atlas.lib.Sync
-
-