use of org.apache.accumulo.proxy.thrift.Range in project accumulo by apache.
the class SimpleProxyBase method testGetRowRange.
@Test
public void testGetRowRange() throws Exception {
Range range = client.getRowRange(s2bb("xyzzy"));
org.apache.accumulo.core.data.Range range2 = new org.apache.accumulo.core.data.Range(new Text("xyzzy"));
assertEquals(0, range.start.row.compareTo(t2bb(range2.getStartKey().getRow())));
assertEquals(0, range.stop.row.compareTo(t2bb(range2.getEndKey().getRow())));
assertEquals(range.startInclusive, range2.isStartKeyInclusive());
assertEquals(range.stopInclusive, range2.isEndKeyInclusive());
assertEquals(0, range.start.colFamily.compareTo(t2bb(range2.getStartKey().getColumnFamily())));
assertEquals(0, range.start.colQualifier.compareTo(t2bb(range2.getStartKey().getColumnQualifier())));
assertEquals(0, range.stop.colFamily.compareTo(t2bb(range2.getEndKey().getColumnFamily())));
assertEquals(0, range.stop.colQualifier.compareTo(t2bb(range2.getEndKey().getColumnQualifier())));
assertEquals(range.start.timestamp, range.start.timestamp);
assertEquals(range.stop.timestamp, range.stop.timestamp);
}
use of org.apache.accumulo.proxy.thrift.Range in project accumulo by apache.
the class SimpleProxyBase method countFiles.
// scan metadata for file entries for the given table
private int countFiles(String table) throws Exception {
Map<String, String> tableIdMap = client.tableIdMap(creds);
String tableId = tableIdMap.get(table);
Key start = new Key();
start.row = s2bb(tableId + ";");
Key end = new Key();
end.row = s2bb(tableId + "<");
end = client.getFollowing(end, PartialKey.ROW);
ScanOptions opt = new ScanOptions();
opt.range = new Range(start, true, end, false);
opt.columns = Collections.singletonList(new ScanColumn(s2bb("file")));
String scanner = client.createScanner(creds, MetadataTable.NAME, opt);
int result = 0;
while (true) {
ScanResult more = client.nextK(scanner, 100);
result += more.getResults().size();
if (!more.more)
break;
}
return result;
}
use of org.apache.accumulo.proxy.thrift.Range in project accumulo by apache.
the class TestProxyReadWrite method readWriteOneShotWithRange.
@Test
public void readWriteOneShotWithRange() throws Exception {
int maxInserts = 100000;
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();
}
}
Key stop = new Key();
stop.setRow("5".getBytes());
ScanOptions opts = new ScanOptions();
opts.range = new Range(null, false, stop, false);
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);
i += kvList.getResultsSize();
hasNext = kvList.isMore();
}
assertEquals(i, 50000);
}
use of org.apache.accumulo.proxy.thrift.Range in project accumulo by apache.
the class TestProxyReadWrite method readWriteBatchOneShotWithRange.
/**
* Insert 100000 cells which have as the row [0..99999] (padded with zeros). Set a range so only the entries between -Inf...5 come back (there should be
* 50,000)
*/
@Test
public void readWriteBatchOneShotWithRange() throws Exception {
int maxInserts = 100000;
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();
}
}
Key stop = new Key();
stop.setRow("5".getBytes());
BatchScanOptions options = new BatchScanOptions();
options.ranges = Collections.singletonList(new Range(null, false, stop, false));
String cookie = tpc.proxy().createBatchScanner(userpass, testtable, options);
int i = 0;
boolean hasNext = true;
int k = 1000;
while (hasNext) {
ScanResult kvList = tpc.proxy().nextK(cookie, k);
i += kvList.getResultsSize();
hasNext = kvList.isMore();
}
assertEquals(i, 50000);
}
Aggregations