com.bigdata.btree.raba.codec
Class EmptyRabaValueCoder

java.lang.Object
  extended by com.bigdata.btree.raba.codec.EmptyRabaValueCoder
All Implemented Interfaces:
IRabaCoder, Externalizable, Serializable

public class EmptyRabaValueCoder
extends Object
implements IRabaCoder, Externalizable

Useful when a B+Tree uses keys but not values. The coder maintains the IRaba.size(), but any byte[] values stored under the B+Tree will be discarded by this IRabaCoder.

Version:
$Id: EmptyRabaValueCoder.java 2547 2010-03-24 20:44:07Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Field Summary
static EmptyRabaValueCoder INSTANCE
           
 
Constructor Summary
EmptyRabaValueCoder()
           
 
Method Summary
 ICodedRaba decode(AbstractFixedByteArrayBuffer data)
          Return an IRaba which can access the coded data.
 AbstractFixedByteArrayBuffer encode(IRaba raba, DataOutputBuffer buf)
          Any data in the IRaba will be discarded! Only the IRaba.size() is maintained.
 ICodedRaba encodeLive(IRaba raba, DataOutputBuffer buf)
          Encode the data, returning an ICodedRaba.
 boolean isKeyCoder()
          No.
 boolean isValueCoder()
          Yes.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final transient EmptyRabaValueCoder INSTANCE
Constructor Detail

EmptyRabaValueCoder

public EmptyRabaValueCoder()
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

isKeyCoder

public final boolean isKeyCoder()
No. Keys can not be constrained to be empty.

Specified by:
isKeyCoder in interface IRabaCoder

isValueCoder

public final boolean isValueCoder()
Yes.

Specified by:
isValueCoder in interface IRabaCoder

encodeLive

public ICodedRaba encodeLive(IRaba raba,
                             DataOutputBuffer buf)
Description copied from interface: IRabaCoder
Encode the data, returning an ICodedRaba. Implementations of this method should be optimized for the very common use case where the caller requires immediate access to the coded data record. In that case, many of the IRabaCoder implementations can be optimized by passing the underlying decoding object directly into an alternative constructor for the ICodedRaba. The byte[] slice for the coded data record is available from ICodedRaba.data().

This method covers the vast major of the use cases for coding data, which is to code B+Tree keys or values for a node or leaf that has been evicted from the AbstractBTree's write retention queue. The common use case is to wrap a coded record that was read from an IRawStore. The IndexSegmentBuilder is a special case, since the coded record will not be used other than to write it on the disk.

Specified by:
encodeLive in interface IRabaCoder

encode

public AbstractFixedByteArrayBuffer encode(IRaba raba,
                                           DataOutputBuffer buf)
Any data in the IRaba will be discarded! Only the IRaba.size() is maintained.

Specified by:
encode in interface IRabaCoder
Parameters:
raba - The data.
buf - A buffer on which the coded data will be written.
Returns:
A slice onto the post-condition state of the caller's buffer whose view corresponds to the coded record. This may be written directly onto an output stream or the slice may be converted to an exact fit byte[].

decode

public ICodedRaba decode(AbstractFixedByteArrayBuffer data)
Description copied from interface: IRabaCoder
Return an IRaba which can access the coded data. In general, implementations SHOULD NOT materialize a backing byte[][]. Instead, the implementation should access the data in place within the caller's buffer. Frequently used fields MAY be cached, but the whole point of the IRabaCoder is to minimize the in-memory footprint for the B+Tree by using a coded (aka compressed) representation of the keys and values whenever possible.

Specified by:
decode in interface IRabaCoder
Parameters:
data - The record containing the coded data.
Returns:
A view of the coded data.


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.