Java Code Examples for org.apache.hadoop.hbase.util.PositionedByteRange#setLength()
The following examples show how to use
org.apache.hadoop.hbase.util.PositionedByteRange#setLength() .
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: LabelConnectionModel.java From hgraphdb with Apache License 2.0 | 5 votes |
public byte[] serialize(String outVertexLabel, String edgeLabel, String inVertexLabel) { PositionedByteRange buffer = new DynamicPositionedMutableByteRange(4096); OrderedBytes.encodeString(buffer, outVertexLabel, Order.ASCENDING); OrderedBytes.encodeString(buffer, edgeLabel, Order.ASCENDING); OrderedBytes.encodeString(buffer, inVertexLabel, Order.ASCENDING); buffer.setLength(buffer.getPosition()); buffer.setPosition(0); byte[] bytes = new byte[buffer.getRemaining()]; buffer.get(bytes); return bytes; }
Example 2
Source File: IndexMetadataModel.java From hgraphdb with Apache License 2.0 | 5 votes |
public byte[] serialize(IndexMetadata.Key index) { PositionedByteRange buffer = new DynamicPositionedMutableByteRange(4096); OrderedBytes.encodeString(buffer, index.label(), Order.ASCENDING); OrderedBytes.encodeString(buffer, index.propertyKey(), Order.ASCENDING); OrderedBytes.encodeInt8(buffer, index.type() == ElementType.VERTEX ? (byte) 1 : (byte) 0, Order.ASCENDING); buffer.setLength(buffer.getPosition()); buffer.setPosition(0); byte[] bytes = new byte[buffer.getRemaining()]; buffer.get(bytes); return bytes; }
Example 3
Source File: TerminatedWrapper.java From hbase with Apache License 2.0 | 5 votes |
/** * Write instance {@code val} into buffer {@code dst}. * @throws IllegalArgumentException when the encoded representation of * {@code val} contains the {@code term} sequence. */ @Override public int encode(PositionedByteRange dst, T val) { final int start = dst.getPosition(); int written = wrapped.encode(dst, val); PositionedByteRange b = dst.shallowCopy(); b.setLength(dst.getPosition()); b.setPosition(start); if (-1 != terminatorPosition(b)) { dst.setPosition(start); throw new IllegalArgumentException("Encoded value contains terminator sequence."); } dst.put(term); return written + term.length; }