wgtmac commented on code in PR #2987:
URL: https://github.com/apache/parquet-java/pull/2987#discussion_r1717179249


##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java:
##########
@@ -1707,19 +1707,27 @@ private static void serializeColumnIndexes(
         }
         long offset = out.getPos();
         Util.writeColumnIndex(columnIndex, out, columnIndexEncryptor, 
columnIndexAAD);
-        column.setColumnIndexReference(new IndexReference(offset, (int) 
(out.getPos() - offset)));
+        column.setColumnIndexReference(new IndexReference(offset, 
toIntWithCheck(out.getPos() - offset)));
       }
     }
   }
 
-  private int toIntWithCheck(long size) {
+  private static int toIntWithCheck(long size) {
     if ((int) size != size) {
       throw new ParquetEncodingException(
           "Cannot write page larger than " + Integer.MAX_VALUE + " bytes: " + 
size);
     }
     return (int) size;
   }
 
+  private static int footerSizeToInt(long size) {
+    if ((int) size != size) {
+      throw new ParquetFileWriteException(

Review Comment:
   What about `ParquetSizeOverflowException`? Perhaps we can also consolidate 
`toIntWithCheck` and `footerSizeToInt` into a single method.



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ParquetFileWriter.java:
##########
@@ -1707,19 +1707,27 @@ private static void serializeColumnIndexes(
         }
         long offset = out.getPos();
         Util.writeColumnIndex(columnIndex, out, columnIndexEncryptor, 
columnIndexAAD);
-        column.setColumnIndexReference(new IndexReference(offset, (int) 
(out.getPos() - offset)));
+        column.setColumnIndexReference(new IndexReference(offset, 
toIntWithCheck(out.getPos() - offset)));
       }
     }
   }
 
-  private int toIntWithCheck(long size) {
+  private static int toIntWithCheck(long size) {

Review Comment:
   TBH, it looks weird to me that the exception is about `Encoding`.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to