Index getIndexForColumns ( OrderedIntHashSet set ) { int maxMatchCount = 0 ; Index selected = null ; if ( set . isEmpty ( ) ) { return null ; } for ( int i = 0 , count = indexList . length ; i < count ; i ++ ) { Index currentindex = getIndex ( i ) ; int [ ] indexcols = currentindex . getColumns ( ) ; int matchCount = set . getOrderedMatchCount ( indexcols ) ; if ( matchCount == 0 ) { continue ; } if ( matchCount == indexcols . length ) { return currentindex ; } if ( matchCount > maxMatchCount ) { maxMatchCount = matchCount ; selected = currentindex ; } } if ( selected != null ) { return selected ; } switch ( tableType ) { case TableBase . SYSTEM_SUBQUERY : case TableBase . SYSTEM_TABLE : case TableBase . VIEW_TABLE : case TableBase . TEMP_TABLE : { selected = createIndexForColumns ( set . toArray ( ) ) ; } } return selected ; }
Finds an existing index for a column set or create one for temporary tables