Search in sources :

Example 6 with Key

use of org.apache.accumulo.proxy.thrift.Key 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);
}
Also used : ScanResult(org.apache.accumulo.proxy.thrift.ScanResult) HashMap(java.util.HashMap) BatchScanOptions(org.apache.accumulo.proxy.thrift.BatchScanOptions) List(java.util.List) Range(org.apache.accumulo.proxy.thrift.Range) ByteBuffer(java.nio.ByteBuffer) Key(org.apache.accumulo.proxy.thrift.Key) Test(org.junit.Test)

Aggregations

Key (org.apache.accumulo.proxy.thrift.Key)6 ScanResult (org.apache.accumulo.proxy.thrift.ScanResult)5 ByteBuffer (java.nio.ByteBuffer)4 HashMap (java.util.HashMap)4 List (java.util.List)4 BatchScanOptions (org.apache.accumulo.proxy.thrift.BatchScanOptions)3 Range (org.apache.accumulo.proxy.thrift.Range)3 ScanOptions (org.apache.accumulo.proxy.thrift.ScanOptions)3 Test (org.junit.Test)3 ColumnUpdate (org.apache.accumulo.proxy.thrift.ColumnUpdate)2 Date (java.util.Date)1 TreeMap (java.util.TreeMap)1 ClusterUser (org.apache.accumulo.cluster.ClusterUser)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 UGIAssumingTransport (org.apache.accumulo.core.rpc.UGIAssumingTransport)1 AccumuloProxy (org.apache.accumulo.proxy.thrift.AccumuloProxy)1 Client (org.apache.accumulo.proxy.thrift.AccumuloProxy.Client)1 KeyValue (org.apache.accumulo.proxy.thrift.KeyValue)1 PartialKey (org.apache.accumulo.proxy.thrift.PartialKey)1 ScanColumn (org.apache.accumulo.proxy.thrift.ScanColumn)1