[ https://issues.apache.org/jira/browse/LUCENE-2126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12789850#action_12789850 ]
Shai Erera commented on LUCENE-2126: ------------------------------------ bq. I bet that a lot of people who used the payload feature before took a ByteArrayOutputStream together with DataOutputStream I actually use ByteBuffer which has similar methods. That's good though if you know the size of the needed byte[] up front. Otherwise, you either code the extension of growing the ByteBuffer, or use DataOutputStream(ByteArrayOutputStream). Michael, I read through the patch (briefly though), and I was confused by the names DataInput/Ouput. Initially, when I read this issue, I thought you mean that IndexInput/Output should implement Java's DataInput/Output, but now I see you created two new such classes. So first, can we perhaps name them otherwise, like LuceneInput/Output or something similar, to not confuse w/ Java's? Second, why not have them implement Java's DataInput/Output, and add on top of them additional methods, like readVInt(), readVLong() etc.? You can keep the abstracts LuceneInput/Output to provide the common implementation. BTW, a small optimization that I think can be made in the classes is to introduce an internal ByteBuffer of size 8. In the methods like readInt(), you can read 4 bytes into the buffer, calling readBytes(buf.array(), 0, 4), and then buf.getInt(). That will save 4 calls to readByte(). Same will go for long, and the write variants. Doesn't work though w/ readVInt(), because we need to read 1-byte at-a-time to decode. Maybe if the use of these is usually through BufferedIndexInput/Output this does not matter much, but it will still save 2/4 method calls. > Split up IndexInput and IndexOutput into DataInput and DataOutput > ----------------------------------------------------------------- > > Key: LUCENE-2126 > URL: https://issues.apache.org/jira/browse/LUCENE-2126 > Project: Lucene - Java > Issue Type: Improvement > Affects Versions: Flex Branch > Reporter: Michael Busch > Assignee: Michael Busch > Priority: Minor > Fix For: Flex Branch > > Attachments: lucene-2126.patch > > > I'd like to introduce the two new classes DataInput and DataOutput > that contain all methods from IndexInput and IndexOutput that actually > decode or encode data, such as readByte()/writeByte(), > readVInt()/writeVInt(). > Methods like getFilePointer(), seek(), close(), etc., which are not > related to data encoding, but to files as input/output source stay in > IndexInput/IndexOutput. > This patch also changes ByteSliceReader/ByteSliceWriter to extend > DataInput/DataOutput. Previously ByteSliceReader implemented the > methods that stay in IndexInput by throwing RuntimeExceptions. > See also LUCENE-2125. > All tests pass. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org