presto-orc/src/main/java/io/prestosql/orc/writer/SliceDictionaryColumnWriter.java/SliceDictionaryColumnWriter/writeDictionaryRowGroup
class SliceDictionaryColumnWriter:    private boolean writeDictionaryRowGroup(Block dictionary, int valueCount, IntBigArray dictionaryIndexes, int maxDirectBytes)
    {
        int[][] segments = dictionaryIndexes.getSegments();
        for (int i = 0; valueCount > 0 && i < segments.length; i++) {
            int[] segment = segments[i];
            int positionCount = Math.min(valueCount, segment.length);
            Block block = new DictionaryBlock(positionCount, dictionary, segment);

            while (block != null) {
                int chunkPositionCount = block.getPositionCount();
                Block chunk = block.getRegion(0, chunkPositionCount);

                // avoid chunk with huge logical size
                while (chunkPositionCount > 1 && chunk.getLogicalSizeInBytes() > DIRECT_CONVERSION_CHUNK_MAX_LOGICAL_BYTES) {
                    chunkPositionCount /= 2;
                    chunk = chunk.getRegion(0, chunkPositionCount);
                }

                directColumnWriter.writeBlock(chunk);
                if (directColumnWriter.getBufferedBytes() > maxDirectBytes) {
                    return false;
                }

                // slice block to only unconverted rows
                if (chunkPositionCount < block.getPositionCount()) {
                    block = block.getRegion(chunkPositionCount, block.getPositionCount() - chunkPositionCount);
                }
                else {
                    block = null;
                }
            }

            valueCount -= positionCount;
        }
        checkState(valueCount == 0);
        return true;
    }