Skip to content

Commit 26ce9e8

Browse files
committed
Update
1 parent 6ac9b29 commit 26ce9e8

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

parquet-column/src/test/java/org/apache/parquet/column/mem/TestMemPageStore.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
import static org.apache.parquet.column.Encoding.BIT_PACKED;
2222
import static org.apache.parquet.column.Encoding.PLAIN;
23+
import static org.junit.Assert.assertEquals;
24+
import static org.junit.Assert.assertNotNull;
2325

2426
import java.io.IOException;
2527
import org.apache.parquet.bytes.BytesInput;
2628
import org.apache.parquet.column.ColumnDescriptor;
2729
import org.apache.parquet.column.page.DataPage;
30+
import org.apache.parquet.column.page.DataPageV1;
2831
import org.apache.parquet.column.page.PageReader;
2932
import org.apache.parquet.column.page.PageWriter;
3033
import org.apache.parquet.column.page.mem.MemPageStore;
@@ -46,19 +49,42 @@ public void test() throws IOException {
4649
ColumnDescriptor col = new ColumnDescriptor(path, PrimitiveTypeName.INT64, 2, 2);
4750
LongStatistics stats = new LongStatistics();
4851
PageWriter pageWriter = memPageStore.getPageWriter(col);
52+
4953
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN);
5054
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN);
5155
pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN);
5256
pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN);
57+
5358
PageReader pageReader = memPageStore.getPageReader(col);
5459
long totalValueCount = pageReader.getTotalValueCount();
55-
LOG.info(String.valueOf(totalValueCount));
60+
LOG.info("Total value count: " + totalValueCount);
61+
62+
assertEquals("Expected total value count to be 836 (4 pages * 209 values)", 836, totalValueCount);
63+
5664
int total = 0;
65+
int pageCount = 0;
5766
do {
5867
DataPage readPage = pageReader.readPage();
68+
69+
// Assert page was successfully read
70+
assertNotNull("Page should not be null", readPage);
71+
// Assert page has expected value count
72+
assertEquals("Each page should have 209 values", 209, readPage.getValueCount());
73+
// Assert encodings when the implementation is DataPageV1
74+
if (readPage instanceof DataPageV1) {
75+
DataPageV1 v1 = (DataPageV1) readPage;
76+
assertEquals("Page repetition level encoding should be BIT_PACKED", BIT_PACKED, v1.getRlEncoding());
77+
assertEquals("Page definition level encoding should be BIT_PACKED", BIT_PACKED, v1.getDlEncoding());
78+
assertEquals("Page value encoding should be PLAIN", PLAIN, v1.getValueEncoding());
79+
}
80+
5981
total += readPage.getValueCount();
60-
LOG.info(readPage.toString());
61-
// TODO: assert
82+
pageCount++;
83+
LOG.info("Page " + pageCount + ": " + readPage.toString());
6284
} while (total < totalValueCount);
85+
86+
// Assert we read exactly the expected number of pages and values
87+
assertEquals("Should have read 4 pages", 4, pageCount);
88+
assertEquals("Total values read should match totalValueCount", totalValueCount, total);
6389
}
6490
}

0 commit comments

Comments
 (0)