private List < String > diagnoseIndexMismatch ( Index theIndex , Index otherIndex ) { List < String > mismatchedAttrs = new ArrayList <> ( ) ; // Pairs of matching indexes must agree on type (int hash, etc.). if ( theIndex . getType ( ) != otherIndex . getType ( ) ) { mismatchedAttrs . add ( "index type (hash vs tree)" ) ; } // Pairs of matching indexes must agree whether they are (assume)unique. if ( theIndex . getUnique ( ) != otherIndex . getUnique ( ) || theIndex . getAssumeunique ( ) != otherIndex . getAssumeunique ( ) ) { mismatchedAttrs . add ( "UNIQUE attribute" ) ; } // Pairs of matching indexes must agree whether they are partial // and if so, agree on the predicate. String thePredicateJSON = theIndex . getPredicatejson ( ) ; String otherPredicateJSON = otherIndex . getPredicatejson ( ) ; if ( thePredicateJSON == null ) { if ( otherPredicateJSON != null ) { mismatchedAttrs . add ( "WHERE predicate" ) ; } } else if ( ! thePredicateJSON . equals ( otherPredicateJSON ) ) { mismatchedAttrs . add ( "WHERE predicate" ) ; } // Pairs of matching indexes must agree that they do or do not index // expressions and, if so, agree on the expressions. String theExprsJSON = theIndex . getExpressionsjson ( ) ; String otherExprsJSON = otherIndex . getExpressionsjson ( ) ; if ( theExprsJSON == null ) { if ( otherExprsJSON != null ) { mismatchedAttrs . add ( "indexed expression" ) ; } } else if ( ! theExprsJSON . equals ( otherExprsJSON ) ) { mismatchedAttrs . add ( "indexed expression" ) ; } // Indexes must agree on the columns they are based on, // identifiable by the columns' order in the table. CatalogMap < ColumnRef > theColumns = theIndex . getColumns ( ) ; int theColumnCount = theColumns . size ( ) ; CatalogMap < ColumnRef > otherColumns = otherIndex . getColumns ( ) ; if ( theColumnCount != otherColumns . size ( ) ) { mismatchedAttrs . add ( "indexed expression" ) ; } Iterator < ColumnRef > theColumnIterator = theColumns . iterator ( ) ; Iterator < ColumnRef > otherColumnIterator = otherColumns . iterator ( ) ; for ( int ii = 0 ; ii < theColumnCount ; ++ ii ) { int theColIndex = theColumnIterator . next ( ) . getColumn ( ) . getIndex ( ) ; int otherColIndex = otherColumnIterator . next ( ) . getColumn ( ) . getIndex ( ) ; if ( theColIndex != otherColIndex ) { mismatchedAttrs . add ( "indexed expression" ) ; } } return mismatchedAttrs ; }
Give two strings return a list of attributes that do not match