/** * Selects the fields from the ORC schema that are returned by InputFormat. * * @param selectedFields The indices of the fields of the ORC schema that are returned by the InputFormat. */ public void selectFields(int... selectedFields) { // set field mapping this.selectedFields = selectedFields; // adapt result type this.rowType = RowTypeInfo.projectFields(this.rowType, selectedFields); }
private OrcTableSource(String path, TypeDescription orcSchema, Configuration orcConfig, int batchSize, boolean recursiveEnumeration, int[] selectedFields, Predicate[] predicates) { Preconditions.checkNotNull(path, "Path must not be null."); Preconditions.checkNotNull(orcSchema, "OrcSchema must not be null."); Preconditions.checkNotNull(path, "Configuration must not be null."); Preconditions.checkArgument(batchSize > 0, "Batch size must be larger than null."); this.path = path; this.orcSchema = orcSchema; this.orcConfig = orcConfig; this.batchSize = batchSize; this.recursiveEnumeration = recursiveEnumeration; this.selectedFields = selectedFields; this.predicates = predicates; // determine the type information from the ORC schema RowTypeInfo typeInfoFromSchema = (RowTypeInfo) OrcBatchReader.schemaToTypeInfo(this.orcSchema); // set return type info if (selectedFields == null) { this.typeInfo = typeInfoFromSchema; } else { this.typeInfo = RowTypeInfo.projectFields(typeInfoFromSchema, selectedFields); } // create a TableSchema that corresponds to the ORC schema this.tableSchema = new TableSchema( typeInfoFromSchema.getFieldNames(), typeInfoFromSchema.getFieldTypes() ); }