pitrou commented on code in PR #3368:
URL: https://github.com/apache/parquet-java/pull/3368#discussion_r2597972024


##########
parquet-hadoop/src/test/java/org/apache/parquet/hadoop/TestColumnChunkPageWriteStore.java:
##########
@@ -316,7 +316,130 @@ public void testColumnOrderV1() throws IOException {
     }
   }
 
+  @Test
+  public void testV2PageCompressThreshold() throws Exception {
+    allocator = TrackingByteBufferAllocator.wrap(new 
HeapByteBufferAllocator());
+    MessageType schema = MessageTypeParser.parseMessageType("message test { 
required int32 data; }");
+    ColumnDescriptor col = schema.getColumns().get(0);
+
+    int valueCount = 100;
+    int rowCount = 100;
+    int nullCount = 0;
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    byte[] value =
+        
ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(0).array();
+    for (int i = 0; i < valueCount; i++) {
+      baos.write(value);
+    }
+    BytesInput data = BytesInput.from(baos.toByteArray());
+
+    BytesInput definitionLevels = BytesInput.empty();
+    BytesInput repetitionLevels = BytesInput.empty();
+    Statistics<?> statistics = Statistics.getBuilderForReading(
+            Types.required(INT32).named("data"))
+        .build();
+    statistics.setMinMaxFromBytes(value, value);
+
+    Path file = writeSingleColumnData(
+        "lowCompressThreshold",
+        schema,
+        col,
+        rowCount,
+        nullCount,
+        valueCount,
+        repetitionLevels,
+        definitionLevels,
+        data,
+        statistics,
+        0.01);
+    ParquetMetadata footer = ParquetFileReader.readFooter(conf, file, 
NO_FILTER);
+    ColumnChunkMetaData columnMeta = 
footer.getBlocks().get(0).getColumns().get(0);
+
+    long uncompressedSize = columnMeta.getTotalUncompressedSize();
+    long compressedSize = columnMeta.getTotalSize();
+
+    assertEquals(
+        "Data should be stored uncompressed when compression ratio exceeds 
threshold",
+        uncompressedSize,
+        compressedSize);

Review Comment:
   Perhaps you want to read the data back and check it's as expected?



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