use of org.apache.accumulo.proxy.thrift.KeyValue in project accumulo by apache.
the class TestProxyReadWrite method manyWritesAndReads.
// @Test
// This test takes kind of a long time. Enable it if you think you may have memory issues.
public void manyWritesAndReads() throws Exception {
int maxInserts = 1000000;
Map<ByteBuffer, List<ColumnUpdate>> mutations = new HashMap<>();
String format = "%1$06d";
String writer = tpc.proxy().createWriter(userpass, testtable, null);
for (int i = 0; i < maxInserts; i++) {
addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
if (i % 1000 == 0 || i == maxInserts - 1) {
tpc.proxy().update(writer, mutations);
mutations.clear();
}
}
tpc.proxy().flush(writer);
tpc.proxy().closeWriter(writer);
String cookie = tpc.proxy().createScanner(userpass, testtable, null);
int i = 0;
boolean hasNext = true;
int k = 1000;
while (hasNext) {
ScanResult kvList = tpc.proxy().nextK(cookie, k);
for (KeyValue kv : kvList.getResults()) {
assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
i++;
}
hasNext = kvList.isMore();
if (hasNext)
assertEquals(k, kvList.getResults().size());
}
assertEquals(maxInserts, i);
}
use of org.apache.accumulo.proxy.thrift.KeyValue in project accumulo by apache.
the class TestProxyReadWrite method readWriteOneShotWithFilterIterator.
/**
* Insert 100000 cells which have as the row [0..99999] (padded with zeros). Filter the results so only the even numbers come back.
*/
@Test
public void readWriteOneShotWithFilterIterator() throws Exception {
int maxInserts = 10000;
Map<ByteBuffer, List<ColumnUpdate>> mutations = new HashMap<>();
String format = "%1$05d";
for (int i = 0; i < maxInserts; i++) {
addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
if (i % 1000 == 0 || i == maxInserts - 1) {
tpc.proxy().updateAndFlush(userpass, testtable, mutations);
mutations.clear();
}
}
String regex = ".*[02468]";
org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
RegExFilter.setRegexs(is, regex, null, null, null, false);
IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
ScanOptions opts = new ScanOptions();
opts.iterators = Collections.singletonList(pis);
String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
int i = 0;
boolean hasNext = true;
int k = 1000;
while (hasNext) {
ScanResult kvList = tpc.proxy().nextK(cookie, k);
for (KeyValue kv : kvList.getResults()) {
assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
i += 2;
}
hasNext = kvList.isMore();
}
}
Aggregations