Search in sources :

Example 1 with PLAIN_DICTIONARY

use of com.facebook.presto.parquet.ParquetEncoding.PLAIN_DICTIONARY in project presto by prestodb.

the class TestValuesDecoders method testInt64RLEDictionary.

@Test
public void testInt64RLEDictionary() throws IOException {
    Random random = new Random(83);
    int valueCount = 2048;
    int dictionarySize = 29;
    List<Object> dictionary = new ArrayList<>();
    List<Integer> dictionaryIds = new ArrayList<>();
    byte[] dictionaryPage = generatePlainValuesPage(dictionarySize, 64, random, dictionary);
    byte[] dataPage = generateDictionaryIdPage2048(dictionarySize - 1, random, dictionaryIds);
    List<Object> expectedValues = new ArrayList<>();
    for (Integer dictionaryId : dictionaryIds) {
        expectedValues.add(dictionary.get(dictionaryId));
    }
    LongDictionary longDictionary = new LongDictionary(new DictionaryPage(Slices.wrappedBuffer(dictionaryPage), dictionarySize, PLAIN_DICTIONARY));
    int64BatchReadWithSkipHelper(valueCount, 0, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(29, 0, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(89, 0, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(1024, 0, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(256, 29, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(89, 29, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    int64BatchReadWithSkipHelper(1024, 1024, valueCount, int64Dictionary(dataPage, dictionarySize, longDictionary), expectedValues);
    List<Object> expectedTimestampValues = expectedValues.stream().map(v -> (long) v / 1000L).collect(Collectors.toList());
    int64BatchReadWithSkipHelper(valueCount, 0, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(29, 0, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(89, 0, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(1024, 0, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(256, 29, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(89, 29, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
    int64BatchReadWithSkipHelper(1024, 1024, valueCount, int64TimestampMicrosDictionary(dataPage, dictionarySize, longDictionary), expectedTimestampValues);
}
Also used : Int64TimestampMicrosPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int64TimestampMicrosPlainValuesDecoder) BooleanValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BooleanValuesDecoder) LongDictionary(com.facebook.presto.parquet.dictionary.LongDictionary) Arrays(java.util.Arrays) BinaryBatchDictionary(com.facebook.presto.parquet.batchreader.dictionary.BinaryBatchDictionary) Int32ValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int32ValuesDecoder) Int64TimestampMicrosRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int64TimestampMicrosRLEDictionaryValuesDecoder) BytesUtils.getWidthFromMaxInt(org.apache.parquet.bytes.BytesUtils.getWidthFromMaxInt) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) Random(java.util.Random) ByteBuffer(java.nio.ByteBuffer) TestParquetUtils.generatePlainValuesPage(com.facebook.presto.parquet.batchreader.decoders.TestParquetUtils.generatePlainValuesPage) ArrayList(java.util.ArrayList) ByteArrayInputStream(java.io.ByteArrayInputStream) Int64ValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64ValuesDecoder) BooleanRLEValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.BooleanRLEValuesDecoder) Int32RLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int32RLEDictionaryValuesDecoder) PLAIN_DICTIONARY(com.facebook.presto.parquet.ParquetEncoding.PLAIN_DICTIONARY) Slices(io.airlift.slice.Slices) UTF8(org.apache.parquet.bytes.BytesUtils.UTF8) Int64TimestampMicrosValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64TimestampMicrosValuesDecoder) TimestampRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.TimestampRLEDictionaryValuesDecoder) TimestampValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.TimestampValuesDecoder) BinaryPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.BinaryPlainValuesDecoder) BooleanPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.BooleanPlainValuesDecoder) BinaryRLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.BinaryRLEDictionaryValuesDecoder) IOException(java.io.IOException) Int64PlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int64PlainValuesDecoder) Math.min(java.lang.Math.min) Collectors(java.util.stream.Collectors) TestParquetUtils.generateDictionaryIdPage2048(com.facebook.presto.parquet.batchreader.decoders.TestParquetUtils.generateDictionaryIdPage2048) TimestampPlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.TimestampPlainValuesDecoder) List(java.util.List) IntegerDictionary(com.facebook.presto.parquet.dictionary.IntegerDictionary) Int32PlainValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.plain.Int32PlainValuesDecoder) Int64RLEDictionaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.rle.Int64RLEDictionaryValuesDecoder) BinaryValuesDecoder(com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BinaryValuesDecoder) TimestampDictionary(com.facebook.presto.parquet.batchreader.dictionary.TimestampDictionary) DictionaryPage(com.facebook.presto.parquet.DictionaryPage) Random(java.util.Random) LongDictionary(com.facebook.presto.parquet.dictionary.LongDictionary) ArrayList(java.util.ArrayList) DictionaryPage(com.facebook.presto.parquet.DictionaryPage) Test(org.testng.annotations.Test)

Aggregations

DictionaryPage (com.facebook.presto.parquet.DictionaryPage)1 PLAIN_DICTIONARY (com.facebook.presto.parquet.ParquetEncoding.PLAIN_DICTIONARY)1 TestParquetUtils.generateDictionaryIdPage2048 (com.facebook.presto.parquet.batchreader.decoders.TestParquetUtils.generateDictionaryIdPage2048)1 TestParquetUtils.generatePlainValuesPage (com.facebook.presto.parquet.batchreader.decoders.TestParquetUtils.generatePlainValuesPage)1 BinaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BinaryValuesDecoder)1 BooleanValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.BooleanValuesDecoder)1 Int32ValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int32ValuesDecoder)1 Int64TimestampMicrosValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64TimestampMicrosValuesDecoder)1 Int64ValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64ValuesDecoder)1 TimestampValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.TimestampValuesDecoder)1 BinaryPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.BinaryPlainValuesDecoder)1 BooleanPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.BooleanPlainValuesDecoder)1 Int32PlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int32PlainValuesDecoder)1 Int64PlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int64PlainValuesDecoder)1 Int64TimestampMicrosPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.Int64TimestampMicrosPlainValuesDecoder)1 TimestampPlainValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.plain.TimestampPlainValuesDecoder)1 BinaryRLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.BinaryRLEDictionaryValuesDecoder)1 BooleanRLEValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.BooleanRLEValuesDecoder)1 Int32RLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.Int32RLEDictionaryValuesDecoder)1 Int64RLEDictionaryValuesDecoder (com.facebook.presto.parquet.batchreader.decoders.rle.Int64RLEDictionaryValuesDecoder)1