System.out.println("Starting scanner...");
int scanner = client
.scannerOpen(t, bytes(""), columnNames);
try {
while (true) {
ScanEntry value = client.scannerGet(scanner);
printEntry(value);
}
} catch (NotFound nf) {
client.scannerClose(scanner);
System.out.println("Scanner finished");
}
//
// Run some operations on a bunch of rows
//
for (int i = 100; i >= 0; --i) {
// format row keys as "00000" to "00100"
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
byte[] row = bytes(nf.format(i));
client.put(t, row, bytes("unused:"), bytes("DELETE_ME"));
printRow(row, client.getRow(t, row));
client.deleteAllRow(t, row);
client.put(t, row, bytes("entry:num"), bytes("0"));
client.put(t, row, bytes("entry:foo"), bytes("FOO"));
printRow(row, client.getRow(t, row));
Mutation m = null;
ArrayList<Mutation> mutations = new ArrayList<Mutation>();
m = new Mutation();
m.column = bytes("entry:foo");
m.isDelete = true;
mutations.add(m);
m = new Mutation();
m.column = bytes("entry:num");
m.value = bytes("-1");
mutations.add(m);
client.mutateRow(t, row, mutations);
printRow(row, client.getRow(t, row));
client.put(t, row, bytes("entry:num"), bytes(Integer.toString(i)));
client.put(t, row, bytes("entry:sqr"), bytes(Integer.toString(i * i)));
printRow(row, client.getRow(t, row));
// sleep to force later timestamp
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// no-op
}
mutations.clear();
m = new Mutation();
m.column = bytes("entry:num");
m.value = bytes("-999");
mutations.add(m);
m = new Mutation();
m.column = bytes("entry:sqr");
m.isDelete = true;
client.mutateRowTs(t, row, mutations, 1); // shouldn't override latest
printRow(row, client.getRow(t, row));
ArrayList<byte[]> versions = client.getVer(t, row, bytes("entry:num"), 10);
printVersions(row, versions);
if (versions.size() != 4) {
System.out.println("FATAL: wrong # of versions");
System.exit(-1);
}
try {
client.get(t, row, bytes("entry:foo"));
System.out.println("FATAL: shouldn't get here");
System.exit(-1);
} catch (NotFound nf2) {
// blank
}
System.out.println("");
}
// scan all rows/columnNames
columnNames.clear();
for (ColumnDescriptor col2 : client.getColumnDescriptors(t).values()) {
columnNames.add(col2.name);
}
System.out.println("Starting scanner...");
scanner = client.scannerOpenWithStop(t, bytes("00020"), bytes("00040"),
columnNames);
try {
while (true) {
ScanEntry value = client.scannerGet(scanner);
printEntry(value);
}
} catch (NotFound nf) {
client.scannerClose(scanner);
System.out.println("Scanner finished");