presto-record-decoder/src/main/java/io/prestosql/decoder/raw/RawColumnDecoder.java/RawColumnDecoder/RawColumnDecoder
class RawColumnDecoder:    public RawColumnDecoder(DecoderColumnHandle columnHandle)
    {
        try {
            requireNonNull(columnHandle, "columnHandle is null");
            checkArgument(!columnHandle.isInternal(), "unexpected internal column '%s'", columnHandle.getName());
            checkArgument(columnHandle.getFormatHint() == null, "unexpected format hint '%s' defined for column '%s'", columnHandle.getFormatHint(), columnHandle.getName());

            columnName = columnHandle.getName();
            columnType = columnHandle.getType();

            try {
                fieldType = columnHandle.getDataFormat() == null ?
                        FieldType.BYTE :
                        FieldType.valueOf(columnHandle.getDataFormat().toUpperCase(Locale.ENGLISH));
            }
            catch (IllegalArgumentException e) {
                throw new IllegalArgumentException(format("invalid dataFormat '%s' for column '%s'", columnHandle.getDataFormat(), columnName));
            }

            String mapping = Optional.ofNullable(columnHandle.getMapping()).orElse("0");
            Matcher mappingMatcher = MAPPING_PATTERN.matcher(mapping);
            if (!mappingMatcher.matches()) {
                throw new IllegalArgumentException(format("invalid mapping format '%s' for column '%s'", mapping, columnName));
            }
            start = parseInt(mappingMatcher.group(1));
            if (mappingMatcher.group(2) != null) {
                end = OptionalInt.of(parseInt(mappingMatcher.group(2)));
            }
            else {
                if (!isVarcharType(columnType)) {
                    end = OptionalInt.of(start + fieldType.getSize());
                }
                else {
                    end = OptionalInt.empty();
                }
            }

            checkArgument(start >= 0, "start offset %s for column '%s' must be greater or equal 0", start, columnName);
            end.ifPresent(endValue -> {
                checkArgument(endValue >= 0, "end offset %s for column '%s' must be greater or equal 0", endValue, columnName);
                checkArgument(endValue >= start, "end offset %s for column '%s' must greater or equal start offset", endValue, columnName);
            });

            checkArgument(isSupportedType(columnType), "Unsupported column type '%s' for column '%s'", columnType.getDisplayName(), columnName);

            if (columnType == BIGINT) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE, FieldType.SHORT, FieldType.INT, FieldType.LONG);
            }
            if (columnType == INTEGER) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE, FieldType.SHORT, FieldType.INT);
            }
            if (columnType == SMALLINT) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE, FieldType.SHORT);
            }
            if (columnType == TINYINT) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE);
            }
            if (columnType == BOOLEAN) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE, FieldType.SHORT, FieldType.INT, FieldType.LONG);
            }
            if (columnType == DOUBLE) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.DOUBLE, FieldType.FLOAT);
            }
            if (isVarcharType(columnType)) {
                checkFieldTypeOneOf(fieldType, columnName, FieldType.BYTE);
            }

            if (!isVarcharType(columnType)) {
                checkArgument(!end.isPresent() || end.getAsInt() - start == fieldType.getSize(),
                        "Bytes mapping for column '%s' does not match dataFormat '%s'; expected %s bytes but got %s",
                        columnName,
                        fieldType.getSize(),
                        end.getAsInt() - start);
            }
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(StandardErrorCode.GENERIC_USER_ERROR, e);
        }
    }