use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestFixedLengthWrapper method testReadWrite.
@Test
public void testReadWrite() {
for (int limit : limits) {
PositionedByteRange buff = new SimplePositionedMutableByteRange(limit);
for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
for (byte[] val : VALUES) {
buff.setPosition(0);
DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(ord), limit);
assertEquals(limit, type.encode(buff, val));
buff.setPosition(0);
byte[] actual = type.decode(buff);
assertTrue("Decoding output differs from expected", Bytes.equals(val, 0, val.length, actual, 0, val.length));
buff.setPosition(0);
assertEquals(limit, type.skip(buff));
}
}
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestFixedLengthWrapper method testInsufficientRemainingRead.
@Test(expected = IllegalArgumentException.class)
public void testInsufficientRemainingRead() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(0);
final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 3);
type.decode(buff);
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestFixedLengthWrapper method testOverflowPassthrough.
@Test(expected = IllegalArgumentException.class)
public void testOverflowPassthrough() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(3);
final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 0);
type.encode(buff, Bytes.toBytes("foo"));
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestFixedLengthWrapper method testInsufficientRemainingWrite.
@Test(expected = IllegalArgumentException.class)
public void testInsufficientRemainingWrite() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(0);
final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 3);
type.encode(buff, Bytes.toBytes(""));
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestOrderedBlobVar method testEncodedLength.
@Test
public void testEncodedLength() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
for (final DataType<byte[]> type : new OrderedBlobVar[] { new OrderedBlobVar(Order.ASCENDING), new OrderedBlobVar(Order.DESCENDING) }) {
for (final byte[] val : VALUES) {
buff.setPosition(0);
type.encode(buff, val);
assertEquals("encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val));
}
}
}
Aggregations