theosib-amazon commented on code in PR #960:
URL: https://github.com/apache/parquet-mr/pull/960#discussion_r929007342
##########
parquet-common/src/main/java/org/apache/parquet/bytes/ByteBufferInputStream.java:
##########
@@ -157,4 +165,80 @@ public void reset() throws IOException {
public boolean markSupported() {
return delegate.markSupported();
}
+
+ public boolean readBoolean() throws IOException {
+ return readByte() != 0;
+ }
+
+ public byte readByte() throws IOException {
+ return delegate.readByte();
+ }
+
+ public int readUnsignedByte() throws IOException {
+ return delegate.readUnsignedByte();
+ }
+
+ public short readShort() throws IOException {
+ return delegate.readShort();
+ }
+
+ public int readUnsignedShort() throws IOException {
+ return delegate.readUnsignedShort();
+ }
+
+ public int readInt() throws IOException {
+ return delegate.readInt();
+ }
+
+ public long readLong() throws IOException {
+ return delegate.readLong();
+ }
+
+ public float readFloat() throws IOException {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ public double readDouble() throws IOException {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ public int readIntLittleEndianOnThreeBytes() throws IOException {
+ int ch1 = readUnsignedByte();
+ int ch2 = readUnsignedByte();
+ int ch3 = readUnsignedByte();
+ return ((ch3 << 16) + (ch2 << 8) + (ch1 << 0));
+ }
+
+ public int readIntLittleEndianPaddedOnBitWidth(int bitWidth)
+ throws IOException {
+
+ int bytesWidth = BytesUtils.paddedByteCountFromBits(bitWidth);
+ switch (bytesWidth) {
+ case 0:
+ return 0;
+ case 1:
+ return readUnsignedByte();
+ case 2:
+ return readUnsignedShort();
+ case 3:
+ return readIntLittleEndianOnThreeBytes();
+ case 4:
+ return readInt();
+ default:
+ throw new IOException(
+ String.format("Encountered bitWidth (%d) that requires more than 4
bytes", bitWidth));
+ }
+ }
+
+ public int readUnsignedVarInt() throws IOException {
Review Comment:
Not exactly. The one in BytesUtils calls methods that read one byte at a
time. This one can take advantage of faster methods that read whole words at a
time. This is a critical-path method, so it's a performance win to eliminate
the extra level of abstraction and all the extra overhead fetching individual
bytes and shifting.
--
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]