Search in sources :

Example 1 with ValuesReader

use of org.apache.parquet.column.values.ValuesReader in project parquet-mr by apache.

the class TestDeltaLengthByteArray method testLengths.

@Test
public void testLengths() throws IOException {
    DeltaLengthByteArrayValuesWriter writer = getDeltaLengthByteArrayValuesWriter();
    ValuesReader reader = new DeltaBinaryPackingValuesReader();
    Utils.writeData(writer, values);
    int[] bin = Utils.readInts(reader, writer.getBytes().toInputStream(), values.length);
    for (int i = 0; i < bin.length; i++) {
        Assert.assertEquals(values[i].length(), bin[i]);
    }
}
Also used : DeltaBinaryPackingValuesReader(org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesReader) ValuesReader(org.apache.parquet.column.values.ValuesReader) DeltaBinaryPackingValuesReader(org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesReader) Test(org.junit.Test)

Example 2 with ValuesReader

use of org.apache.parquet.column.values.ValuesReader in project parquet-mr by apache.

the class TestDictionary method testLongDictionaryFallBack.

@Test
public void testLongDictionaryFallBack() throws IOException {
    int slabSize = 100;
    int maxDictionaryByteSize = 50;
    final FallbackValuesWriter<PlainLongDictionaryValuesWriter, PlainValuesWriter> cw = newPlainLongDictionaryValuesWriter(maxDictionaryByteSize, slabSize);
    // Fallbacked to Plain encoding, therefore use PlainValuesReader to read it back
    ValuesReader reader = new PlainValuesReader.LongPlainValuesReader();
    roundTripLong(cw, reader, maxDictionaryByteSize);
    // simulate cutting the page
    cw.reset();
    assertEquals(0, cw.getBufferedSize());
    cw.resetDictionary();
    roundTripLong(cw, reader, maxDictionaryByteSize);
}
Also used : PlainValuesWriter(org.apache.parquet.column.values.plain.PlainValuesWriter) ValuesReader(org.apache.parquet.column.values.ValuesReader) PlainValuesReader(org.apache.parquet.column.values.plain.PlainValuesReader) BinaryPlainValuesReader(org.apache.parquet.column.values.plain.BinaryPlainValuesReader) PlainLongDictionaryValuesWriter(org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainLongDictionaryValuesWriter) Test(org.junit.Test)

Example 3 with ValuesReader

use of org.apache.parquet.column.values.ValuesReader in project parquet-mr by apache.

the class TestDictionary method testDoubleDictionaryFallBack.

@Test
public void testDoubleDictionaryFallBack() throws IOException {
    int slabSize = 100;
    int maxDictionaryByteSize = 50;
    final FallbackValuesWriter<PlainDoubleDictionaryValuesWriter, PlainValuesWriter> cw = newPlainDoubleDictionaryValuesWriter(maxDictionaryByteSize, slabSize);
    // Fallbacked to Plain encoding, therefore use PlainValuesReader to read it back
    ValuesReader reader = new PlainValuesReader.DoublePlainValuesReader();
    roundTripDouble(cw, reader, maxDictionaryByteSize);
    // simulate cutting the page
    cw.reset();
    assertEquals(0, cw.getBufferedSize());
    cw.resetDictionary();
    roundTripDouble(cw, reader, maxDictionaryByteSize);
}
Also used : PlainValuesWriter(org.apache.parquet.column.values.plain.PlainValuesWriter) ValuesReader(org.apache.parquet.column.values.ValuesReader) PlainValuesReader(org.apache.parquet.column.values.plain.PlainValuesReader) BinaryPlainValuesReader(org.apache.parquet.column.values.plain.BinaryPlainValuesReader) PlainDoubleDictionaryValuesWriter(org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainDoubleDictionaryValuesWriter) Test(org.junit.Test)

Example 4 with ValuesReader

use of org.apache.parquet.column.values.ValuesReader in project parquet-mr by apache.

the class TestDictionary method testIntDictionaryFallBack.

@Test
public void testIntDictionaryFallBack() throws IOException {
    int slabSize = 100;
    int maxDictionaryByteSize = 50;
    final FallbackValuesWriter<PlainIntegerDictionaryValuesWriter, PlainValuesWriter> cw = newPlainIntegerDictionaryValuesWriter(maxDictionaryByteSize, slabSize);
    // Fallbacked to Plain encoding, therefore use PlainValuesReader to read it back
    ValuesReader reader = new PlainValuesReader.IntegerPlainValuesReader();
    roundTripInt(cw, reader, maxDictionaryByteSize);
    // simulate cutting the page
    cw.reset();
    assertEquals(0, cw.getBufferedSize());
    cw.resetDictionary();
    roundTripInt(cw, reader, maxDictionaryByteSize);
}
Also used : PlainValuesWriter(org.apache.parquet.column.values.plain.PlainValuesWriter) ValuesReader(org.apache.parquet.column.values.ValuesReader) PlainValuesReader(org.apache.parquet.column.values.plain.PlainValuesReader) BinaryPlainValuesReader(org.apache.parquet.column.values.plain.BinaryPlainValuesReader) PlainIntegerDictionaryValuesWriter(org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainIntegerDictionaryValuesWriter) Test(org.junit.Test)

Example 5 with ValuesReader

use of org.apache.parquet.column.values.ValuesReader in project parquet-mr by apache.

the class TestDictionary method testFloatDictionaryFallBack.

@Test
public void testFloatDictionaryFallBack() throws IOException {
    int slabSize = 100;
    int maxDictionaryByteSize = 50;
    final FallbackValuesWriter<PlainFloatDictionaryValuesWriter, PlainValuesWriter> cw = newPlainFloatDictionaryValuesWriter(maxDictionaryByteSize, slabSize);
    // Fallbacked to Plain encoding, therefore use PlainValuesReader to read it back
    ValuesReader reader = new PlainValuesReader.FloatPlainValuesReader();
    roundTripFloat(cw, reader, maxDictionaryByteSize);
    // simulate cutting the page
    cw.reset();
    assertEquals(0, cw.getBufferedSize());
    cw.resetDictionary();
    roundTripFloat(cw, reader, maxDictionaryByteSize);
}
Also used : PlainValuesWriter(org.apache.parquet.column.values.plain.PlainValuesWriter) ValuesReader(org.apache.parquet.column.values.ValuesReader) PlainValuesReader(org.apache.parquet.column.values.plain.PlainValuesReader) BinaryPlainValuesReader(org.apache.parquet.column.values.plain.BinaryPlainValuesReader) PlainFloatDictionaryValuesWriter(org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainFloatDictionaryValuesWriter) Test(org.junit.Test)

Aggregations

ValuesReader (org.apache.parquet.column.values.ValuesReader)15 Test (org.junit.Test)10 BinaryPlainValuesReader (org.apache.parquet.column.values.plain.BinaryPlainValuesReader)7 PlainValuesReader (org.apache.parquet.column.values.plain.PlainValuesReader)7 PlainValuesWriter (org.apache.parquet.column.values.plain.PlainValuesWriter)7 IOException (java.io.IOException)4 ValuesWriter (org.apache.parquet.column.values.ValuesWriter)4 PlainDoubleDictionaryValuesWriter (org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainDoubleDictionaryValuesWriter)4 PlainFloatDictionaryValuesWriter (org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainFloatDictionaryValuesWriter)4 PlainIntegerDictionaryValuesWriter (org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainIntegerDictionaryValuesWriter)4 PlainLongDictionaryValuesWriter (org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainLongDictionaryValuesWriter)4 ParquetDecodingException (org.apache.parquet.io.ParquetDecodingException)4 BytesInput (org.apache.parquet.bytes.BytesInput)3 DeltaBinaryPackingValuesReader (org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesReader)3 PlainBinaryDictionaryValuesWriter (org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainBinaryDictionaryValuesWriter)3 FallbackValuesWriter (org.apache.parquet.column.values.fallback.FallbackValuesWriter)3 ByteBufferInputStream (org.apache.parquet.bytes.ByteBufferInputStream)2 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)1 DirectByteBufferAllocator (org.apache.parquet.bytes.DirectByteBufferAllocator)1 RequiresPreviousReader (org.apache.parquet.column.values.RequiresPreviousReader)1