Search in sources :

Example 21 with SimplePositionedMutableByteRange

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

Example 22 with SimplePositionedMutableByteRange

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

Example 23 with SimplePositionedMutableByteRange

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

Example 24 with SimplePositionedMutableByteRange

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());
            }
        }
    }
}
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 25 with SimplePositionedMutableByteRange

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());
            }
        }
    }
}
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)

Aggregations

SimplePositionedMutableByteRange (org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange)68 PositionedByteRange (org.apache.hadoop.hbase.util.PositionedByteRange)61 Test (org.junit.Test)44 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)16 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)16 BufferedMutator (org.apache.hadoop.hbase.client.BufferedMutator)16 Put (org.apache.hadoop.hbase.client.Put)16 ByteBuf (io.netty.buffer.ByteBuf)6 FunctionCall (org.apache.drill.common.expression.FunctionCall)4 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)4 SchemaPath (org.apache.drill.common.expression.SchemaPath)4 BooleanExpression (org.apache.drill.common.expression.ValueExpressions.BooleanExpression)4 DateExpression (org.apache.drill.common.expression.ValueExpressions.DateExpression)4 DoubleExpression (org.apache.drill.common.expression.ValueExpressions.DoubleExpression)4 FloatExpression (org.apache.drill.common.expression.ValueExpressions.FloatExpression)4 IntExpression (org.apache.drill.common.expression.ValueExpressions.IntExpression)4 LongExpression (org.apache.drill.common.expression.ValueExpressions.LongExpression)4 QuotedString (org.apache.drill.common.expression.ValueExpressions.QuotedString)4 TimeExpression (org.apache.drill.common.expression.ValueExpressions.TimeExpression)4 Order (org.apache.hadoop.hbase.util.Order)4