theosib-amazon commented on code in PR #960:
URL: https://github.com/apache/parquet-mr/pull/960#discussion_r948043918
##########
parquet-common/src/main/java/org/apache/parquet/bytes/SingleBufferInputStream.java:
##########
@@ -38,6 +39,34 @@ class SingleBufferInputStream extends ByteBufferInputStream {
// duplicate the buffer because its state will be modified
this.buffer = buffer.duplicate();
this.startPosition = buffer.position();
+ this.buffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
+ }
+
+ SingleBufferInputStream(ByteBuffer buffer, int start, int length) {
+ // duplicate the buffer because its state will be modified
+ this.buffer = buffer.duplicate();
+ this.startPosition = start;
+ this.buffer.position(start);
+ this.buffer.limit(start + length);
+ this.buffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
+ }
+
+ SingleBufferInputStream(byte[] inBuf) {
Review Comment:
I went ahead and added two tests to cover the unused SingleBufferInputStream
constructors. I considered just deleting these constructors, but I decided that
it might be valuable to include them as documentation on how to do this in a
way that is congruent to the behavior of HeapByteBuffer, just in case anyone
wanted to do this in the future. There's also the risk that someone would think
they have to wrap an array with ByteBuffer before using
SingleBufferInputStream, but it would be better to avoid the overhead of
ByteBuffer.duplicate(). (ByteBuffer.duplicate() appears to take constant time
by making a reference to the same backing array, but it's a big constant with
loads of checks.)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]