Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class LargeMappedPersistentBuffer extends AbstractPersistentBuffer
MappedByteBuffer for persistence. Each buffer
covers a maximum of 2^30 bytes. This handles mapping of up to
2^30 * 2^31-2 bytes.MappedPersistentBufferprotectionLevel| Constructor and Description |
|---|
LargeMappedPersistentBuffer()
Creates a read-write buffer backed by a temporary file.
|
LargeMappedPersistentBuffer(File file)
Creates a read-write buffer with
BARRIER protection level. |
LargeMappedPersistentBuffer(File file,
ProtectionLevel protectionLevel)
Creates a buffer.
|
LargeMappedPersistentBuffer(RandomAccessFile raf,
ProtectionLevel protectionLevel)
Creates a buffer using the provided
RandomAccessFile. |
LargeMappedPersistentBuffer(String name)
Creates a read-write buffer with
BARRIER protection level. |
LargeMappedPersistentBuffer(String name,
ProtectionLevel protectionLevel)
Creates a buffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
barrier(boolean force)
There is not currently a way to provide a barrier without using
force. |
long |
capacity()
Gets the capacity of this buffer.
|
void |
close()
Closes this buffer.
|
void |
ensureZeros(long position,
long len)
Ensures that all values from the position for the provided length
are zeros.
|
protected void |
finalize() |
byte |
get(long position)
Gets a single byte from the buffer.
|
void |
get(long position,
byte[] buff,
int off,
int len)
Implemented as calls to
getSome(long,byte[],int,int) |
boolean |
getBoolean(long position)
Implemented as call to
readByte(long) |
int |
getInt(long position)
Implemented as call to
get(long,byte[],int,int) |
long |
getLong(long position)
Implemented as call to
get(long,byte[],int,int) |
int |
getSome(long position,
byte[] buff,
int off,
int len)
Reads to the provided
byte[], may read fewer than len
bytes, but will always read at least one byte. |
boolean |
isClosed()
Checks if this buffer is closed.
|
void |
put(long position,
byte value)
Puts a single byte in the buffer.
|
void |
put(long position,
byte[] buff,
int off,
int len)
Writes the bytes to the provided position.
|
void |
putInt(long position,
int value)
Implemented as call to
write(long,byte[],int,int) |
void |
putLong(long position,
long value)
Implemented as call to
write(long,byte[],int,int) |
void |
setCapacity(long newLength)
Sets the capacity of this buffer.
|
getInputStream, getOutputStream, getProtectionLevelpublic LargeMappedPersistentBuffer()
throws IOException
NONE. The temporary file will be deleted when this
buffer is closed or on JVM shutdown.IOExceptionpublic LargeMappedPersistentBuffer(String name) throws IOException
BARRIER protection level.IOExceptionpublic LargeMappedPersistentBuffer(String name, ProtectionLevel protectionLevel) throws IOException
IOExceptionpublic LargeMappedPersistentBuffer(File file) throws IOException
BARRIER protection level.IOExceptionpublic LargeMappedPersistentBuffer(File file, ProtectionLevel protectionLevel) throws IOException
IOExceptionpublic LargeMappedPersistentBuffer(RandomAccessFile raf, ProtectionLevel protectionLevel) throws IOException
RandomAccessFile.IOExceptionpublic boolean isClosed()
PersistentBufferprotected void finalize()
throws Throwable
public void close()
throws IOException
PersistentBufferIOExceptionpublic long capacity()
throws IOException
PersistentBufferIOExceptionpublic void setCapacity(long newLength)
throws IOException
PersistentBufferbarrier(true), depending on implementation. This
should be considered an expensive operation.IOExceptionpublic void get(long position,
byte[] buff,
int off,
int len)
throws IOException
AbstractPersistentBuffergetSome(long,byte[],int,int)get in interface PersistentBufferget in class AbstractPersistentBufferIOException#read(long, byte[], int, int)public int getSome(long position,
byte[] buff,
int off,
int len)
throws IOException
PersistentBufferbyte[], may read fewer than len
bytes, but will always read at least one byte. Blocks if no data is
available.IOExceptionpublic byte get(long position)
throws IOException
get in interface PersistentBufferget in class AbstractPersistentBufferIOExceptionAbstractPersistentBuffer.get(long, byte[], int, int)public void ensureZeros(long position,
long len)
throws IOException
PersistentBufferIOExceptionpublic void put(long position,
byte value)
throws IOException
put in interface PersistentBufferput in class AbstractPersistentBufferIOExceptionPersistentBuffer.put(long, byte[], int, int)public void put(long position,
byte[] buff,
int off,
int len)
throws IOException
PersistentBufferIOExceptionpublic void barrier(boolean force)
throws IOException
force.
This just uses force for both.IOExceptionPersistentBuffer.getProtectionLevel()public boolean getBoolean(long position)
throws IOException
AbstractPersistentBufferreadByte(long)getBoolean in interface PersistentBuffergetBoolean in class AbstractPersistentBufferIOException#readByte(long)public int getInt(long position)
throws IOException
AbstractPersistentBufferget(long,byte[],int,int)getInt in interface PersistentBuffergetInt in class AbstractPersistentBufferIOExceptionAbstractPersistentBuffer.get(long, byte[], int, int)public long getLong(long position)
throws IOException
AbstractPersistentBufferget(long,byte[],int,int)getLong in interface PersistentBuffergetLong in class AbstractPersistentBufferIOExceptionAbstractPersistentBuffer.get(long, byte[], int, int)public void putInt(long position,
int value)
throws IOException
AbstractPersistentBufferwrite(long,byte[],int,int)putInt in interface PersistentBufferputInt in class AbstractPersistentBufferIOException#write(long, byte[], int, int)public void putLong(long position,
long value)
throws IOException
AbstractPersistentBufferwrite(long,byte[],int,int)putLong in interface PersistentBufferputLong in class AbstractPersistentBufferIOException#write(long, byte[], int, int)Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.