theosib-amazon commented on code in PR #960:
URL: https://github.com/apache/parquet-mr/pull/960#discussion_r965058610


##########
parquet-common/src/main/java/org/apache/parquet/bytes/SingleBufferInputStream.java:
##########
@@ -88,6 +136,21 @@ public long skip(long n) {
     return bytesToSkip;
   }
 
+  @Override
+  public void skipFully(long n) throws IOException {
+    if (n < 0 || n > Integer.MAX_VALUE) {
+      throw new IllegalArgumentException();
+    }
+    
+    try {
+      buffer.position(buffer.position() + (int)n);
+    } catch (IllegalArgumentException e) {

Review Comment:
   A try/catch is basically free when no exception is thrown, while a check is 
not. I have tested this, and the try/catch is empirically faster, since the 
no-exception case is the common case. Putting in the check means we have to 
wait until the C2 compiler produces a trace without the branch. But even then, 
there's always the overhead of a check somewhere to be able to fall back to 
interpretation if the condition is not correct for the trace. I'm avoiding all 
of that entirely, making this faster in of the most common case.



-- 
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: dev-unsubscr...@parquet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to