Java Code Examples for org.apache.hadoop.hbase.KeyValue#write()
The following examples show how to use
org.apache.hadoop.hbase.KeyValue#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestClientKeyValueLocal.java From phoenix with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void validate(KeyValue kv, byte[] row, byte[] family, byte[] qualifier, long ts, Type type, byte[] value) throws IOException { DataOutputBuffer out = new DataOutputBuffer(); kv.write(out); out.close(); byte[] data = out.getData(); // read it back in KeyValue read = new KeyValue(); DataInputBuffer in = new DataInputBuffer(); in.reset(data, data.length); read.readFields(in); in.close(); // validate that its the same assertTrue("Row didn't match!", Bytes.equals(row, read.getRow())); assertTrue("Family didn't match!", Bytes.equals(family, read.getFamily())); assertTrue("Qualifier didn't match!", Bytes.equals(qualifier, read.getQualifier())); assertTrue("Value didn't match!", Bytes.equals(value, read.getValue())); assertEquals("Timestamp didn't match", ts, read.getTimestamp()); assertEquals("Type didn't match", type.getCode(), read.getType()); }
Example 2
Source File: KeyValueCodec.java From phoenix with Apache License 2.0 | 5 votes |
/** * Write a {@link KeyValue} or an {@link IndexedKeyValue} to the output stream. These can be read * back via {@link #readKeyValue(DataInput)} or {@link #readKeyValues(DataInput)}. * @param out to write to * @param kv {@link KeyValue} to which to write * @throws IOException if there is an error writing */ public static void write(DataOutput out, KeyValue kv) throws IOException { if (kv instanceof IndexedKeyValue) { out.writeInt(INDEX_TYPE_LENGTH_MARKER); ((IndexedKeyValue) kv).writeData(out); } else { KeyValue.write(kv, out); } }
Example 3
Source File: KeyValueCodec.java From phoenix with Apache License 2.0 | 5 votes |
/** * Write a {@link KeyValue} or an {@link IndexedKeyValue} to the output stream. These can be read * back via {@link #readKeyValue(DataInput)} or {@link #readKeyValues(DataInput)}. * @param out to write to * @param kv {@link KeyValue} to which to write * @throws IOException if there is an error writing */ public static void write(DataOutput out, KeyValue kv) throws IOException { if (kv instanceof IndexedKeyValue) { out.writeInt(INDEX_TYPE_LENGTH_MARKER); ((IndexedKeyValue) kv).writeData(out); } else { KeyValue.write(kv, out); } }
Example 4
Source File: KeyValueCodec.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Write a {@link KeyValue} or an {@link IndexedKeyValue} to the output stream. These can be read * back via {@link #readKeyValue(DataInput)} or {@link #readKeyValues(DataInput)}. * @param out to write to * @param kv {@link KeyValue} to which to write * @throws IOException if there is an error writing */ public static void write(DataOutput out, KeyValue kv) throws IOException { if (kv instanceof IndexedKeyValue) { out.writeInt(INDEX_TYPE_LENGTH_MARKER); ((IndexedKeyValue) kv).writeData(out); } else { kv.write(out); } }