Search in sources :

Example 6 with PageReader

use of org.apache.parquet.column.page.PageReader in project parquet-mr by apache.

the class TestMemPageStore method test.

@Test
public void test() throws IOException {
    MemPageStore memPageStore = new MemPageStore(10);
    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();
    System.out.println(totalValueCount);
    int total = 0;
    do {
        DataPage readPage = pageReader.readPage();
        total += readPage.getValueCount();
        System.out.println(readPage);
    // TODO: assert
    } while (total < totalValueCount);
}
Also used : LongStatistics(org.apache.parquet.column.statistics.LongStatistics) DataPage(org.apache.parquet.column.page.DataPage) ColumnDescriptor(org.apache.parquet.column.ColumnDescriptor) PageReader(org.apache.parquet.column.page.PageReader) MemPageStore(org.apache.parquet.column.page.mem.MemPageStore) PageWriter(org.apache.parquet.column.page.PageWriter) Test(org.junit.Test)

Example 7 with PageReader

use of org.apache.parquet.column.page.PageReader in project drill by axbaretto.

the class ParquetRecordReaderTest method validateContains.

private void validateContains(MessageType schema, PageReadStore pages, String[] path, int values, BytesInput bytes) throws IOException {
    PageReader pageReader = pages.getPageReader(schema.getColumnDescription(path));
    DataPageV1 page = (DataPageV1) pageReader.readPage();
    assertEquals(values, page.getValueCount());
    assertArrayEquals(bytes.toByteArray(), page.getBytes().toByteArray());
}
Also used : PageReader(org.apache.parquet.column.page.PageReader) DataPageV1(org.apache.parquet.column.page.DataPageV1)

Aggregations

PageReader (org.apache.parquet.column.page.PageReader)7 DataPage (org.apache.parquet.column.page.DataPage)4 DataPageV1 (org.apache.parquet.column.page.DataPageV1)4 ColumnDescriptor (org.apache.parquet.column.ColumnDescriptor)3 DataPageV2 (org.apache.parquet.column.page.DataPageV2)2 DictionaryPage (org.apache.parquet.column.page.DictionaryPage)2 PageReadStore (org.apache.parquet.column.page.PageReadStore)2 PageWriter (org.apache.parquet.column.page.PageWriter)2 MessageType (org.apache.parquet.schema.MessageType)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 List (java.util.List)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 BytesInput (org.apache.parquet.bytes.BytesInput)1 HeapByteBufferAllocator (org.apache.parquet.bytes.HeapByteBufferAllocator)1 Util.encodingAsString (org.apache.parquet.cli.Util.encodingAsString)1 Util.minMaxAsString (org.apache.parquet.cli.Util.minMaxAsString)1 Encoding (org.apache.parquet.column.Encoding)1 MemPageStore (org.apache.parquet.column.page.mem.MemPageStore)1