Exemple #1
0
 static int insertData(Configuration conf, TableName tableName, String column, double prob)
     throws IOException {
   Random rng = new Random();
   int count = 0;
   HTable table = new HTable(conf, tableName);
   byte[] k = new byte[3];
   byte[][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(column));
   for (byte b1 = 'a'; b1 < 'z'; b1++) {
     for (byte b2 = 'a'; b2 < 'z'; b2++) {
       for (byte b3 = 'a'; b3 < 'z'; b3++) {
         if (rng.nextDouble() < prob) {
           k[0] = b1;
           k[1] = b2;
           k[2] = b3;
           Put put = new Put(k);
           put.setDurability(Durability.SKIP_WAL);
           put.add(famAndQf[0], famAndQf[1], k);
           table.put(put);
           count++;
         }
       }
     }
   }
   table.flushCommits();
   table.close();
   return count;
 }