A "cell" in an HBase table. This represents one unit of HBase data, one "record". A note byte arrays This class will never copy any byte[] 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 th
| 49 | * one instance may also unexpectedly affect others. |
| 50 | */ |
| 51 | public final class KeyValue implements Comparable<KeyValue> { |
| 52 | |
| 53 | /** |
| 54 | * Timestamp value to let the server set the timestamp at processing time. |
| 55 | * When this value is used as a timestamp on a {@code KeyValue}, the server |
| 56 | * will substitute a real timestamp at the time it processes it. HBase uses |
| 57 | * current UNIX time in milliseconds. |
| 58 | */ |
| 59 | public static final long TIMESTAMP_NOW = Long.MAX_VALUE; |
| 60 | |
| 61 | //private static final Logger LOG = LoggerFactory.getLogger(KeyValue.class); |
| 62 | |
| 63 | private final byte[] key; // Max length: Short.MAX_VALUE = 32768 |
| 64 | private final byte[] family; // Max length: Byte.MAX_VALUE = 128 |
| 65 | private final byte[] qualifier; |
| 66 | private final byte[] value; |
| 67 | private final long timestamp; |
| 68 | //private final byte type; // Not needed for us ATM. |
| 69 | |
| 70 | // Note: type can be one of: |
| 71 | // - 4 0b00000100 Put |
| 72 | static final byte PUT = 4; |
| 73 | // - 8 0b00001000 Delete (delete the specified version of a cell) |
| 74 | static final byte DELETE = 8; |
| 75 | // - 12 0b00001100 DeleteColumn (delete all previous versions of a cell) |
| 76 | static final byte DELETE_COLUMN = 12; |
| 77 | // - 14 0b01110010 DeleteFamily (delete all cells within a family) |
| 78 | static final byte DELETE_FAMILY = 14; |
| 79 | // (Not sure how those have been assigned... Randomly maybe?) |
| 80 | |
| 81 | /** |
| 82 | * Constructor. |
| 83 | * @param key The row key. Length must fit in 16 bits. |
| 84 | * @param family The column family. Length must fit in 8 bits. |
| 85 | * @param qualifier The column qualifier. |
| 86 | * @param timestamp Timestamp on the value. This timestamp can be set to |
| 87 | * guarantee ordering of values or operations. It is strongly advised to |
| 88 | * use a UNIX timestamp in milliseconds, e.g. from a source such as |
| 89 | * {@link System#currentTimeMillis}. This value must be strictly positive. |
| 90 | * @param value The value, the contents of the cell. |
| 91 | * @throws IllegalArgumentException if any argument is invalid (e.g. array |
| 92 | * size is too long) or if the timestamp is negative. |
| 93 | * @since 1.2 |
| 94 | */ |
| 95 | public KeyValue(final byte[] key, |
| 96 | final byte[] family, final byte[] qualifier, |
| 97 | final long timestamp, |
| 98 | //final byte type, |
| 99 | final byte[] value) { |
| 100 | checkKey(key); |
| 101 | checkFamily(family); |
| 102 | checkQualifier(qualifier); |
| 103 | checkTimestamp(timestamp); |
| 104 | checkValue(value); |
| 105 | this.key = key; |
| 106 | this.family = family; |
| 107 | this.qualifier = qualifier; |
| 108 | this.value = value; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…