public static Schema infer ( List < Writable > record ) { Schema . Builder builder = new Schema . Builder ( ) ; for ( int i = 0 ; i < record . size ( ) ; i ++ ) { if ( record . get ( i ) instanceof DoubleWritable ) builder . addColumnDouble ( String . valueOf ( i ) ) ; else if ( record . get ( i ) instanceof IntWritable ) builder . addColumnInteger ( String . valueOf ( i ) ) ; else if ( record . get ( i ) instanceof LongWritable ) builder . addColumnLong ( String . valueOf ( i ) ) ; else if ( record . get ( i ) instanceof FloatWritable ) builder . addColumnFloat ( String . valueOf ( i ) ) ; else if ( record . get ( i ) instanceof Text ) { builder . addColumnString ( String . valueOf ( i ) ) ; } else throw new IllegalStateException ( "Illegal writable for infering schema of type " + record . get ( i ) . getClass ( ) . toString ( ) + " with record " + record ) ; } return builder . build ( ) ; }
Infers a schema based on the record . The column names are based on indexing .