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
  /*
   * (non-Javadoc)
   *
   * @see com.hazelcast.core.MapStore#storeAll(java.util.Map)
   */
  @Override
  public void storeAll(Map<String, String> pairs) {
    HTable table = null;
    try {
      List<Put> puts = new ArrayList<Put>(pairs.size());
      for (Map.Entry<String, String> pair : pairs.entrySet()) {
        try {
          byte[] rowId =
              prefixDate ? IdUtil.bucketizeId(pair.getKey()) : Bytes.toBytes(pair.getKey());
          Put p = new Put(rowId);
          if (outputFormatType == StoreFormatType.SMILE) {
            p.add(family, qualifier, jsonSmileConverter.convertToSmile(pair.getValue()));
          } else {
            p.add(family, qualifier, Bytes.toBytes(pair.getValue()));
          }
          puts.add(p);
        } catch (NumberFormatException nfe) {
          LOG.error("Encountered bad key: " + pair.getKey(), nfe);
        }
      }

      table = (HTable) pool.getTable(tableName);
      table.setAutoFlush(false);
      table.put(puts);
      table.flushCommits();
    } catch (IOException e) {
      LOG.error("Error during puts", e);
    } finally {
      if (table != null) {
        pool.putTable(table);
      }
    }
  }
Esempio n. 3
0
 public static void SeedData(HBaseConfiguration conf) throws IOException {
   HTable table = new HTable(conf, "people");
   Put put = new Put(Bytes.toBytes("doe-john-m-12345"));
   put.add(Bytes.toBytes("personal"), Bytes.toBytes("givenName"), Bytes.toBytes("John"));
   put.add(Bytes.toBytes("personal"), Bytes.toBytes("mi"), Bytes.toBytes("M"));
   put.add(Bytes.toBytes("personal"), Bytes.toBytes("surame"), Bytes.toBytes("Doe"));
   put.add(
       Bytes.toBytes("contactinfo"),
       Bytes.toBytes("email"),
       Bytes.toBytes("*****@*****.**"));
   table.put(put);
   table.flushCommits();
   table.close();
 }