public class ArrayStoreBuffer extends java.lang.Object implements BlockPublishStore.Buffer
MemoryStoreBuffer
, but instead of using a ByteBuffer,
it just uses an array directly. Resize may be a tad more expensive, but
steady-state latencies are significantly lower.Constructor and Description |
---|
ArrayStoreBuffer() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
byte[] |
getBuffer()
Gets the back buffer.
|
byte |
getByte()
Gets the byte from the buffer.
|
void |
getBytes(BlockPublishStore.ByteSequence outBytes)
Gets the series of bytes at the current position by placing them into the provided
BlockPublishStore.ByteSequence object. |
void |
getBytes(Field outField,
int length)
Gets the series of bytes at the current position, this is done by copying them into a
Field object. |
int |
getInt()
Gets the integer from the buffer.
|
int |
getInt(long position)
Gets the integer from the buffer.
|
long |
getLong()
Gets the long from the buffer.
|
long |
getPosition()
Gets the current position in the buffer.
|
long |
getSize()
Gets the size of the back buffer.
|
void |
putByte(byte b)
Writes the byte into the buffer.
|
void |
putBytes(BlockPublishStore.ByteSequence bytes)
Writes a series of bytes at the current position, taken from the specified
BlockPublishStore.ByteSequence . |
void |
putBytes(byte[] buffer,
long position,
long length)
Writes a series of bytes at the current position, taken from a byte array.
|
void |
putInt(int i)
Writes the integer into the buffer.
|
void |
putInt(long position,
int i)
Puts the integer into the buffer.
|
void |
putLong(long l)
Writes the long into the buffer.
|
void |
putLong(long position,
long l)
Writes the long into the buffer.
|
void |
setPosition(long position)
Sets the current position in the buffer.
|
void |
setSize(long newSize)
Sets the size of the back buffer.
|
void |
zero(long offset,
int length)
Sets the buffer, offset, and length to 0.
|
public byte[] getBuffer()
public long getSize() throws java.io.IOException
getSize
in interface BlockPublishStore.Buffer
java.io.IOException
- Not thrown from this implementation.public void setSize(long newSize) throws java.io.IOException
setSize
in interface BlockPublishStore.Buffer
newSize
- The number to be set as the new buffer size.java.io.IOException
- Not thrown from this implementation.public long getPosition() throws java.io.IOException
getPosition
in interface BlockPublishStore.Buffer
java.io.IOException
- Not thrown from this implementation.public void setPosition(long position) throws java.io.IOException
setPosition
in interface BlockPublishStore.Buffer
position
- The current position to set.java.io.IOException
- Not thrown from this implementation.public void putByte(byte b) throws java.io.IOException
putByte
in interface BlockPublishStore.Buffer
b
- The byte to place in the buffer.java.io.IOException
- Not thrown from this implementation.public byte getByte() throws java.io.IOException
getByte
in interface BlockPublishStore.Buffer
java.io.IOException
- Not thrown from this implementation.public void putInt(int i) throws java.io.IOException
putInt
in interface BlockPublishStore.Buffer
i
- The integer to place in the buffer.java.io.IOException
- Not thrown from this implementation.public void putInt(long position, int i) throws java.io.IOException
putInt
in interface BlockPublishStore.Buffer
position
- The position in the buffer to place the integer.i
- The integer to place in the buffer.java.io.IOException
- Not thrown from this implementation.public int getInt() throws java.io.IOException
getInt
in interface BlockPublishStore.Buffer
java.io.IOException
- Not thrown from this implementation.public int getInt(long position) throws java.io.IOException
getInt
in interface BlockPublishStore.Buffer
position
- The position in the buffer where the integer should begin.java.io.IOException
- Not thrown from this implementation.public void putLong(long l) throws java.io.IOException
putLong
in interface BlockPublishStore.Buffer
l
- The long to be placed in the buffer.java.io.IOException
- Not thrown from this implementation.public void putLong(long position, long l) throws java.io.IOException
putLong
in interface BlockPublishStore.Buffer
position
- The position where the long should be placed in the buffer.l
- The long to be placed in the buffer.java.io.IOException
- Not thrown from this implementation.public long getLong() throws java.io.IOException
getLong
in interface BlockPublishStore.Buffer
java.io.IOException
- Not thrown from this implementation.public void putBytes(BlockPublishStore.ByteSequence bytes) throws java.io.IOException
BlockPublishStore.ByteSequence
.putBytes
in interface BlockPublishStore.Buffer
bytes
- The series of bytes to write at the current position.java.io.IOException
- Not thrown from this implementation.public void getBytes(BlockPublishStore.ByteSequence outBytes) throws java.io.IOException
BlockPublishStore.ByteSequence
object.getBytes
in interface BlockPublishStore.Buffer
outBytes
- The provided ByteSequence object.java.io.IOException
- Not thrown from this implementation.public void putBytes(byte[] buffer, long position, long length) throws java.io.IOException
putBytes
in interface BlockPublishStore.Buffer
buffer
- The buffer containing a series of bytes.position
- The position in the buffer where the series of bytes are located.length
- The length of the byte buffer.java.io.IOException
- Not thrown from this implementation.public void getBytes(Field outField, int length) throws java.io.IOException
Field
object.getBytes
in interface BlockPublishStore.Buffer
outField
- The Field object used to copy the byte sequence.length
- The length of the Field object.java.io.IOException
- Not thrown from this implementation.public void zero(long offset, int length) throws java.io.IOException
zero
in interface BlockPublishStore.Buffer
offset
- The offset to set as 0.length
- The length to set as 0.java.io.IOException
- Not thrown from this implementation.public void close()
close
in interface java.lang.AutoCloseable