@ Override public void resolveColumnIndexes ( ) { // First, assert that our topology is sane and then // recursively resolve all child/inline column indexes IndexScanPlanNode index_scan = ( IndexScanPlanNode ) getInlinePlanNode ( PlanNodeType . INDEXSCAN ) ; assert ( m_children . size ( ) == 2 && index_scan == null ) ; for ( AbstractPlanNode child : m_children ) { child . resolveColumnIndexes ( ) ; } final NodeSchema outer_schema = m_children . get ( 0 ) . getOutputSchema ( ) ; final NodeSchema inner_schema = m_children . get ( 1 ) . getOutputSchema ( ) ; final int outerSize = outer_schema . size ( ) ; final int innerSize = inner_schema . size ( ) ; // resolve predicates resolvePredicate ( m_preJoinPredicate , outer_schema , inner_schema ) ; resolvePredicate ( m_joinPredicate , outer_schema , inner_schema ) ; resolvePredicate ( m_wherePredicate , outer_schema , inner_schema ) ; // Resolve subquery expression indexes resolveSubqueryColumnIndexes ( ) ; // Resolve TVE indexes for each schema column. for ( int i = 0 ; i < m_outputSchemaPreInlineAgg . size ( ) ; ++ i ) { SchemaColumn col = m_outputSchemaPreInlineAgg . getColumn ( i ) ; // These will all be TVEs. assert ( col . getExpression ( ) instanceof TupleValueExpression ) ; TupleValueExpression tve = ( TupleValueExpression ) col . getExpression ( ) ; int index ; if ( i < outerSize ) { index = tve . setColumnIndexUsingSchema ( outer_schema ) ; } else { index = tve . setColumnIndexUsingSchema ( inner_schema ) ; index += outerSize ; } if ( index == - 1 ) { throw new RuntimeException ( "Unable to find index for column: " + col . toString ( ) ) ; } tve . setColumnIndex ( index ) ; tve . setDifferentiator ( index ) ; } // We want the output columns to be ordered like [outer table columns][inner table columns], // and further ordered by TVE index within the left- and righthand sides. // generateOutputSchema already places outer columns on the left and inner on the right, // so we just need to order the left- and righthand sides by TVE index separately. m_outputSchemaPreInlineAgg . sortByTveIndex ( 0 , outer_schema . size ( ) ) ; m_outputSchemaPreInlineAgg . sortByTveIndex ( outer_schema . size ( ) , m_outputSchemaPreInlineAgg . size ( ) ) ; m_hasSignificantOutputSchema = true ; resolveRealOutputSchema ( ) ; }
order and TVE indexes for the output SchemaColumns .