Java Code Examples for org.apache.hadoop.hbase.util.PositionedByteRange#put()
The following examples show how to use
org.apache.hadoop.hbase.util.PositionedByteRange#put() .
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: FixedLengthWrapper.java From hbase with Apache License 2.0 | 6 votes |
@Override public int encode(PositionedByteRange dst, T val) { if (dst.getRemaining() < length) { throw new IllegalArgumentException("Not enough buffer remaining. dst.offset: " + dst.getOffset() + " dst.length: " + dst.getLength() + " dst.position: " + dst.getPosition() + " max length: " + length); } int written = base.encode(dst, val); if (written > length) { throw new IllegalArgumentException("Length of encoded value (" + written + ") exceeds max length (" + length + ")."); } // TODO: is the zero-padding appropriate? for (; written < length; written++) { dst.put((byte) 0x00); } return written; }
Example 2
Source File: PDataType.java From phoenix with Apache License 2.0 | 5 votes |
@Override public int encode(PositionedByteRange pbr, T val) { // default implementation based on existing PDataType methods. int pos = pbr.getPosition(); pbr.put(toBytes(val)); return pbr.getPosition() - pos; }
Example 3
Source File: RawString.java From hbase with Apache License 2.0 | 5 votes |
@Override public int encode(PositionedByteRange dst, String val) { byte[] s = Bytes.toBytes(val); order.apply(s); dst.put(s); return s.length; }
Example 4
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; }
Example 5
Source File: PDataType.java From phoenix with Apache License 2.0 | 5 votes |
@Override public int encode(PositionedByteRange pbr, T val) { // default implementation based on existing PDataType methods. int pos = pbr.getPosition(); pbr.put(toBytes(val)); return pbr.getPosition() - pos; }