use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestStructNullExtension method testNonNullableNullExtension.
/**
* Verify null extension respects the type's isNullable field.
*/
@Test(expected = NullPointerException.class)
public void testNonNullableNullExtension() {
Struct s = new StructBuilder().add(// not nullable
new RawStringTerminated("|")).toStruct();
PositionedByteRange buf = new SimplePositionedMutableByteRange(4);
s.encode(buf, new Object[1]);
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestTerminatedWrapper method testReadWriteSkippable.
@Test
public void testReadWriteSkippable() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(14);
for (final OrderedString t : new OrderedString[] { new OrderedString(Order.ASCENDING), new OrderedString(Order.DESCENDING) }) {
for (final byte[] term : TERMINATORS) {
for (final String val : VALUES_STRINGS) {
buff.setPosition(0);
final DataType<String> type = new TerminatedWrapper<>(t, term);
assertEquals(val.length() + 2 + term.length, type.encode(buff, val));
buff.setPosition(0);
assertEquals(val, type.decode(buff));
assertEquals(val.length() + 2 + term.length, buff.getPosition());
}
}
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestTerminatedWrapper method testInvalidSkip.
@Test(expected = IllegalArgumentException.class)
public void testInvalidSkip() {
final PositionedByteRange buff = new SimplePositionedMutableByteRange(Bytes.toBytes("foo"));
final DataType<byte[]> type = new TerminatedWrapper<>(new RawBytes(Order.ASCENDING), new byte[] { 0x00 });
type.skip(buff);
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestTerminatedWrapper method testSkipNonSkippable.
@Test
public void testSkipNonSkippable() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
for (byte[] term : TERMINATORS) {
for (byte[] val : VALUES_BYTES) {
buff.setPosition(0);
DataType<byte[]> type = new TerminatedWrapper<>(new RawBytes(ord), term);
int expected = type.encode(buff, val);
buff.setPosition(0);
assertEquals(expected, type.skip(buff));
assertEquals(expected, buff.getPosition());
}
}
}
}
use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange in project hbase by apache.
the class TestTerminatedWrapper method testReadWriteNonSkippable.
@Test
public void testReadWriteNonSkippable() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(12);
for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
for (byte[] term : TERMINATORS) {
for (byte[] val : VALUES_BYTES) {
buff.setPosition(0);
DataType<byte[]> type = new TerminatedWrapper<>(new RawBytes(ord), term);
assertEquals(val.length + term.length, type.encode(buff, val));
buff.setPosition(0);
assertArrayEquals(val, type.decode(buff));
assertEquals(val.length + term.length, buff.getPosition());
}
}
}
}
Aggregations