Пример #1
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB_RTNCOINS_SHARDANOBJ, "rtnCoordInsert::shardAnObj" )
   INT32 rtnCoordInsert::shardAnObj( CHAR *pInsertor,
                                     const CoordCataInfoPtr &cataInfo,
                                     GroupObjsMap &groupObjsMap )
   {
      INT32 rc = SDB_OK;
      PD_TRACE_ENTRY ( SDB_RTNCOINS_SHARDANOBJ ) ;
      try
      {
         BSONObj insertObj( pInsertor );
         UINT32 groupID = 0;
         rc = cataInfo->getGroupByRecord( insertObj, groupID );
         PD_RC_CHECK( rc, PDERROR, "Failed to get the group(rc=%d)", rc );

         groupObjsMap[ groupID ].push_back( pInsertor ) ;
      }
      catch ( std::exception &e )
      {
         PD_CHECK( FALSE, SDB_INVALIDARG, error, PDERROR,
                   "Failed to shard the data, received unexpected error:%s",
                   e.what() );
      }

   done:
      PD_TRACE_EXITRC ( SDB_RTNCOINS_SHARDANOBJ, rc ) ;
      return rc;
   error:
      goto done;
   }
Пример #2
0
   INT32 rtnCoordInsert::shardAnObj( CHAR *pInsertor,
                                     const CoordCataInfoPtr &cataInfo,
                                     pmdEDUCB * cb,
                                     GroupSubCLMap &groupSubCLMap )
   {
      INT32 rc = SDB_OK;
      std::string subCLName ;
      UINT32 groupID = CAT_INVALID_GROUPID;

      try
      {
         BSONObj insertObj( pInsertor ) ;
         CoordCataInfoPtr subClCataInfo;
         rc = cataInfo->getSubCLNameByRecord( insertObj, subCLName ) ;
         PD_CHECK( SDB_OK == rc, SDB_CLS_COORD_NODE_CAT_VER_OLD, error,
                  PDWARNING, "couldn't find the match sub-collection(rc=%d)",
                  rc ) ;
         rc = rtnCoordGetCataInfo( cb, subCLName.c_str(), FALSE,
                                   subClCataInfo );
         PD_CHECK( SDB_OK == rc, SDB_CLS_COORD_NODE_CAT_VER_OLD, error,
                  PDWARNING, "failed to get catalog of sub-collection(%s)",
                  subCLName.c_str() );
         rc = subClCataInfo->getGroupByRecord( insertObj, groupID );
         PD_CHECK( SDB_OK == rc, SDB_CLS_COORD_NODE_CAT_VER_OLD, error,
                  PDWARNING, "couldn't find the match catalog of "
                  "sub-collection(%s)", subCLName.c_str() );
         (groupSubCLMap[ groupID ])[ subCLName ].push_back( pInsertor );
      }
      catch ( std::exception &e )
      {
         PD_CHECK( FALSE, SDB_INVALIDARG, error, PDERROR,
                   "Failed to shard the data, occur unexpected error:%s",
                   e.what() );
      }

   done:
      return rc ;
   error:
      goto done ;
   }