protected Relation < ? > [ ] alignColumns ( ObjectBundle pack ) { // align representations. Relation < ? > [ ] targets = new Relation < ? > [ pack . metaLength ( ) ] ; long [ ] used = BitsUtil . zero ( relations . size ( ) ) ; for ( int i = 0 ; i < targets . length ; i ++ ) { SimpleTypeInformation < ? > meta = pack . meta ( i ) ; // TODO: aggressively try to match exact metas first? // Try to match unused representations only for ( int j = BitsUtil . nextClearBit ( used , 0 ) ; j >= 0 && j < relations . size ( ) ; j = BitsUtil . nextClearBit ( used , j + 1 ) ) { Relation < ? > relation = relations . get ( j ) ; if ( relation . getDataTypeInformation ( ) . isAssignableFromType ( meta ) ) { targets [ i ] = relation ; BitsUtil . setI ( used , j ) ; break ; } } if ( targets [ i ] == null ) { targets [ i ] = addNewRelation ( meta ) ; BitsUtil . setI ( used , relations . size ( ) - 1 ) ; } } return targets ; }
Find a mapping from package columns to database columns eventually adding new database columns when needed .