private RecordList loadData ( AbstractDataTable table , DataSchema schema ) { RecordListBuilder recordListBuilder = new RecordListBuilder ( RecordListBuilder . CompressionMode . CANONICAL , schema ) ; // simple check to ensure schema and table definitions are aligned if ( schema . size ( ) != table . getNumberOfColumns ( ) ) { final IllegalArgumentException illegalArgumentException = new IllegalArgumentException ( "schema row definition do not match table supplied" ) ; logger . log ( SEVERE , "Warning:" , illegalArgumentException ) ; } int columnLength = table . getNumberOfColumns ( ) ; // for each row for ( int rowIndex = 0 ; rowIndex < table . getNumberOfRows ( ) ; rowIndex ++ ) { //for each column String [ ] fields = new String [ columnLength ] ; for ( int columnIndex = 0 ; columnIndex < columnLength ; columnIndex ++ ) { if ( table . getColumnType ( columnIndex ) == AbstractDataTable . ColumnType . DATE ) { Date valueDate = table . getValueDate ( rowIndex , columnIndex ) ; if ( valueDate == null ) { continue ; } String dateFormatted = DateTimeFormat . getFormat ( DateTimeFormat . PredefinedFormat . ISO_8601 ) . format ( valueDate ) ; fields [ columnIndex ] = dateFormatted ; } else { fields [ columnIndex ] = table . getFormattedValue ( rowIndex , columnIndex ) ; } } recordListBuilder . addRecord ( ( fields ) ) ; } String dataSourceHash = "" ; return recordListBuilder . createRecordList ( dataSourceHash ) ; }
Given a schema attempts to load table into internal structure