private void appendTo()

in paimon-prestosql-common/src/main/java/org/apache/paimon/prestosql/PrestoSqlPageSourceBase.java [152:200]


    private void appendTo(Type type, DataType logicalType, Object value, BlockBuilder output) {
        if (value == null) {
            output.appendNull();
            return;
        }

        Class<?> javaType = type.getJavaType();
        if (javaType == boolean.class) {
            type.writeBoolean(output, (Boolean) value);
        } else if (javaType == long.class) {
            if (type.equals(BIGINT)
                    || type.equals(INTEGER)
                    || type.equals(TINYINT)
                    || type.equals(SMALLINT)
                    || type.equals(DATE)) {
                type.writeLong(output, ((Number) value).longValue());
            } else if (type.equals(REAL)) {
                type.writeLong(output, Float.floatToIntBits((Float) value));
            } else if (type instanceof DecimalType) {
                DecimalType decimalType = (DecimalType) type;
                BigDecimal decimal = ((Decimal) value).toBigDecimal();
                type.writeLong(output, encodeShortScaledValue(decimal, decimalType.getScale()));
            } else if (type.equals(TIMESTAMP)) {
                type.writeLong(output, ((Timestamp) value).getMillisecond());
            } else if (type.equals(TIME)) {
                type.writeLong(output, (int) value);
            } else if (type.equals(TIMESTAMP_WITH_TIME_ZONE)) {
                type.writeLong(
                        output,
                        packDateTimeWithZone(((Timestamp) value).getMillisecond(), UTC_KEY));
            } else {
                throw new PrestoSqlException(
                        GENERIC_INTERNAL_ERROR,
                        format("Unhandled type for %s: %s", javaType.getSimpleName(), type));
            }
        } else if (javaType == double.class) {
            type.writeDouble(output, ((Number) value).doubleValue());
        } else if (type instanceof DecimalType) {
            writeObject(output, type, value);
        } else if (javaType == Slice.class) {
            writeSlice(output, type, value);
        } else if (javaType == Block.class) {
            writeBlock(output, type, logicalType, value);
        } else {
            throw new PrestoSqlException(
                    GENERIC_INTERNAL_ERROR,
                    format("Unhandled type for %s: %s", javaType.getSimpleName(), type));
        }
    }