use of org.apache.rya.accumulo.mr.GraphXInputFormat.RyaStatementRecordReader in project incubator-rya by apache.
the class GraphXInputFormatTest method testInputFormat.
@Test
public void testInputFormat() throws Exception {
RyaStatement input = RyaStatement.builder().setSubject(new RyaURI("http://www.google.com")).setPredicate(new RyaURI("http://some_other_uri")).setObject(new RyaURI("http://www.yahoo.com")).setColumnVisibility(new byte[0]).setValue(new byte[0]).build();
apiImpl.add(input);
Job jobConf = Job.getInstance();
GraphXInputFormat.setMockInstance(jobConf, instance.getInstanceName());
GraphXInputFormat.setConnectorInfo(jobConf, username, password);
GraphXInputFormat.setInputTableName(jobConf, table);
GraphXInputFormat.setInputTableName(jobConf, table);
GraphXInputFormat.setScanIsolation(jobConf, false);
GraphXInputFormat.setLocalIterators(jobConf, false);
GraphXInputFormat.setOfflineTableScan(jobConf, false);
GraphXInputFormat inputFormat = new GraphXInputFormat();
JobContext context = new JobContextImpl(jobConf.getConfiguration(), jobConf.getJobID());
List<InputSplit> splits = inputFormat.getSplits(context);
Assert.assertEquals(1, splits.size());
TaskAttemptContext taskAttemptContext = new TaskAttemptContextImpl(context.getConfiguration(), new TaskAttemptID(new TaskID(), 1));
RecordReader<Object, RyaTypeWritable> reader = inputFormat.createRecordReader(splits.get(0), taskAttemptContext);
RyaStatementRecordReader ryaStatementRecordReader = (RyaStatementRecordReader) reader;
ryaStatementRecordReader.initialize(splits.get(0), taskAttemptContext);
List<RyaType> results = new ArrayList<RyaType>();
System.out.println("before while");
while (ryaStatementRecordReader.nextKeyValue()) {
System.out.println("in while");
RyaTypeWritable writable = ryaStatementRecordReader.getCurrentValue();
RyaType value = writable.getRyaType();
Object text = ryaStatementRecordReader.getCurrentKey();
RyaType type = new RyaType();
type.setData(value.getData());
type.setDataType(value.getDataType());
results.add(type);
System.out.println(value.getData());
System.out.println(value.getDataType());
System.out.println(results);
System.out.println(type);
System.out.println(text);
System.out.println(value);
}
System.out.println("after while");
System.out.println(results.size());
System.out.println(results);
// Assert.assertTrue(results.size() == 2);
// Assert.assertTrue(results.contains(input));
}
Aggregations