Search in sources :

Example 16 with BufferedMutator

use of org.apache.hadoop.hbase.client.BufferedMutator in project drill by apache.

the class TestTableGenerator method generateHBaseDataset1.

public static void generateHBaseDataset1(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("f"));
    desc.addFamily(new HColumnDescriptor("f2"));
    if (numberRegions > 1) {
        admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions - 1));
    } else {
        admin.createTable(desc);
    }
    BufferedMutator table = conn.getBufferedMutator(tableName);
    Put p = new Put("a1".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
    p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
    p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("a2".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
    p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
    p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("a3".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "3".getBytes());
    p.addColumn("f".getBytes(), "c7".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c8".getBytes(), "5".getBytes());
    p.addColumn("f".getBytes(), "c9".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put(new byte[] { 'b', '4', 0 });
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f2".getBytes(), "c2".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
    p.addColumn("f2".getBytes(), "c4".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
    p.addColumn("f2".getBytes(), "c6".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("b4".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f2".getBytes(), "c2".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
    p.addColumn("f2".getBytes(), "c4".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
    p.addColumn("f2".getBytes(), "c6".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("b5".getBytes());
    p.addColumn("f2".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
    p.addColumn("f2".getBytes(), "c3".getBytes(), "3".getBytes());
    p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
    p.addColumn("f2".getBytes(), "c5".getBytes(), "5".getBytes());
    p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("b6".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f2".getBytes(), "c3".getBytes(), "2".getBytes());
    p.addColumn("f".getBytes(), "c5".getBytes(), "3".getBytes());
    p.addColumn("f2".getBytes(), "c7".getBytes(), "4".getBytes());
    p.addColumn("f".getBytes(), "c8".getBytes(), "5".getBytes());
    p.addColumn("f2".getBytes(), "c9".getBytes(), "6".getBytes());
    table.mutate(p);
    p = new Put("b7".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
    p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
    table.mutate(p);
    table.close();
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) BufferedMutator(org.apache.hadoop.hbase.client.BufferedMutator) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 17 with BufferedMutator

use of org.apache.hadoop.hbase.client.BufferedMutator in project drill by apache.

the class TestTableGenerator method generateHBaseDatasetDoubleOB.

public static void generateHBaseDatasetDoubleOB(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.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 18 with BufferedMutator

use of org.apache.hadoop.hbase.client.BufferedMutator in project drill by apache.

the class TestTableGenerator method generateHBaseDatasetBigIntOB.

public static void generateHBaseDatasetBigIntOB(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.ASCENDING);
        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 19 with BufferedMutator

use of org.apache.hadoop.hbase.client.BufferedMutator in project drill by apache.

the class TestTableGenerator method generateHBaseDatasetNullStr.

public static void generateHBaseDatasetNullStr(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("f"));
    if (numberRegions > 1) {
        admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions - 1));
    } else {
        admin.createTable(desc);
    }
    BufferedMutator table = conn.getBufferedMutator(tableName);
    Put p = new Put("a1".getBytes());
    p.addColumn("f".getBytes(), "c1".getBytes(), "".getBytes());
    p.addColumn("f".getBytes(), "c2".getBytes(), "".getBytes());
    p.addColumn("f".getBytes(), "c3".getBytes(), "5".getBytes());
    p.addColumn("f".getBytes(), "c4".getBytes(), "".getBytes());
    table.mutate(p);
    table.close();
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) BufferedMutator(org.apache.hadoop.hbase.client.BufferedMutator) Put(org.apache.hadoop.hbase.client.Put) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 20 with BufferedMutator

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

Aggregations

BufferedMutator (org.apache.hadoop.hbase.client.BufferedMutator)25 Put (org.apache.hadoop.hbase.client.Put)19 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)16 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)16 PositionedByteRange (org.apache.hadoop.hbase.util.PositionedByteRange)8 SimplePositionedMutableByteRange (org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange)8 TableName (org.apache.hadoop.hbase.TableName)3 Connection (org.apache.hadoop.hbase.client.Connection)3 Table (org.apache.hadoop.hbase.client.Table)3 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 Mutation (org.apache.hadoop.hbase.client.Mutation)2 IOException (java.io.IOException)1 Key (java.security.Key)1 SecureRandom (java.security.SecureRandom)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1