I agree with you that shouldn’t modify the position of TsFileInput when having already specified the position. Sorry for the misunderstanding. But if not specified, should it be changed for hdfs or local?
Best, Boris zhu On Mon, Sep 9, 2019 at 11:35 PM Yuan Tian <[email protected]> wrote: > In fact, I am working on the hadoop-connector, so I should create a > HDFSInput that implements TsFileInput interface for reading tsfile from > HDFS. > > And actually, in DefaultTsFileInput, this method is unsupported which you > can see in the following. > > @Override > public int read(byte[] b, int off, int len) throws IOException { > throw new UnsupportedOperationException(); > } > > Not all read methods in DefaultTsFileInput modify the position, such as > 'int read(ByteBuffer dst, long position)’. > > So it seems that if you specify the position where you want to start in > the method signature, the method shouldn’t modify the position of > TsFileInput which is consistent with FileChannel’s interface. > > > Best, > -------------- > Yuan Tian > School of Software, Tsinghua University > > 田原 > 清华大学 软件学院 > > > 在 2019年9月9日,下午11:19,Boris Zhu <[email protected]> 写道: > > > > Hi, tian > > DefaultTsFileInput is a class to implement TsFileInput > > interface. DefaultTsFileInput's method read actually change the position > of > > itself because it uses java.io.FileChannel, and we can use a "position" > > method to change its position back. But I'm also confusing that why can't > > change the position of TsFileInput or modify this TsFileInput. > > > > Best, > > Boris zhu > > > > On Mon, Sep 9, 2019 at 10:55 PM Yuan Tian <[email protected]> > wrote: > > > >> Hi, > >> > >> While implementing one read method(shown in the following) in > TsFileInput > >> interface, I don’t know whether to modify the position of TsFileInput. > >> > >> /** > >> * read an array of byte from the Input. > >> * > >> * @param b -array of byte > >> * @param off -offset of the Input > >> * @param len -length > >> */ > >> int read(byte[] b, int off, int len) throws IOException; > >> > >> > >> I think this method should not modify this TsFileInput and it should be > >> specified in the comments. > >> > >> Best, > >> -------------- > >> Yuan Tian > >> School of Software, Tsinghua University > >> > >> 田原 > >> 清华大学 软件学院 > >> > >> > >
