Search in sources :

Example 6 with SimplePositionedMutableByteRange

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

the class TestTableGenerator method generateHBaseDatasetBigIntOBDesc.

public static void generateHBaseDatasetBigIntOBDesc(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
    if (admin.tableExists(tableName)) {
        admin.disableTable(tableName);
        admin.deleteTable(tableName);
    }
    HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(FAMILY_F));
    if (numberRegions > 1) {
        admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions - 1));
    } else {
        admin.createTable(desc);
    }
    BufferedMutator table = conn.getBufferedMutator(tableName);
    long startTime = (long) 1438034423 * 1000;
    for (long i = startTime; i <= startTime + 100; i++) {
        byte[] bytes = new byte[9];
        PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
        OrderedBytes.encodeInt64(br, i, Order.DESCENDING);
        Put p = new Put(bytes);
        p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
        table.mutate(p);
    }
    table.close();
    admin.flush(tableName);
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) BufferedMutator(org.apache.hadoop.hbase.client.BufferedMutator) SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) PositionedByteRange(org.apache.hadoop.hbase.util.PositionedByteRange) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 7 with SimplePositionedMutableByteRange

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

the class TestUnion2 method testSkip.

@Test
public void testSkip() {
    Integer intVal = 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 8 with SimplePositionedMutableByteRange

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

the class TestOrderedBlob method testEncodedLength.

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

Example 9 with SimplePositionedMutableByteRange

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

the class TestOrderedFloat32 method testEncodedLength.

@Test
public void testEncodedLength() {
    final PositionedByteRange buffer = new SimplePositionedMutableByteRange(20);
    for (final DataType<Float> type : new OrderedFloat32[] { new OrderedFloat32(Order.ASCENDING), new OrderedFloat32(Order.DESCENDING) }) {
        for (final Float val : 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 10 with SimplePositionedMutableByteRange

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

the class TestOrderedFloat32 method testEncodeNoSupportForNull.

@Test
public void testEncodeNoSupportForNull() {
    exception.expect(IllegalArgumentException.class);
    final DataType<Float> type = new OrderedFloat32(Order.ASCENDING);
    type.encode(new SimplePositionedMutableByteRange(20), null);
}
Also used : SimplePositionedMutableByteRange(org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange) 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