Search in sources :

Example 1 with AccumuloInputFormat

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

the class AccumuloInputFormatIT method testCorrectRangeInputSplits.

@Test
public void testCorrectRangeInputSplits() throws Exception {
    Job job = Job.getInstance();
    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();
    List<InputSplit> splits = aif.getSplits(job);
    Assert.assertEquals(1, splits.size());
    InputSplit split = splits.get(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.mapreduce.RangeInputSplit) AccumuloInputFormat(org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat) Level(org.apache.log4j.Level) Job(org.apache.hadoop.mapreduce.Job) BatchInputSplit(org.apache.accumulo.core.client.mapreduce.impl.BatchInputSplit) RangeInputSplit(org.apache.accumulo.core.client.mapreduce.RangeInputSplit) InputSplit(org.apache.hadoop.mapreduce.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.mapreduce.AccumuloInputFormat)1 RangeInputSplit (org.apache.accumulo.core.client.mapreduce.RangeInputSplit)1 BatchInputSplit (org.apache.accumulo.core.client.mapreduce.impl.BatchInputSplit)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.mapreduce.InputSplit)1 Job (org.apache.hadoop.mapreduce.Job)1 Level (org.apache.log4j.Level)1 Test (org.junit.Test)1