use of org.apache.hadoop.hbase.util.PositionedByteRange 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());
}
}
}
}
use of org.apache.hadoop.hbase.util.PositionedByteRange 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.PositionedByteRange in project hbase by apache.
the class TestUnion2 method testSkip.
@Test
public void testSkip() {
Integer intVal = Integer.valueOf(10);
String strVal = "hello";
PositionedByteRange buff = new SimplePositionedMutableByteRange(10);
SampleUnion1 type = new SampleUnion1();
int len = type.encode(buff, intVal);
buff.setPosition(0);
assertEquals(len, type.skip(buff));
buff.setPosition(0);
len = type.encode(buff, strVal);
buff.setPosition(0);
assertEquals(len, type.skip(buff));
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestOrderedBlob method testEncodedLength.
@Test
public void testEncodedLength() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
for (DataType<byte[]> type : new OrderedBlob[] { OrderedBlob.ASCENDING, OrderedBlob.DESCENDING }) {
for (byte[] val : VALUES) {
buff.setPosition(0);
type.encode(buff, val);
assertEquals("encodedLength does not match actual, " + Bytes.toStringBinary(val), buff.getPosition(), type.encodedLength(val));
}
}
}
use of org.apache.hadoop.hbase.util.PositionedByteRange in project hbase by apache.
the class TestOrderedString method testEncodedLength.
@Test
public void testEncodedLength() {
PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
for (DataType<String> type : new OrderedString[] { OrderedString.ASCENDING, OrderedString.DESCENDING }) {
for (String val : VALUES) {
buff.setPosition(0);
type.encode(buff, val);
assertEquals("encodedLength does not match actual, " + val, buff.getPosition(), type.encodedLength(val));
}
}
}
Aggregations