INT32 _qgmOptiNLJoin::handleHints( QGM_HINS &hints ) { PD_TRACE_ENTRY( SDB__QGMOPTINLJOIN_HANDLEHINTS ) ; INT32 rc = SDB_OK ; if ( SQL_GRAMMAR::INNERJOIN != _joinType) { goto done ; } { QGM_HINS::iterator itr = hints.begin() ; for ( ; itr != hints.end(); itr++ ) { if ( 0 == ossStrncmp( itr->value.begin(), QGM_HINT_HASHJOIN, itr->value.size() )) { if ( NULL != _condition && SQL_GRAMMAR::EG == _condition->type ) { SDB_ASSERT( NULL != _condition->left && NULL != _condition->right, "impossible") ; if ( SQL_GRAMMAR::DBATTR == _condition->left->type && SQL_GRAMMAR::DBATTR == _condition->right->type ) { qgmHint hint = *itr ; _hints.push_back( hint ) ; } } } } } done: PD_TRACE_EXITRC( SDB__QGMOPTINLJOIN_HANDLEHINTS, rc ) ; return rc ; }
string qgmHintToString( const QGM_HINS &hint ) { stringstream ss ; QGM_HINS::const_iterator i = hint.begin() ; for ( ; i != hint.end(); ++i ) { ss << i->value.toString() << "(" ; vector<qgmOpField>::const_iterator j = i->param.begin() ; for ( ; j != i->param.end(); ++j ) { ss << j->value.toString() << "," ; } ss << ") " ; } return ss.str() ; }
INT32 _qgmOptiNLJoin::_handleHints( _qgmOptiTreeNode *sub, const QGM_HINS &hint ) { INT32 rc = SDB_OK ; QGM_HINS copy ; const qgmField &alias = sub->getAlias() ; QGM_HINS::const_iterator itr = hint.begin() ; for ( ; itr != hint.end(); itr++ ) { if ( 0 == ossStrncmp( itr->value.begin(), QGM_HINT_USEINDEX, itr->value.size() ) && 2 == itr->param.size() ) { const qgmField &tName = itr->param.begin()->value.attr() ; if ( alias == tName ) { copy.push_back( *itr ) ; break ; } } } if ( copy.empty() ) { goto done ; } rc = sub->handleHints( copy ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to handle hint in sub node:%d", rc ) ; goto error ; } done: return rc ; error: goto done ; }
INT32 _qgmOptiNLJoin::handleHints( QGM_HINS &hints ) { PD_TRACE_ENTRY( SDB__QGMOPTINLJOIN_HANDLEHINTS ) ; INT32 rc = SDB_OK ; if ( SQL_GRAMMAR::INNERJOIN != _joinType) { goto done ; } { QGM_HINS::iterator itr = hints.begin() ; for ( ; itr != hints.end(); itr++ ) { if ( 0 == ossStrncmp( itr->value.begin(), QGM_HINT_HASHJOIN, itr->value.size() )) { if ( NULL != _condition && SQL_GRAMMAR::EG == _condition->type ) { SDB_ASSERT( NULL != _condition->left && NULL != _condition->right, "impossible") ; if ( SQL_GRAMMAR::DBATTR == _condition->left->type && SQL_GRAMMAR::DBATTR == _condition->right->type ) { qgmHint hint = *itr ; _hints.push_back( hint ) ; } } } } } if ( 2 != _children.size() ) { goto done ; } if ( QGM_OPTI_TYPE_SCAN == _children[0]->getType() ) { rc = _handleHints( _children[0], hints ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "sub node failed to handle hint:%d", rc ) ; goto error ; } } if ( QGM_OPTI_TYPE_SCAN == _children[1]->getType() ) { rc = _handleHints( _children[1], hints ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "sub node failed to handle hint:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB__QGMOPTINLJOIN_HANDLEHINTS, rc ) ; return rc ; error: goto done ; }