Search in sources :

Example 1 with DictionaryColumnWriter

use of com.facebook.presto.orc.writer.DictionaryColumnWriter in project presto by prestodb.

the class TestDictionaryColumnWriter method testDictionaryRetainedSizeWithDifferentSettings.

@Test
public void testDictionaryRetainedSizeWithDifferentSettings() {
    DictionaryColumnWriter ignoredRowGroupWriter = getStringDictionaryColumnWriter(true);
    DictionaryColumnWriter withRowGroupWriter = getStringDictionaryColumnWriter(false);
    int numEntries = 10_000;
    int numBlocks = 10;
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, numEntries);
    Slice slice = utf8Slice("SomeString");
    for (int i = 0; i < numEntries; i++) {
        VARCHAR.writeSlice(blockBuilder, slice);
    }
    Block block = blockBuilder.build();
    for (int i = 0; i < numBlocks; i++) {
        writeBlock(ignoredRowGroupWriter, block);
        writeBlock(withRowGroupWriter, block);
    }
    long ignoredRowGroupBytes = ignoredRowGroupWriter.getRowGroupRetainedSizeInBytes();
    long withRowGroupBytes = withRowGroupWriter.getRowGroupRetainedSizeInBytes();
    long expectedDictionaryIndexSize = (numBlocks * numEntries * SIZE_OF_BYTE);
    String message = String.format("Ignored bytes %s With bytes %s", ignoredRowGroupBytes, withRowGroupBytes);
    assertTrue(ignoredRowGroupBytes + expectedDictionaryIndexSize <= withRowGroupBytes, message);
}
Also used : Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Slice(io.airlift.slice.Slice) Block(com.facebook.presto.common.block.Block) DictionaryColumnWriter(com.facebook.presto.orc.writer.DictionaryColumnWriter) SliceDictionaryColumnWriter(com.facebook.presto.orc.writer.SliceDictionaryColumnWriter) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Test(org.testng.annotations.Test)

Example 2 with DictionaryColumnWriter

use of com.facebook.presto.orc.writer.DictionaryColumnWriter in project presto by prestodb.

the class BenchmarkDictionaryWriter method writeDictionaryAndConvert.

@Benchmark
public void writeDictionaryAndConvert(BenchmarkData data) {
    DictionaryColumnWriter columnWriter = getDictionaryColumnWriter(data, true);
    for (Block block : data.getBlocks()) {
        columnWriter.beginRowGroup();
        columnWriter.writeBlock(block);
        columnWriter.finishRowGroup();
    }
    int maxDirectBytes = toIntExact(new DataSize(512, MEGABYTE).toBytes());
    OptionalInt optionalInt = columnWriter.tryConvertToDirect(maxDirectBytes);
    checkState(optionalInt.isPresent(), "Column did not covert to direct");
    columnWriter.close();
    columnWriter.reset();
}
Also used : DataSize(io.airlift.units.DataSize) Block(com.facebook.presto.common.block.Block) OptionalInt(java.util.OptionalInt) DictionaryColumnWriter(com.facebook.presto.orc.writer.DictionaryColumnWriter) SliceDictionaryColumnWriter(com.facebook.presto.orc.writer.SliceDictionaryColumnWriter) LongDictionaryColumnWriter(com.facebook.presto.orc.writer.LongDictionaryColumnWriter) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 3 with DictionaryColumnWriter

use of com.facebook.presto.orc.writer.DictionaryColumnWriter in project presto by prestodb.

the class BenchmarkDictionaryWriter method getDictionaryColumnWriter.

private DictionaryColumnWriter getDictionaryColumnWriter(BenchmarkData data, boolean sortStringDictionaryKeys) {
    DictionaryColumnWriter columnWriter;
    Type type = data.getType();
    ColumnWriterOptions columnWriterOptions = getColumnWriterOptions(sortStringDictionaryKeys);
    if (type.equals(VARCHAR)) {
        columnWriter = new SliceDictionaryColumnWriter(COLUMN_INDEX, type, columnWriterOptions, Optional.empty(), DWRF, DWRF.createMetadataWriter());
    } else {
        columnWriter = new LongDictionaryColumnWriter(COLUMN_INDEX, type, columnWriterOptions, Optional.empty(), DWRF, DWRF.createMetadataWriter());
    }
    return columnWriter;
}
Also used : Type(com.facebook.presto.common.type.Type) SliceDictionaryColumnWriter(com.facebook.presto.orc.writer.SliceDictionaryColumnWriter) LongDictionaryColumnWriter(com.facebook.presto.orc.writer.LongDictionaryColumnWriter) DictionaryColumnWriter(com.facebook.presto.orc.writer.DictionaryColumnWriter) SliceDictionaryColumnWriter(com.facebook.presto.orc.writer.SliceDictionaryColumnWriter) LongDictionaryColumnWriter(com.facebook.presto.orc.writer.LongDictionaryColumnWriter)

Aggregations

DictionaryColumnWriter (com.facebook.presto.orc.writer.DictionaryColumnWriter)3 SliceDictionaryColumnWriter (com.facebook.presto.orc.writer.SliceDictionaryColumnWriter)3 Block (com.facebook.presto.common.block.Block)2 LongDictionaryColumnWriter (com.facebook.presto.orc.writer.LongDictionaryColumnWriter)2 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 Type (com.facebook.presto.common.type.Type)1 Slice (io.airlift.slice.Slice)1 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)1 DataSize (io.airlift.units.DataSize)1 OptionalInt (java.util.OptionalInt)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 Test (org.testng.annotations.Test)1