private int [ ] alignCategoricals ( String [ ] longerDomain , String [ ] shorterDomain ) { String [ ] sortedLongerDomain = Arrays . copyOf ( longerDomain , longerDomain . length ) ; //Sort to make sure binary search is possible Arrays . sort ( sortedLongerDomain ) ; int [ ] transformedIndices = MemoryManager . malloc4 ( shorterDomain . length ) ; for ( int i = 0 ; i < shorterDomain . length ; i ++ ) { transformedIndices [ i ] = Arrays . binarySearch ( sortedLongerDomain , shorterDomain [ i ] ) ; } return transformedIndices ; }
Produces a mapping array with indexes of the smaller pointing to the larger domain .