Ejemplo n.º 1
0
 qgmPlMthMatcherScan::qgmPlMthMatcherScan( const qgmDbAttr &collection,
                                           const qgmOPFieldVec &selector,
                                           const bson::BSONObj &orderby,
                                           const bson::BSONObj &hint,
                                           INT64 numSkip,
                                           INT64 numReturn,
                                           const qgmField &alias,
                                           const bson::BSONObj &matcher )
 : _qgmPlScan( collection, selector, orderby, hint, numSkip, numReturn,
             alias, NULL )
 {
    _condition = matcher.copy();
 }
Ejemplo n.º 2
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__MTHSELECTOR_SELECT, "_mthSelector::select" )
   INT32 _mthSelector::select( const bson::BSONObj &source,
                               bson::BSONObj &target )
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY( SDB__MTHSELECTOR_SELECT ) ;
      SDB_ASSERT(_init, "The selector has not been initialized, please "
                         "call 'loadPattern' before using it" ) ;
      BSONObj obj ;
      if ( !_init )
      {
         target = source.copy() ;
         goto done ;
      }

      rc = _matrix.select( source, obj ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to select columns:%d", rc ) ;
         goto error ;
      }

      if ( !_stringOutput )
      {
         target = obj ;
      }
      else
      {
         BSONObj resorted ;
         rc = _resortObj( _matrix.getPattern(),
                          obj,
                          resorted ) ;
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "failed to resort obj:%d", rc ) ;
            goto error ;
         }

         rc = _buildCSV( resorted, target ) ;
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "failed to build csv:%d", rc ) ;
            goto error ;
         }
      }
   done:
      PD_TRACE_EXITRC( SDB__MTHSELECTOR_SELECT, rc ) ;
      return rc ;
   error:
      goto done ;
   }