Search in sources :

Example 56 with SimplePositionedMutableByteRange

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

the class TestFixedLengthWrapper method testReadWrite.

@Test
public void testReadWrite() {
    for (int limit : limits) {
        PositionedByteRange buff = new SimplePositionedMutableByteRange(limit);
        for (Order ord : new Order[] { Order.ASCENDING, Order.DESCENDING }) {
            for (byte[] val : VALUES) {
                buff.setPosition(0);
                DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(ord), limit);
                assertEquals(limit, type.encode(buff, val));
                buff.setPosition(0);
                byte[] actual = type.decode(buff);
                assertTrue("Decoding output differs from expected", Bytes.equals(val, 0, val.length, actual, 0, val.length));
                buff.setPosition(0);
                assertEquals(limit, type.skip(buff));
            }
        }
    }
}
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 57 with SimplePositionedMutableByteRange

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

the class TestFixedLengthWrapper method testInsufficientRemainingRead.

@Test(expected = IllegalArgumentException.class)
public void testInsufficientRemainingRead() {
    final PositionedByteRange buff = new SimplePositionedMutableByteRange(0);
    final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 3);
    type.decode(buff);
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 58 with SimplePositionedMutableByteRange

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

the class TestFixedLengthWrapper method testOverflowPassthrough.

@Test(expected = IllegalArgumentException.class)
public void testOverflowPassthrough() {
    final PositionedByteRange buff = new SimplePositionedMutableByteRange(3);
    final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 0);
    type.encode(buff, Bytes.toBytes("foo"));
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 59 with SimplePositionedMutableByteRange

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

the class TestFixedLengthWrapper method testInsufficientRemainingWrite.

@Test(expected = IllegalArgumentException.class)
public void testInsufficientRemainingWrite() {
    final PositionedByteRange buff = new SimplePositionedMutableByteRange(0);
    final DataType<byte[]> type = new FixedLengthWrapper<>(new RawBytes(Order.ASCENDING), 3);
    type.encode(buff, Bytes.toBytes(""));
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 60 with SimplePositionedMutableByteRange

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

the class TestOrderedBlobVar method testEncodedLength.

@Test
public void testEncodedLength() {
    final PositionedByteRange buff = new SimplePositionedMutableByteRange(20);
    for (final DataType<byte[]> type : new OrderedBlobVar[] { new OrderedBlobVar(Order.ASCENDING), new OrderedBlobVar(Order.DESCENDING) }) {
        for (final 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)

Aggregations

SimplePositionedMutableByteRange (org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange)72 PositionedByteRange (org.apache.hadoop.hbase.util.PositionedByteRange)61 Test (org.junit.Test)45 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