wgtmac commented on code in PR #3268:
URL: https://github.com/apache/parquet-java/pull/3268#discussion_r2296555944
##########
parquet-column/src/test/java/org/apache/parquet/column/mem/TestMemPageStore.java:
##########
@@ -46,19 +49,42 @@ public void test() throws IOException {
ColumnDescriptor col = new ColumnDescriptor(path, PrimitiveTypeName.INT64,
2, 2);
LongStatistics stats = new LongStatistics();
PageWriter pageWriter = memPageStore.getPageWriter(col);
+
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
+
PageReader pageReader = memPageStore.getPageReader(col);
long totalValueCount = pageReader.getTotalValueCount();
- LOG.info(String.valueOf(totalValueCount));
+ LOG.info("Total value count: " + totalValueCount);
+
+ assertEquals("Expected total value count to be 836 (4 pages * 209
values)", 836, totalValueCount);
+
int total = 0;
+ int pageCount = 0;
do {
DataPage readPage = pageReader.readPage();
+
+ // Assert page was successfully read
+ assertNotNull("Page should not be null", readPage);
+ // Assert page has expected value count
+ assertEquals("Each page should have 209 values", 209,
readPage.getValueCount());
+ // Assert encodings when the implementation is DataPageV1
+ if (readPage instanceof DataPageV1) {
Review Comment:
I'd prefer asserting that this is a DataPageV1
##########
parquet-column/src/test/java/org/apache/parquet/column/mem/TestMemPageStore.java:
##########
@@ -46,19 +49,42 @@ public void test() throws IOException {
ColumnDescriptor col = new ColumnDescriptor(path, PrimitiveTypeName.INT64,
2, 2);
LongStatistics stats = new LongStatistics();
PageWriter pageWriter = memPageStore.getPageWriter(col);
+
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
+
PageReader pageReader = memPageStore.getPageReader(col);
long totalValueCount = pageReader.getTotalValueCount();
- LOG.info(String.valueOf(totalValueCount));
+ LOG.info("Total value count: " + totalValueCount);
+
+ assertEquals("Expected total value count to be 836 (4 pages * 209
values)", 836, totalValueCount);
+
int total = 0;
+ int pageCount = 0;
do {
DataPage readPage = pageReader.readPage();
+
+ // Assert page was successfully read
+ assertNotNull("Page should not be null", readPage);
+ // Assert page has expected value count
+ assertEquals("Each page should have 209 values", 209,
readPage.getValueCount());
+ // Assert encodings when the implementation is DataPageV1
+ if (readPage instanceof DataPageV1) {
+ DataPageV1 v1 = (DataPageV1) readPage;
+ assertEquals("Page repetition level encoding should be BIT_PACKED",
BIT_PACKED, v1.getRlEncoding());
+ assertEquals("Page definition level encoding should be BIT_PACKED",
BIT_PACKED, v1.getDlEncoding());
+ assertEquals("Page value encoding should be PLAIN", PLAIN,
v1.getValueEncoding());
+ }
+
total += readPage.getValueCount();
- LOG.info(readPage.toString());
- // TODO: assert
+ pageCount++;
+ LOG.info("Page " + pageCount + ": " + readPage.toString());
Review Comment:
Should we totally remove the LOG? It is useless at this moment.
##########
parquet-column/src/test/java/org/apache/parquet/column/mem/TestMemPageStore.java:
##########
@@ -46,19 +49,42 @@ public void test() throws IOException {
ColumnDescriptor col = new ColumnDescriptor(path, PrimitiveTypeName.INT64,
2, 2);
LongStatistics stats = new LongStatistics();
PageWriter pageWriter = memPageStore.getPageWriter(col);
+
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats,
BIT_PACKED, BIT_PACKED, PLAIN);
+
PageReader pageReader = memPageStore.getPageReader(col);
long totalValueCount = pageReader.getTotalValueCount();
- LOG.info(String.valueOf(totalValueCount));
+ LOG.info("Total value count: " + totalValueCount);
+
+ assertEquals("Expected total value count to be 836 (4 pages * 209
values)", 836, totalValueCount);
+
int total = 0;
+ int pageCount = 0;
do {
DataPage readPage = pageReader.readPage();
+
+ // Assert page was successfully read
Review Comment:
It seems that TestMemPageStore previously tests nothing but merely to prove
that methods of MemPageStore are working.
--
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]