本文整理汇总了Java中org.apache.parquet.hadoop.ParquetRecordReader类的典型用法代码示例。如果您正苦于以下问题:Java ParquetRecordReader类的具体用法?Java ParquetRecordReader怎么用?Java ParquetRecordReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParquetRecordReader类属于org.apache.parquet.hadoop包,在下文中一共展示了ParquetRecordReader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RecordReaderWrapper
import org.apache.parquet.hadoop.ParquetRecordReader; //导入依赖的package包/类
public RecordReaderWrapper(
InputSplit oldSplit, JobConf oldJobConf, Reporter reporter)
throws IOException {
splitLen = oldSplit.getLength();
try {
realReader = new ParquetRecordReader<V>(
ParquetInputFormat.<V>getReadSupportInstance(oldJobConf),
ParquetInputFormat.getFilter(oldJobConf));
if (oldSplit instanceof ParquetInputSplitWrapper) {
realReader.initialize(((ParquetInputSplitWrapper) oldSplit).realSplit, oldJobConf, reporter);
} else if (oldSplit instanceof FileSplit) {
realReader.initialize((FileSplit) oldSplit, oldJobConf, reporter);
} else {
throw new IllegalArgumentException(
"Invalid split (not a FileSplit or ParquetInputSplitWrapper): " + oldSplit);
}
// read once to gain access to key and value objects
if (realReader.nextKeyValue()) {
firstRecord = true;
valueContainer = new Container<V>();
valueContainer.set(realReader.getCurrentValue());
} else {
eof = true;
}
} catch (InterruptedException e) {
Thread.interrupted();
throw new IOException(e);
}
}
示例2: TextRecordReaderWrapper
import org.apache.parquet.hadoop.ParquetRecordReader; //导入依赖的package包/类
public TextRecordReaderWrapper(ParquetInputFormat<SimpleGroup> newInputFormat,
InputSplit oldSplit,
JobConf oldJobConf,
Reporter reporter) throws IOException {
splitLen = oldSplit.getLength();
try {
ReadSupport<SimpleGroup> rs = ParquetInputFormat.getReadSupportInstance(oldJobConf);
realReader = new ParquetRecordReader<>(rs);
realReader.initialize(((StreamingParquetInputSplitWrapper)oldSplit).realSplit, oldJobConf, reporter);
oldJobConf.set("map.input.file",((StreamingParquetInputSplitWrapper)oldSplit).realSplit.getPath().toString());
oldJobConf.set("mapreduce.map.input.file",((StreamingParquetInputSplitWrapper)oldSplit).realSplit.getPath().toString());
// read once to gain access to key and value objects
if (realReader.nextKeyValue()) {
firstRecord = true;
valueContainer = new Container<>();
SimpleGroup v = realReader.getCurrentValue();
valueContainer.set(v);
ls = groupToStrings(v);
} else {
eof = true;
}
} catch (InterruptedException e) {
Thread.interrupted();
throw new IOException(e);
}
}