public ParseSetup readSetup ( FileVec f , String [ ] columnNames , byte [ ] columnTypes ) { try { Reader orcFileReader = getReader ( f ) ; StructObjectInspector insp = ( StructObjectInspector ) orcFileReader . getObjectInspector ( ) ; OrcParser . OrcParseSetup stp = OrcParser . deriveParseSetup ( orcFileReader , insp ) ; // change back the columnNames and columnTypes if they are specified already if ( ! ( columnNames == null ) && ( stp . getAllColNames ( ) . length == columnNames . length ) ) { // copy column name stp . setColumnNames ( columnNames ) ; stp . setAllColNames ( columnNames ) ; } if ( columnTypes != null ) { // copy enum type only byte [ ] old_columnTypes = stp . getColumnTypes ( ) ; String [ ] old_columnTypeNames = stp . getColumnTypesString ( ) ; for ( int index = 0 ; index < columnTypes . length ; index ++ ) { if ( columnTypes [ index ] != old_columnTypes [ index ] ) { if ( supported_type_conversions [ old_columnTypes [ index ] ] [ columnTypes [ index ] ] == 1 ) { old_columnTypes [ index ] = columnTypes [ index ] ; } else { stp . addErrs ( new ParseWriter . UnsupportedTypeOverride ( f . _key . toString ( ) , Vec . TYPE_STR [ old_columnTypes [ index ] ] , Vec . TYPE_STR [ columnTypes [ index ] ] , columnNames [ index ] ) ) ; } } if ( columnTypes [ index ] == Vec . T_CAT || columnTypes [ index ] == Vec . T_BAD || columnTypes [ index ] == Vec . T_TIME ) // only copy the enum types old_columnTypes [ index ] = columnTypes [ index ] ; } stp . setColumnTypes ( old_columnTypes ) ; stp . setColumnTypeStrings ( old_columnTypeNames ) ; } List < StripeInformation > stripesInfo = orcFileReader . getStripes ( ) ; if ( stripesInfo . size ( ) == 0 ) { // empty file f . setChunkSize ( stp . _chunk_size = ( int ) f . length ( ) ) ; return stp ; } f . setNChunks ( stripesInfo . size ( ) ) ; stp . _chunk_size = f . _chunkSize ; assert f . nChunks ( ) == stripesInfo . size ( ) ; // ORC parser needs one-to one mapping between chunk and strip (just ids, offsets do not matter) return stp ; } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } }
This method will create the readers and others info needed to parse an orc file . In addition it will not over - ride the columnNames columnTypes that the user may want to force upon it . However we only allow users to set column types to enum at this point and ignore all the other requests .