rdblue commented on code in PR #6293: URL: https://github.com/apache/iceberg/pull/6293#discussion_r1041607110
########## orc/src/main/java/org/apache/iceberg/orc/ORC.java: ########## @@ -789,7 +808,210 @@ static Reader newFileReader(InputFile file, Configuration config) { ReaderOptions readerOptions = OrcFile.readerOptions(config).useUTCTimestamp(true); if (file instanceof HadoopInputFile) { readerOptions.filesystem(((HadoopInputFile) file).getFileSystem()); + } else { + readerOptions.filesystem(new InputFileSystem(file)).maxLength(file.getLength()); } return newFileReader(file.location(), readerOptions); } + + static Writer newFileWriter( + OutputFile file, OrcFile.WriterOptions options, Map<String, byte[]> metadata) { + if (file instanceof HadoopOutputFile) { + options.fileSystem(((HadoopOutputFile) file).getFileSystem()); + } else { + options.fileSystem(new OutputFileSystem(file)); + } + final Path locPath = new Path(file.location()); + final Writer writer; + + try { + writer = OrcFile.createWriter(locPath, options); + } catch (IOException ioe) { + throw new RuntimeIOException(ioe, "Can't create file %s", locPath); + } + + metadata.forEach((key, value) -> writer.addUserMetadata(key, ByteBuffer.wrap(value))); + + return writer; + } + + private static class WrappedSeekableInputStream extends FSInputStream { + private final SeekableInputStream inputStream; + private boolean closed; + private final StackTraceElement[] createStack; + + private WrappedSeekableInputStream(SeekableInputStream inputStream) { Review Comment: Can you move this stream to HadoopStreams? There's nothing ORC specific here and we may find other uses for it. That would also allow us to update the `wrap` methods that convert to detect double wrapping and return the underlying stream. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org