use of org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainFloatDictionaryValuesWriter in project parquet-mr by apache.
the class TestDictionary method testFloatDictionary.
@Test
public void testFloatDictionary() throws IOException {
int COUNT = 2000;
int COUNT2 = 4000;
final FallbackValuesWriter<PlainFloatDictionaryValuesWriter, PlainValuesWriter> cw = newPlainFloatDictionaryValuesWriter(10000, 10000);
for (float i = 0; i < COUNT; i++) {
cw.writeFloat(i % 50);
}
BytesInput bytes1 = getBytesAndCheckEncoding(cw, PLAIN_DICTIONARY);
assertEquals(50, cw.initialWriter.getDictionarySize());
for (float i = COUNT2; i > 0; i--) {
cw.writeFloat(i % 50);
}
BytesInput bytes2 = getBytesAndCheckEncoding(cw, PLAIN_DICTIONARY);
assertEquals(50, cw.initialWriter.getDictionarySize());
DictionaryValuesReader cr = initDicReader(cw, FLOAT);
cr.initFromPage(COUNT, bytes1.toInputStream());
for (float i = 0; i < COUNT; i++) {
float back = cr.readFloat();
assertEquals(i % 50, back, 0.0f);
}
cr.initFromPage(COUNT2, bytes2.toInputStream());
for (float i = COUNT2; i > 0; i--) {
float back = cr.readFloat();
assertEquals(i % 50, back, 0.0f);
}
}
use of org.apache.parquet.column.values.dictionary.DictionaryValuesWriter.PlainFloatDictionaryValuesWriter 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);
}
Aggregations