presto-hive/src/main/java/io/prestosql/plugin/hive/HiveCoercionRecordCursor.java/HiveCoercionRecordCursor/rewriteBlock
class HiveCoercionRecordCursor:    private static void rewriteBlock(
            Type fromType,
            Type toType,
            Block block,
            int position,
            BlockBuilder blockBuilder,
            Coercer coercer,
            BridgingRecordCursor bridgingRecordCursor)
    {
        Class<?> fromJavaType = fromType.getJavaType();
        if (fromJavaType == long.class) {
            bridgingRecordCursor.setValue(fromType.getLong(block, position));
        }
        else if (fromJavaType == double.class) {
            bridgingRecordCursor.setValue(fromType.getDouble(block, position));
        }
        else if (fromJavaType == boolean.class) {
            bridgingRecordCursor.setValue(fromType.getBoolean(block, position));
        }
        else if (fromJavaType == Slice.class) {
            bridgingRecordCursor.setValue(fromType.getSlice(block, position));
        }
        else if (fromJavaType == Block.class) {
            bridgingRecordCursor.setValue(fromType.getObject(block, position));
        }
        else {
            bridgingRecordCursor.setValue(null);
        }
        coercer.reset();
        Class<?> toJaveType = toType.getJavaType();
        if (coercer.isNull(bridgingRecordCursor, 0)) {
            blockBuilder.appendNull();
        }
        else if (toJaveType == long.class) {
            toType.writeLong(blockBuilder, coercer.getLong(bridgingRecordCursor, 0));
        }
        else if (toJaveType == double.class) {
            toType.writeDouble(blockBuilder, coercer.getDouble(bridgingRecordCursor, 0));
        }
        else if (toJaveType == boolean.class) {
            toType.writeBoolean(blockBuilder, coercer.getBoolean(bridgingRecordCursor, 0));
        }
        else if (toJaveType == Slice.class) {
            toType.writeSlice(blockBuilder, coercer.getSlice(bridgingRecordCursor, 0));
        }
        else if (toJaveType == Block.class) {
            toType.writeObject(blockBuilder, coercer.getObject(bridgingRecordCursor, 0));
        }
        else {
            throw new PrestoException(NOT_SUPPORTED, format("Unsupported coercion from %s to %s", fromType.getDisplayName(), toType.getDisplayName()));
        }
        coercer.reset();
        bridgingRecordCursor.close();
    }