|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hbase.async.KeyValue
public final class KeyValue
A "cell" in an HBase table.
This represents one unit of HBase data, one "record".
byte
arraysbyte[]
that's given to it, neither
will it create a copy before returning one to you.
Changing a byte array get from or pass to this class will have
unpredictable consequences. In particular, multiple
KeyValue
instances may share the same byte arrays, so changing
one instance may also unexpectedly affect others.
Field Summary | |
---|---|
static long |
TIMESTAMP_NOW
Timestamp value to let the server set the timestamp at processing time. |
Constructor Summary | |
---|---|
KeyValue(byte[] key,
byte[] family,
byte[] qualifier,
byte[] value)
Constructor. |
|
KeyValue(byte[] key,
byte[] family,
byte[] qualifier,
long timestamp,
byte[] value)
Constructor. |
Method Summary | |
---|---|
int |
compareTo(KeyValue other)
|
boolean |
equals(Object other)
|
byte[] |
family()
Returns the column family. |
static KeyValue |
fromBuffer(ChannelBuffer buf,
KeyValue prev)
De-serializes KeyValue from a buffer. |
int |
hashCode()
|
byte[] |
key()
Returns the row key. |
byte[] |
qualifier()
Returns the column qualifier. |
long |
timestamp()
Returns the timestamp stored in this KeyValue . |
String |
toString()
|
byte[] |
value()
Returns the value, the contents of the cell. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long TIMESTAMP_NOW
KeyValue
, the server
will substitute a real timestamp at the time it processes it. HBase uses
current UNIX time in milliseconds.
Constructor Detail |
---|
public KeyValue(byte[] key, byte[] family, byte[] qualifier, long timestamp, byte[] value)
key
- The row key. Length must fit in 16 bits.family
- The column family. Length must fit in 8 bits.qualifier
- The column qualifier.timestamp
- Timestamp on the value. This timestamp can be set to
guarantee ordering of values or operations. It is strongly advised to
use a UNIX timestamp in milliseconds, e.g. from a source such as
System.currentTimeMillis()
. This value must be strictly positive.value
- The value, the contents of the cell.
IllegalArgumentException
- if any argument is invalid (e.g. array
size is too long) or if the timestamp is negative.public KeyValue(byte[] key, byte[] family, byte[] qualifier, byte[] value)
This KeyValue
will be timestamped by the server at the time
the server processes it.
key
- The row key. Length must fit in 16 bits.family
- The column family. Length must fit in 8 bits.qualifier
- The column qualifier.value
- The value, the contents of the cell.
IllegalArgumentException
- if any argument is invalid (e.g. array
size is too long).TIMESTAMP_NOW
Method Detail |
---|
public byte[] key()
public byte[] family()
public byte[] qualifier()
public long timestamp()
KeyValue
.
TIMESTAMP_NOW
public byte[] value()
public int compareTo(KeyValue other)
compareTo
in interface Comparable<KeyValue>
public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public static KeyValue fromBuffer(ChannelBuffer buf, KeyValue prev)
KeyValue
from a buffer.
buf
- The buffer to de-serialize from.prev
- Another KeyValue
previously de-serialized from the
same buffer. Can be null
. The idea here is that KeyValues
often come in a sorted batch, and often share a number of byte arrays
(e.g. they all have the same row key and/or same family...). When
you specify another KeyValue, its byte arrays will be re-used in order
to avoid having too much duplicate data in memory. This costs a little
bit of CPU time to compare the arrays but saves memory (which in turns
saves CPU time later).
null
).
IllegalArgumentException
- if the buffer seems to contain a
malformed KeyValue
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |