2020
2121import static org .apache .parquet .column .Encoding .BIT_PACKED ;
2222import static org .apache .parquet .column .Encoding .PLAIN ;
23+ import static org .junit .Assert .assertEquals ;
24+ import static org .junit .Assert .assertNotNull ;
25+ import static org .junit .Assert .assertTrue ;
2326
2427import java .io .IOException ;
2528import org .apache .parquet .bytes .BytesInput ;
2629import org .apache .parquet .column .ColumnDescriptor ;
2730import org .apache .parquet .column .page .DataPage ;
31+ import org .apache .parquet .column .page .DataPageV1 ;
2832import org .apache .parquet .column .page .PageReader ;
2933import org .apache .parquet .column .page .PageWriter ;
3034import org .apache .parquet .column .page .mem .MemPageStore ;
@@ -46,19 +50,42 @@ public void test() throws IOException {
4650 ColumnDescriptor col = new ColumnDescriptor (path , PrimitiveTypeName .INT64 , 2 , 2 );
4751 LongStatistics stats = new LongStatistics ();
4852 PageWriter pageWriter = memPageStore .getPageWriter (col );
53+
4954 pageWriter .writePage (BytesInput .from (new byte [735 ]), 209 , stats , BIT_PACKED , BIT_PACKED , PLAIN );
5055 pageWriter .writePage (BytesInput .from (new byte [743 ]), 209 , stats , BIT_PACKED , BIT_PACKED , PLAIN );
5156 pageWriter .writePage (BytesInput .from (new byte [743 ]), 209 , stats , BIT_PACKED , BIT_PACKED , PLAIN );
5257 pageWriter .writePage (BytesInput .from (new byte [735 ]), 209 , stats , BIT_PACKED , BIT_PACKED , PLAIN );
58+
5359 PageReader pageReader = memPageStore .getPageReader (col );
5460 long totalValueCount = pageReader .getTotalValueCount ();
55- LOG .info (String .valueOf (totalValueCount ));
61+ LOG .info ("Total value count: " + totalValueCount );
62+
63+ assertEquals ("Expected total value count to be 836 (4 pages * 209 values)" , 836 , totalValueCount );
64+
5665 int total = 0 ;
66+ int pageCount = 0 ;
5767 do {
5868 DataPage readPage = pageReader .readPage ();
69+
70+ // Assert page was successfully read
71+ assertNotNull ("Page should not be null" , readPage );
72+ // Assert page has expected value count
73+ assertEquals ("Each page should have 209 values" , 209 , readPage .getValueCount ());
74+ // Assert encodings when the implementation is DataPageV1
75+ assertTrue ("Page should be an instance of DataPageV1" , readPage instanceof DataPageV1 );
76+ if (readPage instanceof DataPageV1 ) {
77+ DataPageV1 v1 = (DataPageV1 ) readPage ;
78+ assertEquals ("Page repetition level encoding should be BIT_PACKED" , BIT_PACKED , v1 .getRlEncoding ());
79+ assertEquals ("Page definition level encoding should be BIT_PACKED" , BIT_PACKED , v1 .getDlEncoding ());
80+ assertEquals ("Page value encoding should be PLAIN" , PLAIN , v1 .getValueEncoding ());
81+ }
82+
5983 total += readPage .getValueCount ();
60- LOG .info (readPage .toString ());
61- // TODO: assert
84+ pageCount ++;
6285 } while (total < totalValueCount );
86+
87+ // Assert we read exactly the expected number of pages and values
88+ assertEquals ("Should have read 4 pages" , 4 , pageCount );
89+ assertEquals ("Total values read should match totalValueCount" , totalValueCount , total );
6390 }
6491}
0 commit comments