org.apache.blur.store.blockcache_v2.cachevalue
Class BaseCacheValue

java.lang.Object
  extended by org.apache.blur.store.blockcache_v2.cachevalue.BaseCacheValue
All Implemented Interfaces:
CacheValue
Direct Known Subclasses:
ByteArrayCacheValue, UnsafeCacheValue

public abstract class BaseCacheValue
extends Object
implements CacheValue


Nested Class Summary
static class BaseCacheValue.Evicted
           
 
Constructor Summary
BaseCacheValue(int length)
           
 
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.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.blur.store.blockcache_v2.CacheValue
release
 

Constructor Detail

BaseCacheValue

public BaseCacheValue(int length)
Method Detail

length

public final int length()
Description copied from interface: CacheValue
The length of the data in this block.

Specified by:
length in interface CacheValue
Returns:
the length.

write

public void write(int position,
                  byte[] buf,
                  int offset,
                  int length)
Description copied from interface: CacheValue
Writes data out to a given position in this block.

Specified by:
write in interface CacheValue
Parameters:
position - the position.
buf - the buffer.
offset - the offset in the buffer.
length - the length of bytes to write.

read

public void read(int position,
                 byte[] buf,
                 int offset,
                 int length)
Description copied from interface: CacheValue
Reads data into the buffer given the position.

Specified by:
read in interface CacheValue
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

public byte read(int position)
Description copied from interface: CacheValue
Reads a byte from the given position.

Specified by:
read in interface CacheValue
Parameters:
position - the position.
Returns:
the byte.

readShort

public short readShort(int position)
Description copied from interface: CacheValue
Reads a short from the given position.

Specified by:
readShort in interface CacheValue
Parameters:
position - the Position to read from.
Returns:
the short.

readInt

public int readInt(int position)
Description copied from interface: CacheValue
Reads a int from the given position.

Specified by:
readInt in interface CacheValue
Parameters:
position - the Position to read from.
Returns:
the int.

readLong

public long readLong(int position)
Description copied from interface: CacheValue
Reads a long from the given position.

Specified by:
readLong in interface CacheValue
Parameters:
position - the Position to read from.
Returns:
the long.

trim

public CacheValue trim(int length)
Description copied from interface: CacheValue
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.

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

detachFromCache

public CacheValue detachFromCache()
Description copied from interface: CacheValue
Detach from the base cache.

Specified by:
detachFromCache in interface CacheValue
Returns:
old cache value.

decRef

public void decRef()
Specified by:
decRef in interface CacheValue

incRef

public void incRef()
Specified by:
incRef in interface CacheValue


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