Exemplo n.º 1
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 ;
   }