Search in sources :

Example 1 with SummingCombiner

use of org.apache.accumulo.core.iterators.user.SummingCombiner in project accumulo by apache.

the class SimpleProxyBase method iteratorFunctionality.

@Test
public void iteratorFunctionality() throws Exception {
    // iterators
    HashMap<String, String> options = new HashMap<>();
    options.put("type", "STRING");
    options.put("columns", "cf");
    IteratorSetting setting = new IteratorSetting(10, tableName, SummingCombiner.class.getName(), options);
    client.attachIterator(creds, tableName, setting, EnumSet.allOf(IteratorScope.class));
    for (int i = 0; i < 10; i++) {
        client.updateAndFlush(creds, tableName, mutation("row1", "cf", "cq", "1"));
    }
    // 10 updates of "1" in the value w/ SummingCombiner should return value of "10"
    assertScan(new String[][] { { "row1", "cf", "cq", "10" } }, tableName);
    try {
        client.checkIteratorConflicts(creds, tableName, setting, EnumSet.allOf(IteratorScope.class));
        fail("checkIteratorConflicts did not throw an exception");
    } catch (Exception ex) {
    // Expected
    }
    client.deleteRows(creds, tableName, null, null);
    client.removeIterator(creds, tableName, "test", EnumSet.allOf(IteratorScope.class));
    String[][] expected = new String[10][];
    for (int i = 0; i < 10; i++) {
        client.updateAndFlush(creds, tableName, mutation("row" + i, "cf", "cq", "" + i));
        expected[i] = new String[] { "row" + i, "cf", "cq", "" + i };
        client.flushTable(creds, tableName, null, null, true);
    }
    assertScan(expected, tableName);
}
Also used : IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) HashMap(java.util.HashMap) SummingCombiner(org.apache.accumulo.core.iterators.user.SummingCombiner) IteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope) NumericValueConstraint(org.apache.accumulo.test.constraints.NumericValueConstraint) TableNotFoundException(org.apache.accumulo.proxy.thrift.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.proxy.thrift.MutationsRejectedException) NamespaceNotEmptyException(org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException) AccumuloSecurityException(org.apache.accumulo.proxy.thrift.AccumuloSecurityException) TException(org.apache.thrift.TException) NamespaceExistsException(org.apache.accumulo.proxy.thrift.NamespaceExistsException) NamespaceNotFoundException(org.apache.accumulo.proxy.thrift.NamespaceNotFoundException) TApplicationException(org.apache.thrift.TApplicationException) TableExistsException(org.apache.accumulo.proxy.thrift.TableExistsException) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 SummingCombiner (org.apache.accumulo.core.iterators.user.SummingCombiner)1 AccumuloSecurityException (org.apache.accumulo.proxy.thrift.AccumuloSecurityException)1 IteratorScope (org.apache.accumulo.proxy.thrift.IteratorScope)1 IteratorSetting (org.apache.accumulo.proxy.thrift.IteratorSetting)1 MutationsRejectedException (org.apache.accumulo.proxy.thrift.MutationsRejectedException)1 NamespaceExistsException (org.apache.accumulo.proxy.thrift.NamespaceExistsException)1 NamespaceNotEmptyException (org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException)1 NamespaceNotFoundException (org.apache.accumulo.proxy.thrift.NamespaceNotFoundException)1 TableExistsException (org.apache.accumulo.proxy.thrift.TableExistsException)1 TableNotFoundException (org.apache.accumulo.proxy.thrift.TableNotFoundException)1 NumericValueConstraint (org.apache.accumulo.test.constraints.NumericValueConstraint)1 TApplicationException (org.apache.thrift.TApplicationException)1 TException (org.apache.thrift.TException)1 Test (org.junit.Test)1