org.apache.blur.store.blockcache_v2
Interface CacheValue

All Known Implementing Classes:
BaseCacheValue, ByteArrayCacheValue, DetachableCacheValue, UnsafeCacheValue

public interface CacheValue


Method Summary
 void decRef()
           
 CacheValue detachFromCache()
          Detach from the base cache.
 void incRef()
           
 int length()
          The length of the data in this block.
 byte read(int position)
          Reads a byte from the given position.
 void read(int position, byte[] buf, int offset, int length)
          Reads data into the buffer given the position.
 int readInt(int position)
          Reads a int from the given position.
 long readLong(int position)
          Reads a long from the given position.
 short readShort(int position)
          Reads a short from the given position.
 void release()
          Releases any underlying resources.
 CacheValue trim(int length)
          This method may trim the existing CacheValue and produce potentially a new CacheValue with the same data up to the length provided.
 void write(int position, byte[] buf, int offset, int length)
          Writes data out to a given position in this block.
 

Method Detail

detachFromCache

CacheValue detachFromCache()
Detach from the base cache.

Returns:
old cache value.

length

int length()
The length of the data in this block.

Returns:
the length.

write

void write(int position,
           byte[] buf,
           int offset,
           int length)
Writes data out to a given position in this block.

Parameters:
position - the position.
buf - the buffer.
offset - the offset in the buffer.
length - the length of bytes to write.

read

void read(int position,
          byte[] buf,
          int offset,
          int length)
Reads data into the buffer given the position.

Parameters:
position - the position to read.
buf - the buffer to read into.
offset - the offset within the buffer.
length - the length of data to read.

read

byte read(int position)
Reads a byte from the given position.

Parameters:
position - the position.
Returns:
the byte.

release

void release()
Releases any underlying resources.


readShort

short readShort(int position)
Reads a short from the given position.

Parameters:
position - the Position to read from.
Returns:
the short.

readInt

int readInt(int position)
Reads a int from the given position.

Parameters:
position - the Position to read from.
Returns:
the int.

readLong

long readLong(int position)
Reads a long from the given position.

Parameters:
position - the Position to read from.
Returns:
the long.

trim

CacheValue trim(int length)
This method may trim the existing CacheValue and produce potentially a new CacheValue with the same data up to the length provided. Also if a new CacheValue is produced then this method is responsible to calling release on the old CacheValue.

Parameters:
length - the valid amount of data in the CacheValue.
Returns:
new trim CacheValue that has been trimmed if needed.

decRef

void decRef()

incRef

void incRef()


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.