int maxInserts = 1000000;
String format = "%1$05d";
Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
for (int i = 0; i < maxInserts; i++) {
String result = String.format(format, i);
ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq" + i).getBytes()));
update.setValue(Util.randStringBuffer(10));
mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
if (i % 1000 == 0) {
tpc.proxy().updateAndFlush(login, testTable, mutations);
mutations.clear();
}
}
tpc.proxy().updateAndFlush(login, testTable, mutations);
Date end = new Date();
System.out.println(" End of writing: " + (end.getTime() - start.getTime()));
tpc.proxy().deleteTable(login, testTable);
tpc.proxy().createTable(login, testTable, true, TimeType.MILLIS);
// Thread.sleep(1000);
System.out.println("Writing async: ");
start = new Date();
then = new Date();
mutations.clear();
String writer = tpc.proxy().createWriter(login, testTable, null);
for (int i = 0; i < maxInserts; i++) {
String result = String.format(format, i);
Key pkey = new Key();
pkey.setRow(result.getBytes());
ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq" + i).getBytes()));
update.setValue(Util.randStringBuffer(10));
mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
tpc.proxy().update(writer, mutations);
mutations.clear();
}