presto-main/src/main/java/io/prestosql/operator/aggregation/TypedKeyValueHeap.java/TypedKeyValueHeap/add
class TypedKeyValueHeap:    public void add(Block keyBlock, Block valueBlock, int position)
    {
        checkArgument(!keyBlock.isNull(position));
        if (positionCount == capacity) {
            if (keyComparator.compareTo(keyBlockBuilder, heapIndex[0], keyBlock, position) >= 0) {
                return; // and new element is not larger than heap top: do not add
            }
            heapIndex[0] = keyBlockBuilder.getPositionCount();
            keyType.appendTo(keyBlock, position, keyBlockBuilder);
            valueType.appendTo(valueBlock, position, valueBlockBuilder);
            siftDown();
        }
        else {
            heapIndex[positionCount] = keyBlockBuilder.getPositionCount();
            positionCount++;
            keyType.appendTo(keyBlock, position, keyBlockBuilder);
            valueType.appendTo(valueBlock, position, valueBlockBuilder);
            siftUp();
        }
        compactIfNecessary();
    }