Search in sources :

Example 16 with SimplePositionedMutableByteRange

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

the class TestOrderedInt8 method testEncodeNoSupportForNull.

@Test
public void testEncodeNoSupportForNull() {
    exception.expect(IllegalArgumentException.class);
    final DataType<Byte> type = new OrderedInt8(Order.ASCENDING);
    type.encode(new SimplePositionedMutableByteRange(20), null);
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) Test(org.junit.Test)

Example 17 with SimplePositionedMutableByteRange

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

the class TestOrderedNumeric method testEncodedBigIntegerLength.

@Test
public void testEncodedBigIntegerLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    for (final DataType<Number> type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) {
        for (final Number val : BIG_INTEGER_VALUES) {
            buffer.setPosition(0);
            type.encode(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 18 with SimplePositionedMutableByteRange

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

the class TestOrderedNumeric method testEncodedLength.

@Test
public void testEncodedLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    for (final DataType<Number> type : new OrderedNumeric[] { new OrderedNumeric(Order.ASCENDING), new OrderedNumeric(Order.DESCENDING) }) {
        for (final Number val : DOUBLE_VALUES) {
            buffer.setPosition(0);
            type.encode(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 19 with SimplePositionedMutableByteRange

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

the class TestStruct method testOrderPreservation.

@Test
@SuppressWarnings("unchecked")
public void testOrderPreservation() throws Exception {
    Object[] vals = new Object[constructorArgs.length];
    PositionedByteRange[] encodedGeneric = new PositionedByteRange[constructorArgs.length];
    PositionedByteRange[] encodedSpecialized = new PositionedByteRange[constructorArgs.length];
    Constructor<?> ctor = specialized.encodedClass().getConstructor(Object[].class);
    for (int i = 0; i < vals.length; i++) {
        vals[i] = ctor.newInstance(new Object[] { constructorArgs[i] });
        encodedGeneric[i] = new SimplePositionedMutableByteRange(generic.encodedLength(constructorArgs[i]));
        encodedSpecialized[i] = new SimplePositionedMutableByteRange(specialized.encodedLength(vals[i]));
    }
    // populate our arrays
    for (int i = 0; i < vals.length; i++) {
        generic.encode(encodedGeneric[i], constructorArgs[i]);
        encodedGeneric[i].setPosition(0);
        specialized.encode(encodedSpecialized[i], vals[i]);
        encodedSpecialized[i].setPosition(0);
        assertArrayEquals(encodedGeneric[i].getBytes(), encodedSpecialized[i].getBytes());
    }
    Arrays.sort(vals);
    Arrays.sort(encodedGeneric);
    Arrays.sort(encodedSpecialized);
    for (int i = 0; i < vals.length; i++) {
        assertEquals("Struct encoder does not preserve sort order at position " + i, vals[i], ctor.newInstance(new Object[] { generic.decode(encodedGeneric[i]) }));
        assertEquals("Specialized encoder does not preserve sort order at position " + i, vals[i], specialized.decode(encodedSpecialized[i]));
    }
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Test(org.junit.Test)

Example 20 with SimplePositionedMutableByteRange

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

the class TestOrderedString method testEncodedLength.

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

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