Search in sources :

Example 1 with AccumuloInputFormat

use of org.apache.accumulo.core.client.mapred.AccumuloInputFormat in project accumulo by apache.

the class AccumuloInputFormatIT method testCorrectRangeInputSplits.

@Test
public void testCorrectRangeInputSplits() throws Exception {
    JobConf job = new JobConf();
    String table = getUniqueNames(1)[0];
    Authorizations auths = new Authorizations("foo");
    Collection<Pair<Text, Text>> fetchColumns = Collections.singleton(new Pair<>(new Text("foo"), new Text("bar")));
    boolean isolated = true, localIters = true;
    Level level = Level.WARN;
    Connector connector = getConnector();
    connector.tableOperations().create(table);
    AccumuloInputFormat.setConnectionInfo(job, getConnectionInfo());
    AccumuloInputFormat.setInputTableName(job, table);
    AccumuloInputFormat.setScanAuthorizations(job, auths);
    AccumuloInputFormat.setScanIsolation(job, isolated);
    AccumuloInputFormat.setLocalIterators(job, localIters);
    AccumuloInputFormat.fetchColumns(job, fetchColumns);
    AccumuloInputFormat.setLogLevel(job, level);
    AccumuloInputFormat aif = new AccumuloInputFormat();
    InputSplit[] splits = aif.getSplits(job, 1);
    Assert.assertEquals(1, splits.length);
    InputSplit split = splits[0];
    Assert.assertEquals(RangeInputSplit.class, split.getClass());
    RangeInputSplit risplit = (RangeInputSplit) split;
    Assert.assertEquals(getAdminPrincipal(), risplit.getPrincipal());
    Assert.assertEquals(table, risplit.getTableName());
    Assert.assertEquals(getAdminToken(), risplit.getToken());
    Assert.assertEquals(auths, risplit.getAuths());
    Assert.assertEquals(getConnector().getInstance().getInstanceName(), risplit.getInstanceName());
    Assert.assertEquals(isolated, risplit.isIsolatedScan());
    Assert.assertEquals(localIters, risplit.usesLocalIterators());
    Assert.assertEquals(fetchColumns, risplit.getFetchedColumns());
    Assert.assertEquals(level, risplit.getLogLevel());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Authorizations(org.apache.accumulo.core.security.Authorizations) Text(org.apache.hadoop.io.Text) RangeInputSplit(org.apache.accumulo.core.client.mapred.RangeInputSplit) AccumuloInputFormat(org.apache.accumulo.core.client.mapred.AccumuloInputFormat) Level(org.apache.log4j.Level) JobConf(org.apache.hadoop.mapred.JobConf) RangeInputSplit(org.apache.accumulo.core.client.mapred.RangeInputSplit) InputSplit(org.apache.hadoop.mapred.InputSplit) Pair(org.apache.accumulo.core.util.Pair) Test(org.junit.Test)

Aggregations

Connector (org.apache.accumulo.core.client.Connector)1 AccumuloInputFormat (org.apache.accumulo.core.client.mapred.AccumuloInputFormat)1 RangeInputSplit (org.apache.accumulo.core.client.mapred.RangeInputSplit)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 Pair (org.apache.accumulo.core.util.Pair)1 Text (org.apache.hadoop.io.Text)1 InputSplit (org.apache.hadoop.mapred.InputSplit)1 JobConf (org.apache.hadoop.mapred.JobConf)1 Level (org.apache.log4j.Level)1 Test (org.junit.Test)1