use of org.apache.drill.exec.store.easy.json.JSONRecordReader in project drill by apache.
the class TestUtilities method getJsonReadersFromBatchString.
/**
* Create JSONRecordReader from input strings.
* @param jsonBatches : list of input strings, each element represent a batch. Each string could either
* be in the form of "[{...}, {...}, ..., {...}]", or in the form of "{...}".
* @param fragContext : fragment context
* @param columnsToRead : list of schema pathes to read from JSON reader.
* @return
*/
public static Iterator<RecordReader> getJsonReadersFromBatchString(List<String> jsonBatches, FragmentContext fragContext, List<SchemaPath> columnsToRead) {
ObjectMapper mapper = new ObjectMapper();
List<RecordReader> readers = new ArrayList<>();
for (String batchJason : jsonBatches) {
JsonNode records;
try {
records = mapper.readTree(batchJason);
} catch (IOException e) {
throw new RuntimeException(e);
}
readers.add(new JSONRecordReader(fragContext, records, null, columnsToRead));
}
return readers.iterator();
}
Aggregations