Search in sources :

Example 36 with SimplePositionedMutableByteRange

use of org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange 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)

Example 37 with SimplePositionedMutableByteRange

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

the class TestTableGenerator method generateHBaseDatasetDoubleOBDesc.

public static void generateHBaseDatasetDoubleOBDesc(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);
    for (double i = 0.5; i <= 100.00; i += 0.75) {
        byte[] bytes = new byte[9];
        PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
        OrderedBytes.encodeFloat64(br, i, Order.DESCENDING);
        Put p = new Put(bytes);
        p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", 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 38 with SimplePositionedMutableByteRange

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

the class TestTableGenerator method generateHBaseDatasetFloatOBDesc.

public static void generateHBaseDatasetFloatOBDesc(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);
    for (float i = (float) 0.5; i <= 100.00; i += 0.75) {
        byte[] bytes = new byte[5];
        PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
        OrderedBytes.encodeFloat32(br, i, Order.DESCENDING);
        Put p = new Put(bytes);
        p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", 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 39 with SimplePositionedMutableByteRange

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

the class TestTableGenerator method generateHBaseDatasetFloatOB.

public static void generateHBaseDatasetFloatOB(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);
    for (float i = (float) 0.5; i <= 100.00; i += 0.75) {
        byte[] bytes = new byte[5];
        PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
        OrderedBytes.encodeFloat32(br, i, Order.ASCENDING);
        Put p = new Put(bytes);
        p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", 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 40 with SimplePositionedMutableByteRange

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

the class TestTableGenerator method generateHBaseDatasetIntOBDesc.

public static void generateHBaseDatasetIntOBDesc(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);
    for (int i = -49; i <= 100; i++) {
        byte[] bytes = new byte[5];
        PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
        OrderedBytes.encodeInt32(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)

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