Search in sources :

Example 1 with SimplePositionedByteRange

use of org.apache.hadoop.hbase.util.SimplePositionedByteRange in project hbase by apache.

the class TestPBCell method testRoundTrip.

/**
   * Basic test to verify utility methods in {@link PBType} and delegation to protobuf works.
   */
@Test
public void testRoundTrip() {
    final Cell cell = new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("fam"), Bytes.toBytes("qual"), Bytes.toBytes("val"));
    CellProtos.Cell c = ProtobufUtil.toCell(cell), decoded;
    PositionedByteRange pbr = new SimplePositionedByteRange(c.getSerializedSize());
    pbr.setPosition(0);
    int encodedLength = CODEC.encode(pbr, c);
    pbr.setPosition(0);
    decoded = CODEC.decode(pbr);
    assertEquals(encodedLength, pbr.getPosition());
    assertTrue(CellUtil.equals(cell, ProtobufUtil.toCell(decoded)));
}
Also used : KeyValue(org.apache.hadoop.hbase.KeyValue) SimplePositionedByteRange(org.apache.hadoop.hbase.util.SimplePositionedByteRange) CellProtos(org.apache.hadoop.hbase.protobuf.generated.CellProtos) SimplePositionedByteRange(org.apache.hadoop.hbase.util.SimplePositionedByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Aggregations

Cell (org.apache.hadoop.hbase.Cell)1 KeyValue (org.apache.hadoop.hbase.KeyValue)1 CellProtos (org.apache.hadoop.hbase.protobuf.generated.CellProtos)1 PositionedByteRange (org.apache.hadoop.hbase.util.PositionedByteRange)1 SimplePositionedByteRange (org.apache.hadoop.hbase.util.SimplePositionedByteRange)1 Test (org.junit.Test)1