com.bigdata.btree.raba.codec
Class CanonicalHuffmanRabaCoder.CodedRabaImpl

java.lang.Object
  extended by com.bigdata.btree.raba.codec.AbstractCodedRaba
      extended by com.bigdata.btree.raba.codec.CanonicalHuffmanRabaCoder.CodedRabaImpl
All Implemented Interfaces:
ICodedRaba, IRaba, Iterable<byte[]>
Enclosing class:
CanonicalHuffmanRabaCoder

public static class CanonicalHuffmanRabaCoder.CodedRabaImpl
extends AbstractCodedRaba

Decoder.

Version:
$Id: CanonicalHuffmanRabaCoder.java 2547 2010-03-24 20:44:07Z thompsonbry $
Author:
Bryan Thompson

Constructor Summary
CanonicalHuffmanRabaCoder.CodedRabaImpl(AbstractFixedByteArrayBuffer data)
          Constructor used to decode a data record.
CanonicalHuffmanRabaCoder.CodedRabaImpl(AbstractFixedByteArrayBuffer data, it.unimi.dsi.compression.Decoder decoder, long decoderInputsBitLength)
          Constructor used when encoding a data record (more information is available from the caller's context).
 
Method Summary
 int capacity()
          The capacity is equal to the size (the data are immutable).
 int copy(int index, OutputStream os)
          This decodes the value at the specified index in a single pass onto the caller's stream.
 AbstractFixedByteArrayBuffer data()
          The coded (aka compressed) data.
 byte[] get(int index)
          This uses two passes over the code words for the given index.
 boolean isEmpty()
          True iff the logical byte[][] is empty.
 boolean isFull()
          Always returns true since size() == capacity() by definition for this class.
 boolean isKeys()
          When true the IRaba supports search and elements are interpreted as unsigned byte[]s (B+Tree keys).
 boolean isNull(int index)
          Return true iff the byte[] at that index is null.
 Iterator<byte[]> iterator()
          Basic implementation may be overridden if a faster implementation is available.
 int length(int index)
          This computes the length of the decoded byte[] by counting the code words for the coded value.
 int search(byte[] probe)
          This is an efficient binary search performed without materializing the coded byte[][].
 int size()
          The #of entries in the logical byte[][].
 
Methods inherited from class com.bigdata.btree.raba.codec.AbstractCodedRaba
add, add, add, isReadOnly, set, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CanonicalHuffmanRabaCoder.CodedRabaImpl

public CanonicalHuffmanRabaCoder.CodedRabaImpl(AbstractFixedByteArrayBuffer data)
Constructor used to decode a data record.

Parameters:
data - The record containing the coded data.

CanonicalHuffmanRabaCoder.CodedRabaImpl

public CanonicalHuffmanRabaCoder.CodedRabaImpl(AbstractFixedByteArrayBuffer data,
                                               it.unimi.dsi.compression.Decoder decoder,
                                               long decoderInputsBitLength)
Constructor used when encoding a data record (more information is available from the caller's context).

Parameters:
data - The record containing the coded data.
decoder - The decoder (optional). When not given the decoder is reconstructed from the record.
decoderInputsBitLength - The bit length of the HuffmanCodec.DecoderInputs in the coded data record. This information is used to skip beyond the HuffmanCodec.DecoderInputs without having to read them from the InputBitStream.
Method Detail

size

public final int size()
Description copied from interface: IRaba
The #of entries in the logical byte[][].


capacity

public final int capacity()
The capacity is equal to the size (the data are immutable).


isEmpty

public final boolean isEmpty()
Description copied from interface: IRaba
True iff the logical byte[][] is empty.


isFull

public final boolean isFull()
Always returns true since size() == capacity() by definition for this class.


isKeys

public final boolean isKeys()
Description copied from interface: IRaba
When true the IRaba supports search and elements are interpreted as unsigned byte[]s (B+Tree keys). For this case the application MUST ensure that the elements are maintained in unsigned byte[] order and that duplicates byte[]s are not stored.

When false, the IRaba allows nulls and the elements are interpreted as signed byte[] (B+Tree values).

Returns:
true if the IRaba represents B+Tree keys and false if it represents B+Tree values.

data

public AbstractFixedByteArrayBuffer data()
Description copied from interface: ICodedRaba
The coded (aka compressed) data.


isNull

public boolean isNull(int index)
Description copied from interface: IRaba
Return true iff the byte[] at that index is null. If IRaba.isKeys() would return true then this method MUST return false since nulls are not permitted for B+Tree keys.

Parameters:
index - The index in [0:IRaba.size()-1].

length

public int length(int index)
This computes the length of the decoded byte[] by counting the code words for the coded value.

Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The length of the byte[] at that index.

get

public byte[] get(int index)
This uses two passes over the code words for the given index. The first pass figures out the #of bytes in the decoded byte[] and allocates the byte[]. The second pass decodes into the allocated byte[].

Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The byte[] value at that index and null if a null value was stored at that index.

copy

public int copy(int index,
                OutputStream os)
This decodes the value at the specified index in a single pass onto the caller's stream.

Parameters:
index - The index in [0:IRaba.size()-1].
Returns:
The #of bytes copied.

iterator

public Iterator<byte[]> iterator()
Basic implementation may be overridden if a faster implementation is available.

Specified by:
iterator in interface IRaba
Specified by:
iterator in interface Iterable<byte[]>
Overrides:
iterator in class AbstractCodedRaba

search

public int search(byte[] probe)
This is an efficient binary search performed without materializing the coded byte[][].

Parameters:
probe - The search key.
Returns:
index of the search key, if it is found; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted. Note that this guarantees that the return value will be >= 0 if and only if the key is found.


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