fommil commented on a change in pull request #815: URL: https://github.com/apache/parquet-mr/pull/815#discussion_r543682706
########## File path: parquet-common/src/main/java/org/apache/parquet/io/LocalSeekableInputStream.java ########## @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.parquet.io; + +import java.io.IOException; +import java.io.InputStream; + +public class LocalSeekableInputStream extends DelegatingSeekableInputStream { + private long pos; + + public LocalSeekableInputStream(InputStream stream) { + super(stream); + this.pos = 0; + } + + @Override + public long getPos() throws IOException { + return pos; + } + + @Override + public void seek(long newPos) throws IOException { Review comment: I don't see how this can work, the `pos` needs to be updated anytime the stream is progressed. From my reading of the DelegatingSeekableInputStream it is designed to work only for InputStreams that already track their position and can therefore be consulted. e.g. in ```scala final class LocalInputFile(file: File) extends InputFile { def getLength() = file.length() def newStream(): SeekableInputStream = { val input = new FileInputStream(file) new DelegatingSeekableInputStream(input) { def getPos(): Long = input.getChannel().position() def seek(bs: Long): Unit = { val _ = input.getChannel().position(bs) } } } } ``` from https://issues.apache.org/jira/browse/PARQUET-1953 which is relying on the underlying `FileInputStream` to keep track of its position in the stream. Also note that `seek` is not the same as `skip`. The former is an absolute position from the beginning of the stream, whereas `skip` is about a relative movement from the current position. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org