Search in sources :

Example 51 with PositionedByteRange

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

the class TestOrderedNumeric method testEncodedNullLength.

@Test
public void testEncodedNullLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    final DataType<Number> type = new OrderedNumeric(Order.ASCENDING);
    buffer.setPosition(0);
    type.encode(buffer, null);
    type.encode(new SimplePositionedMutableByteRange(20), null);
    assertEquals("encodedLength does not match actual, " + null, buffer.getPosition(), type.encodedLength(null));
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 52 with PositionedByteRange

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

the class TestOrderedNumeric method testEncodedDoubleLength.

@Test
public void testEncodedDoubleLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    for (final OrderedNumeric type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) {
        for (final Double val : DOUBLE_VALUES) {
            buffer.setPosition(0);
            type.encodeDouble(buffer, val);
            assertEquals("encodedLength does not match actual, " + val, buffer.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 53 with PositionedByteRange

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

the class TestOrderedNumeric method testEncodedLongLength.

@Test
public void testEncodedLongLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    for (final OrderedNumeric type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) {
        for (final Long val : LONG_VALUES) {
            buffer.setPosition(0);
            type.encodeLong(buffer, val);
            assertEquals("encodedLength does not match actual, " + val, buffer.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 54 with PositionedByteRange

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

the class TestUnion2 method testEncodeDecode.

@Test
public void testEncodeDecode() {
    Integer intVal = 10;
    String strVal = "hello";
    PositionedByteRange buff = new SimplePositionedMutableByteRange(10);
    SampleUnion1 type = new SampleUnion1();
    type.encode(buff, intVal);
    buff.setPosition(0);
    assertEquals(0, intVal.compareTo(type.decodeA(buff)));
    buff.setPosition(0);
    type.encode(buff, strVal);
    buff.setPosition(0);
    assertEquals(0, strVal.compareTo(type.decodeB(buff)));
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 55 with PositionedByteRange

use of org.apache.hadoop.hbase.util.PositionedByteRange in project drill by apache.

the class MaprDBCompareFunctionsProcessor method getByteBuf.

@Override
protected ByteBuf getByteBuf(LogicalExpression valueArg, String encodingType) {
    switch(encodingType) {
        case "UTF8_OB":
        case "UTF8_OBD":
            if (valueArg instanceof ValueExpressions.QuotedString) {
                int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(Charsets.UTF_8).length;
                ByteBuf bb = newByteBuf(stringLen + 2, true);
                PositionedByteRange br = new SimplePositionedMutableByteRange(bb.array(), 0, stringLen + 2);
                if (encodingType.endsWith("_OBD")) {
                    org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value, Order.DESCENDING);
                    setSortOrderAscending(false);
                } else {
                    org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value, Order.ASCENDING);
                }
                return bb;
            }
    }
    return null;
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) ValueExpressions(org.apache.drill.common.expression.ValueExpressions) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

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