use of org.apache.drill.exec.store.hive.HiveSubScan in project drill by apache.
the class ReadersInitializer method init.
/**
* Selects reader constructor reference as {@link HiveReaderFactory} readerFactory.
* Then check if input splits are empty creates empty record reader, or one reader per split otherwise.
*
* @param ctx context related to fragment
* @param config context which holds different Hive configurations
* @return list containing one or more readers
*/
public static List<RecordReader> init(ExecutorFragmentContext ctx, HiveSubScan config) {
final HiveReaderFactory readerFactory = getReaderFactory(config);
final UserGroupInformation proxyUgi = ImpersonationUtil.createProxyUgi(config.getUserName(), ctx.getQueryUserName());
final List<List<InputSplit>> inputSplits = config.getInputSplits();
final HiveConf hiveConf = config.getHiveConf();
if (inputSplits.isEmpty()) {
return Collections.singletonList(readerFactory.createReader(config.getTable(), null, /*partition*/
null, /*split*/
config.getColumns(), ctx, hiveConf, proxyUgi));
} else {
IndexedPartitions partitions = getPartitions(config);
return IntStream.range(0, inputSplits.size()).mapToObj(idx -> readerFactory.createReader(config.getTable(), partitions.get(idx), inputSplits.get(idx), config.getColumns(), ctx, hiveConf, proxyUgi)).collect(Collectors.toList());
}
}
Aggregations