Package util

Examples of util.HBaseHelper


public class ColumnPaginationFilterExample {

  public static void main(String[] args) throws IOException {
    Configuration conf = HBaseConfiguration.create();

    HBaseHelper helper = HBaseHelper.getHelper(conf);
    helper.dropTable("testtable");
    helper.createTable("testtable", "colfam1");
    System.out.println("Adding rows to table...");
    helper.fillTable("testtable", 1, 10, 30, 2, true, "colfam1");

    HTable table = new HTable(conf, "testtable");

    // vv ColumnPaginationFilterExample
    Filter filter = new ColumnPaginationFilter(5, 15);
View Full Code Here


    // ^^ BatchExample

  public static void main(String[] args) throws IOException, InterruptedException {
    Configuration conf = HBaseConfiguration.create();

    HBaseHelper helper = HBaseHelper.getHelper(conf);
    helper.dropTable("testtable");
    helper.createTable("testtable", "colfam1", "colfam2");
    helper.put("testtable",
      new String[] { "row1" },
      new String[] { "colfam1" },
      new String[] { "qual1", "qual2", "qual3" },
      new long[] { 1, 2, 3 },
      new String[] { "val1", "val2", "val3" });
    System.out.println("Before batch call...");
    helper.dump("testtable", new String[] { "row1", "row2" }, null, null);

    HTable table = new HTable(conf, "testtable");

    // vv BatchExample
    List<Row> batch = new ArrayList<Row>(); // co BatchExample-2-CreateList Create a list to hold all values.

    Put put = new Put(ROW2);
    put.add(COLFAM2, QUAL1, Bytes.toBytes("val5")); // co BatchExample-3-AddPut Add a Put instance.
    batch.add(put);

    Get get1 = new Get(ROW1);
    get1.addColumn(COLFAM1, QUAL1); // co BatchExample-4-AddGet Add a Get instance for a different row.
    batch.add(get1);

    Delete delete = new Delete(ROW1);
    delete.deleteColumns(COLFAM1, QUAL2); // co BatchExample-5-AddDelete Add a Delete instance.
    batch.add(delete);

    Get get2 = new Get(ROW2);
    get2.addFamily(Bytes.toBytes("BOGUS")); // co BatchExample-6-AddBogus Add a Get instance that will fail.
    batch.add(get2);

    Object[] results = new Object[batch.size()]; // co BatchExample-7-CreateResult Create result array.
    try {
      table.batch(batch, results);
    } catch (Exception e) {
      System.err.println("Error: " + e); // co BatchExample-8-Print Print error that was caught.
    }

    for (int i = 0; i < results.length; i++) {
      System.out.println("Result[" + i + "]: " + results[i]); // co BatchExample-9-Dump Print all results.
    }
    // ^^ BatchExample
    System.out.println("After batch call...");
    helper.dump("testtable", new String[]{ "row1", "row2" }, null, null);
  }
View Full Code Here

TOP

Related Classes of util.HBaseHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.