Esempio n. 1
0
  @Test
  public void insert_rowkey_prefix_date() throws IOException {

    System.out.println(errorTable);
    errorTable.setAutoFlushTo(false);
    List<Put> puts = new ArrayList<Put>();
    long t1 = System.currentTimeMillis();
    for (int i = 0; i < 10000000; i++) {
      String uuid = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 8);
      Put put = new Put(Bytes.toBytes("20150705" + "_" + uuid));
      put.add(
          fBytes,
          Bytes.toBytes("stacktrace"),
          Bytes.toBytes("java.io.IOException:file not found" + UUID.randomUUID().toString()));
      //            puts.add(put);
      errorTable.put(put);
      if (i % 10000 == 0) {
        errorTable.flushCommits();
      }
    }
    errorTable.flushCommits();
    long t2 = System.currentTimeMillis();
    System.out.println("count=" + puts.size() + ",t2-t1=" + (t2 - t1));
    //        errorTable.close();
  }
Esempio n. 2
0
  @Test
  public void scan_by_prefix_date() throws IOException {
    FilterList fl = new FilterList();
    Filter filter =
        new RowFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator("20150903"));
    fl.addFilter(filter);
    Scan scan = new Scan();
    scan.setFilter(fl);

    long t1 = System.currentTimeMillis();
    ResultScanner rs = errorTable.getScanner(scan);
    Result result;
    int count = 0;
    while ((result = rs.next()) != null) {
      System.out.println("rowkey=" + new String(result.getRow()));
      System.out.println(
          "value=" + new String(result.getValue(fBytes, Bytes.toBytes("stacktrace"))));
      System.out.println();
      count++;
    }
    long t2 = System.currentTimeMillis();
    System.out.println("count=" + count + ",t2 - t1=" + ((t2 - t1) / 1000));
  }
Esempio n. 3
0
 /**
  * Main entry point.
  *
  * @param args The command line parameters.
  * @throws Exception When running the job fails.
  */
 public static void main(String[] args) throws Exception {
   Configuration conf = HBaseConfiguration.create();
   String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
   if (otherArgs.length < 1) {
     System.err.println("ERROR: Wrong number of parameters: " + args.length);
     System.err.println(
         "Usage: CellCounter <tablename> <outputDir> <reportSeparator> "
             + "[^[regex pattern] or [Prefix] for row filter]] ");
     System.err.println("  Note: -D properties will be applied to the conf used. ");
     System.err.println("  Additionally, the following SCAN properties can be specified");
     System.err.println("  to get fine grained control on what is counted..");
     System.err.println("   -D " + TableInputFormat.SCAN_COLUMN_FAMILY + "=<familyName>");
     System.err.println(
         " <reportSeparator> parameter can be used to override the default report separator "
             + "string : used to separate the rowId/column family name and qualifier name.");
     System.err.println(
         " [^[regex pattern] or [Prefix] parameter can be used to limit the cell counter count "
             + "operation to a limited subset of rows from the table based on regex or prefix pattern.");
     System.exit(-1);
   }
   Job job = createSubmittableJob(conf, otherArgs);
   System.exit(job.waitForCompletion(true) ? 0 : 1);
 }