Search in sources :

Example 6 with PositionedByteRange

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());
            }
        }
    }
}
Also used : Order(org.apache.hadoop.hbase.util.Order) SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 7 with PositionedByteRange

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());
            }
        }
    }
}
Also used : Order(org.apache.hadoop.hbase.util.Order) SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 8 with PositionedByteRange

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));
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 9 with PositionedByteRange

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));
        }
    }
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 10 with PositionedByteRange

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));
        }
    }
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Aggregations

PositionedByteRange (org.apache.hadoop.hbase.util.PositionedByteRange)32 SimplePositionedMutableByteRange (org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange)30 Test (org.junit.Test)20 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)8 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)8 BufferedMutator (org.apache.hadoop.hbase.client.BufferedMutator)8 Put (org.apache.hadoop.hbase.client.Put)8 Order (org.apache.hadoop.hbase.util.Order)4 ByteBuf (io.netty.buffer.ByteBuf)2 FunctionCall (org.apache.drill.common.expression.FunctionCall)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 BooleanExpression (org.apache.drill.common.expression.ValueExpressions.BooleanExpression)2 DateExpression (org.apache.drill.common.expression.ValueExpressions.DateExpression)2 DoubleExpression (org.apache.drill.common.expression.ValueExpressions.DoubleExpression)2 FloatExpression (org.apache.drill.common.expression.ValueExpressions.FloatExpression)2 IntExpression (org.apache.drill.common.expression.ValueExpressions.IntExpression)2 LongExpression (org.apache.drill.common.expression.ValueExpressions.LongExpression)2 QuotedString (org.apache.drill.common.expression.ValueExpressions.QuotedString)2 TimeExpression (org.apache.drill.common.expression.ValueExpressions.TimeExpression)2