public class FixedLengthValueRabaCoder extends Object implements IRabaCoder, Externalizable
version : byte size : int32 nulls : BytesUtil.bitFlagByteLength(size) values : size * lenwhere
IRaba
.null
values. The length of
the vector is rounded up to the nearest whole byte based on size.null
value as specified to the
constructor.null
values occupy the same
space in the array as non-null
values.Constructor and Description |
---|
FixedLengthValueRabaCoder()
De-serialization ctor.
|
FixedLengthValueRabaCoder(int len)
Designated constructor.
|
Modifier and Type | Method and Description |
---|---|
ICodedRaba |
decode(AbstractFixedByteArrayBuffer data)
Return an
IRaba which can access the coded data. |
AbstractFixedByteArrayBuffer |
encode(IRaba raba,
DataOutputBuffer buf)
Encode the data.
|
ICodedRaba |
encodeLive(IRaba raba,
DataOutputBuffer buf)
Encode the data, returning an
ICodedRaba . |
int |
getLength()
The required length for all non-
null values. |
boolean |
isDuplicateKeys()
Return true iff this
IRabaCoder supports duplicate keys. |
boolean |
isKeyCoder()
No.
|
boolean |
isValueCoder()
Yes.
|
void |
readExternal(ObjectInput in) |
void |
writeExternal(ObjectOutput out) |
public FixedLengthValueRabaCoder()
public FixedLengthValueRabaCoder(int len)
len
- The length of the byte[] value for each non-null
tuple. IRaba
s having values with a different length
will result in a runtime exception when they are encoded.public final boolean isKeyCoder()
isKeyCoder
in interface IRabaCoder
public final boolean isValueCoder()
isValueCoder
in interface IRabaCoder
public boolean isDuplicateKeys()
IRabaCoder
IRabaCoder
supports duplicate keys.isDuplicateKeys
in interface IRabaCoder
public final int getLength()
null
values.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public ICodedRaba encodeLive(IRaba raba, DataOutputBuffer buf)
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.
Instances of this class will reject IRaba
instances having non-
null
values whose length is not the length specified to the
constructor.
encodeLive
in interface IRabaCoder
UnsupportedOperationException
- if the IRaba
has a non-null
value with a
length other than the length specified to the constructor.public AbstractFixedByteArrayBuffer encode(IRaba raba, DataOutputBuffer buf)
IRabaCoder
Note: Implementations of this method are typically heavy. While it is
always valid to IRabaCoder.encode(IRaba, DataOutputBuffer)
an IRaba
, DO NOT invoke this arbitrarily on data which may already be
coded. The ICodedRaba
interface will always be implemented for
coded data.
encode
in interface IRabaCoder
raba
- The data.buf
- A buffer on which the coded data will be written.public ICodedRaba decode(AbstractFixedByteArrayBuffer data)
IRabaCoder
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.decode
in interface IRabaCoder
data
- The record containing the coded data.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.