iverase commented on PR #12460: URL: https://github.com/apache/lucene/pull/12460#issuecomment-1720945832
Thanks @jpountz and @uschindler for the input. I had a look into `RandomAccessInput` and I don't think this what we need. We need an DataInput that is positional ware so it supports seek and in addition it knows its length so we can still read the full stream via `readBytes(byte[] b, int offset, int len)` to support the current functionality. What I am missing is an abstraction between `DataInput` and `IndexInput` like: ``` /** * A positional aware {@link DataInput}. */ public abstract class SliceDataInput extends DataInput { /** The number of bytes in the stream. */ public abstract long length(); /** * Returns the current position in this stream, where the next read will occur. * * @see #seek(long) */ public abstract long position(); /** * Sets current position in this stream, where the next read will occur. * * @see #position() */ public abstract void seek(long pos) throws IOException; /** * {@inheritDoc} * * <p>Behavior is functionally equivalent to seeking to <code>position() + numBytes</code>. * * @see #position() * @see #seek(long) */ @Override public void skipBytes(long numBytes) throws IOException { if (numBytes < 0) { throw new IllegalArgumentException("numBytes must be >= 0, got " + numBytes); } final long skipTo = position() + numBytes; seek(skipTo); } } ``` (Naming is so hard, naming proposals are welcome) This abstraction can be extended by `ByteBuffersDataInput` and `IndexInput` and potentially by `ByteArrayDataInput` and `FTS.BytesReader`. -- 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...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org