private List<Group> readParquetFiles(File outputFile) throws IOException { ParquetReader<Group> reader = null; List<Group> records = new ArrayList<>(); try { reader = new ParquetReader<>(new Path(outputFile.toString()), new SimpleReadSupport()); for (Group value = reader.read(); value != null; value = reader.read()) { records.add(value); } } finally { if (reader != null) { try { reader.close(); } catch (Exception ex) { System.out.println(ex.getMessage()); } } } return records; }
/** * @return the next record or null if finished * @throws IOException */ public T read() throws IOException { try { if (reader != null && reader.nextKeyValue()) { return reader.getCurrentValue(); } else { initReader(); return reader == null ? null : read(); } } catch (InterruptedException e) { throw new IOException(e); } }
public ParquetReader<T> build() throws IOException { return new ParquetReader<T>(conf, file, readSupport, filter); } }
public ParquetReader<T> build() throws IOException { ReadSupport<T> readSupport; if (thriftClass != null) { readSupport = new ThriftReadSupport<T>(thriftClass); } else { readSupport = new ThriftReadSupport<T>(); } return ParquetReader.builder(readSupport, file).withConf(conf).withFilter(filter).build(); } }
@Override public void execute(CommandLine options) throws Exception { super.execute(options); long num = DEFAULT; if (options.hasOption('n')) { num = Long.parseLong(options.getOptionValue('n')); } String[] args = options.getArgs(); String input = args[0]; ParquetReader<SimpleRecord> reader = null; try { PrintWriter writer = new PrintWriter(Main.out, true); reader = new ParquetReader<SimpleRecord>(new Path(input), new SimpleReadSupport()); for (SimpleRecord value = reader.read(); value != null && num-- > 0; value = reader.read()) { value.prettyPrint(writer); writer.println(); } } finally { if (reader != null) { try { reader.close(); } catch (Exception ex) { } } } } }
@Override public void execute(CommandLine options) throws Exception { super.execute(options); String[] args = options.getArgs(); String input = args[0]; ParquetReader<SimpleRecord> reader = null; try { PrintWriter writer = new PrintWriter(Main.out, true); reader = new ParquetReader<SimpleRecord>(new Path(input), new SimpleReadSupport()); for (SimpleRecord value = reader.read(); value != null; value = reader.read()) { if (options.hasOption('j')) { value.prettyPrintJson(writer); } else { value.prettyPrint(writer); } writer.println(); } } finally { if (reader != null) { try { reader.close(); } catch (Exception ex) { } } } } }