presto-main/src/main/java/io/prestosql/operator/scalar/MapEntriesFunction.java/MapEntriesFunction/mapFromEntries
class MapEntriesFunction:    @TypeParameter("K")
    @TypeParameter("V")
    @SqlType("array(row(K,V))")
    public Block mapFromEntries(
            @TypeParameter("row(K,V)") RowType rowType,
            @SqlType("map(K,V)") Block block)
    {
        verify(rowType.getTypeParameters().size() == 2);
        verify(block.getPositionCount() % 2 == 0);

        Type keyType = rowType.getTypeParameters().get(0);
        Type valueType = rowType.getTypeParameters().get(1);
        ArrayType arrayType = new ArrayType(rowType);

        if (pageBuilder.isFull()) {
            pageBuilder.reset();
        }

        int entryCount = block.getPositionCount() / 2;
        BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
        BlockBuilder entryBuilder = blockBuilder.beginBlockEntry();
        for (int i = 0; i < entryCount; i++) {
            BlockBuilder rowBuilder = entryBuilder.beginBlockEntry();
            keyType.appendTo(block, 2 * i, rowBuilder);
            valueType.appendTo(block, 2 * i + 1, rowBuilder);
            entryBuilder.closeEntry();
        }

        blockBuilder.closeEntry();
        pageBuilder.declarePosition();
        return arrayType.getObject(blockBuilder, blockBuilder.getPositionCount() - 1);
    }