Search in sources :

Example 1 with PageType

use of org.apache.parquet.format.PageType in project parquet-mr by apache.

the class ParquetMetadataConverter method convertEncodingStats.

public List<PageEncodingStats> convertEncodingStats(EncodingStats stats) {
    if (stats == null) {
        return null;
    }
    List<PageEncodingStats> formatStats = new ArrayList<PageEncodingStats>();
    for (org.apache.parquet.column.Encoding encoding : stats.getDictionaryEncodings()) {
        formatStats.add(new PageEncodingStats(PageType.DICTIONARY_PAGE, getEncoding(encoding), stats.getNumDictionaryPagesEncodedAs(encoding)));
    }
    PageType dataPageType = (stats.usesV2Pages() ? PageType.DATA_PAGE_V2 : PageType.DATA_PAGE);
    for (org.apache.parquet.column.Encoding encoding : stats.getDataEncodings()) {
        formatStats.add(new PageEncodingStats(dataPageType, getEncoding(encoding), stats.getNumDataPagesEncodedAs(encoding)));
    }
    return formatStats;
}
Also used : ArrayList(java.util.ArrayList) PageEncodingStats(org.apache.parquet.format.PageEncodingStats) PageType(org.apache.parquet.format.PageType)

Example 2 with PageType

use of org.apache.parquet.format.PageType in project parquet-mr by apache.

the class TestParquetMetadataConverter method testPageHeader.

@Test
public void testPageHeader() throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PageType type = PageType.DATA_PAGE;
    int compSize = 10;
    int uncSize = 20;
    PageHeader pageHeader = new PageHeader(type, uncSize, compSize);
    writePageHeader(pageHeader, out);
    PageHeader readPageHeader = readPageHeader(new ByteArrayInputStream(out.toByteArray()));
    assertEquals(pageHeader, readPageHeader);
}
Also used : Util.readPageHeader(org.apache.parquet.format.Util.readPageHeader) PageHeader(org.apache.parquet.format.PageHeader) Util.writePageHeader(org.apache.parquet.format.Util.writePageHeader) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PageType(org.apache.parquet.format.PageType) ParquetMetadataConverter.filterFileMetaDataByMidpoint(org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByMidpoint) Test(org.junit.Test)

Aggregations

PageType (org.apache.parquet.format.PageType)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 PageEncodingStats (org.apache.parquet.format.PageEncodingStats)1 PageHeader (org.apache.parquet.format.PageHeader)1 Util.readPageHeader (org.apache.parquet.format.Util.readPageHeader)1 Util.writePageHeader (org.apache.parquet.format.Util.writePageHeader)1 ParquetMetadataConverter.filterFileMetaDataByMidpoint (org.apache.parquet.format.converter.ParquetMetadataConverter.filterFileMetaDataByMidpoint)1 Test (org.junit.Test)1