|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.sparse.KeyDecoder
public class KeyDecoder
A utility class that decodes a key in a SparseRowStore into the
KeyType for the primary key, the column name, and the timestamp. Note
that the exact schema name itself is not recoverable since it is encoded
using a non-reversal algorithm (it is a sort key generated by a Unicode
collator). Likewise, the primary key can be decoded for primitive data types,
but while we can identify the bytes corresponding to the primary key for a
Unicode KeyType we can not decode them (it is also a sort key
generated by a Unicode collator). The column name is NOT stored with Unicode
compression so that we can decode it without loss (it is encoded into bytes
using UTF-8 and those bytes are written directly into the key). This means
that column names are NOT ordered according to the Unicode collator. In
practice this is not a problem since we never assume order for that part of
the key. The SparseRowStore only relies on {columnName,timestamp}
defining the semantics of distinct keys for a given {schema,primaryKey}
prefix.
The encoded schema name is followed by the KeyType.getByteCode() and
then by a nul byte. By searching for the nul
byte we can identify the end of the encoded schema name and also the data
type of the primary key. Most kinds of primary keys have a fixed length
encoding, e.g., Long, Double, etc. However, Unicode primary
keys have a variable length encoding which makes life more ... complex. Since
the keys need to reflect the total sort order we can not include the byte
count of the primary key in the key itself. The only reasonable approach is
to append a byte sequence to the key that never occurs within the generated
Unicode sort keys. We use a nul byte for this purpose since it
is not emitted by most Unicode collation implementations as it would cause
grief for C-language strings.
Schema.fromKey(IKeyBuilder, Object),
KeyType.getKeyType(byte),
AtomicRowWriteRead,
AtomicRowRead| Field Summary | |
|---|---|
long |
timestamp
The decoded timestamp on the column value. |
| Constructor Summary | |
|---|---|
KeyDecoder(byte[] key)
|
|
| Method Summary | |
|---|---|
String |
getColumnName()
The decoded column name. |
byte[] |
getPrefix()
Returns the head of the key corresponding to the encoded schema name, the primary key's KeyType, and the primary key (including any
terminating nul byte). |
Object |
getPrimaryKey()
The decoded primary key. |
KeyType |
getPrimaryKeyType()
The decoded KeyType for the primary key. |
byte[] |
getSchemaBytes()
The bytes from the key that represent the encoded name of the Schema. |
long |
getTimestamp()
The decoded timestamp on the column value. |
String |
toString()
Shows some of the data that is extracted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final long timestamp
| Constructor Detail |
|---|
public KeyDecoder(byte[] key)
| Method Detail |
|---|
public byte[] getSchemaBytes()
Schema.
public final KeyType getPrimaryKeyType()
KeyType for the primary key.
public Object getPrimaryKey()
UnsupportedOperationException - if the primary key can not be decoded (e.g., for
KeyType.Unicode keys).public final String getColumnName()
public long getTimestamp()
public byte[] getPrefix()
KeyType, and the primary key (including any
terminating nul byte).
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||