com.crankuptheamps.client
Class ArrayStoreBuffer

java.lang.Object
  extended by com.crankuptheamps.client.ArrayStoreBuffer
All Implemented Interfaces:
BlockPublishStore.Buffer

public class ArrayStoreBuffer
extends Object
implements BlockPublishStore.Buffer

ArrayStoreBuffer is a simple wrapper for a java array that maintains position. Very similar to the 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 Summary
ArrayStoreBuffer()
           
 
Method Summary
 byte[] getBuffer()
           
 byte getByte()
           
 void getBytes(BlockPublishStore.ByteSequence outBytes)
           
 int getInt()
           
 long getLong()
           
 long getPosition()
           
 long getSize()
           
 void putByte(byte b)
           
 void putBytes(BlockPublishStore.ByteSequence bytes)
           
 void putInt(int i)
           
 void putLong(long l)
           
 void setPosition(long position)
           
 void setResizeHandler(PublishStoreResizeHandler handler, Store store)
           
 void setSize(long newSize)
           
 void zero(long offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayStoreBuffer

public ArrayStoreBuffer()
Method Detail

getBuffer

public byte[] getBuffer()

getSize

public long getSize()
             throws IOException
Specified by:
getSize in interface BlockPublishStore.Buffer
Throws:
IOException

setSize

public void setSize(long newSize)
             throws IOException
Specified by:
setSize in interface BlockPublishStore.Buffer
Throws:
IOException

getPosition

public long getPosition()
                 throws IOException
Specified by:
getPosition in interface BlockPublishStore.Buffer
Throws:
IOException

setPosition

public void setPosition(long position)
                 throws IOException
Specified by:
setPosition in interface BlockPublishStore.Buffer
Throws:
IOException

putByte

public void putByte(byte b)
             throws IOException
Specified by:
putByte in interface BlockPublishStore.Buffer
Throws:
IOException

getByte

public byte getByte()
             throws IOException
Specified by:
getByte in interface BlockPublishStore.Buffer
Throws:
IOException

putInt

public void putInt(int i)
            throws IOException
Specified by:
putInt in interface BlockPublishStore.Buffer
Throws:
IOException

getInt

public int getInt()
           throws IOException
Specified by:
getInt in interface BlockPublishStore.Buffer
Throws:
IOException

putLong

public void putLong(long l)
             throws IOException
Specified by:
putLong in interface BlockPublishStore.Buffer
Throws:
IOException

getLong

public long getLong()
             throws IOException
Specified by:
getLong in interface BlockPublishStore.Buffer
Throws:
IOException

putBytes

public void putBytes(BlockPublishStore.ByteSequence bytes)
              throws IOException
Specified by:
putBytes in interface BlockPublishStore.Buffer
Throws:
IOException

getBytes

public void getBytes(BlockPublishStore.ByteSequence outBytes)
              throws IOException
Specified by:
getBytes in interface BlockPublishStore.Buffer
Throws:
IOException

zero

public void zero(long offset,
                 int length)
          throws IOException
Specified by:
zero in interface BlockPublishStore.Buffer
Throws:
IOException

setResizeHandler

public void setResizeHandler(PublishStoreResizeHandler handler,
                             Store store)
Specified by:
setResizeHandler in interface BlockPublishStore.Buffer