private void ensureReadFunctionsAreInitialized()

in server/pxf-hdfs/src/main/java/org/greenplum/pxf/plugins/hdfs/orc/ORCVectorizedResolver.java [286:375]


    private void ensureReadFunctionsAreInitialized() {
        if (readFunctions != null) return;
        if (!(context.getMetadata() instanceof TypeDescription))
            throw new PxfRuntimeException("No ORC schema detected in request context");

        orcSchema = (TypeDescription) context.getMetadata();
        int schemaSize = orcSchema.getChildren().size();

        readFunctions = new TriFunction[schemaSize];
        typeOidMappings = new int[schemaSize];

        readFields = new HashMap<>(schemaSize);
        IntStream.range(0, schemaSize).forEach(idx -> {
            String columnName = orcSchema.getFieldNames().get(idx);
            TypeDescription t = orcSchema.getChildren().get(idx);
            readFields.put(columnName, t);
            readFields.put(columnName.toLowerCase(), t);
        });

        List<TypeDescription> children = orcSchema.getChildren();
        for (int i = 0; i < children.size(); i++) {
            TypeDescription t = children.get(i);
            switch (t.getCategory()) {
                case BOOLEAN:
                    readFunctions[i] = ORCVectorizedMappingFunctions::booleanReader;
                    typeOidMappings[i] = BOOLEAN.getOID();
                    break;
                case BYTE:
                case SHORT:
                    readFunctions[i] = ORCVectorizedMappingFunctions::shortReader;
                    typeOidMappings[i] = SMALLINT.getOID();
                    break;
                case INT:
                    readFunctions[i] = ORCVectorizedMappingFunctions::integerReader;
                    typeOidMappings[i] = INTEGER.getOID();
                    break;
                case LONG:
                    readFunctions[i] = ORCVectorizedMappingFunctions::longReader;
                    typeOidMappings[i] = BIGINT.getOID();
                    break;
                case FLOAT:
                    readFunctions[i] = ORCVectorizedMappingFunctions::floatReader;
                    typeOidMappings[i] = REAL.getOID();
                    break;
                case DOUBLE:
                    readFunctions[i] = ORCVectorizedMappingFunctions::doubleReader;
                    typeOidMappings[i] = FLOAT8.getOID();
                    break;
                case STRING:
                    readFunctions[i] = ORCVectorizedMappingFunctions::textReader;
                    typeOidMappings[i] = TEXT.getOID();
                    break;
                case DATE:
                    readFunctions[i] = ORCVectorizedMappingFunctions::dateReader;
                    typeOidMappings[i] = DATE.getOID();
                    break;
                case TIMESTAMP:
                    readFunctions[i] = ORCVectorizedMappingFunctions::timestampReader;
                    typeOidMappings[i] = TIMESTAMP.getOID();
                    break;
                case TIMESTAMP_INSTANT:
                    readFunctions[i] = ORCVectorizedMappingFunctions::timestampWithTimezoneReader;
                    typeOidMappings[i] = TIMESTAMP_WITH_TIME_ZONE.getOID();
                    break;
                case BINARY:
                    readFunctions[i] = ORCVectorizedMappingFunctions::binaryReader;
                    typeOidMappings[i] = BYTEA.getOID();
                    break;
                case DECIMAL:
                    readFunctions[i] = ORCVectorizedMappingFunctions::decimalReader;
                    typeOidMappings[i] = NUMERIC.getOID();
                    break;
                case VARCHAR:
                    readFunctions[i] = ORCVectorizedMappingFunctions::textReader;
                    typeOidMappings[i] = VARCHAR.getOID();
                    break;
                case CHAR:
                    readFunctions[i] = ORCVectorizedMappingFunctions::textReader;
                    typeOidMappings[i] = BPCHAR.getOID();
                    break;
                case LIST:
                    readFunctions[i] = ORCVectorizedMappingFunctions::listReader;
                    typeOidMappings[i] = getArrayDataType(t.getChildren().get(0)).getOID();
                    break;
                default:
                    throw new UnsupportedTypeException(
                            String.format("ORC type '%s' is not supported for reading.", t.getCategory().getName()));
            }
        }
    }