mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Start using getShardsForQuery SERVER-952
This commit is contained in:
parent
3b37957322
commit
43d5954d08
@ -44,13 +44,12 @@ namespace mongo {
|
||||
|
||||
Query query( q.query );
|
||||
|
||||
vector<shared_ptr<ChunkRange> > shards;
|
||||
info->getChunksForQuery( shards , query.getFilter() );
|
||||
set<Shard> shards;
|
||||
info->getShardsForQuery( shards , query.getFilter() );
|
||||
|
||||
set<ServerAndQuery> servers;
|
||||
for ( vector<shared_ptr<ChunkRange> >::iterator i = shards.begin(); i != shards.end(); i++ ){
|
||||
shared_ptr<ChunkRange> c = *i;
|
||||
servers.insert( ServerAndQuery( c->getShard().getConnString() , BSONObj() ) );
|
||||
for ( set<Shard>::iterator i = shards.begin(); i != shards.end(); i++ ){
|
||||
servers.insert( ServerAndQuery( i->getConnString() , BSONObj() ) );
|
||||
}
|
||||
|
||||
if ( logLevel > 4 ){
|
||||
@ -204,15 +203,10 @@ namespace mongo {
|
||||
}
|
||||
|
||||
if ( multi ){
|
||||
vector<shared_ptr<ChunkRange> > chunks;
|
||||
manager->getChunksForQuery( chunks , chunkFinder );
|
||||
set<Shard> seen;
|
||||
for ( vector<shared_ptr<ChunkRange> >::iterator i=chunks.begin(); i!=chunks.end(); i++){
|
||||
shared_ptr<ChunkRange> c = *i;
|
||||
if ( seen.count( c->getShard() ) )
|
||||
continue;
|
||||
doWrite( dbUpdate , r , c->getShard() );
|
||||
seen.insert( c->getShard() );
|
||||
set<Shard> shards;
|
||||
manager->getShardsForQuery( shards , chunkFinder );
|
||||
for ( set<Shard>::iterator i=shards.begin(); i!=shards.end(); i++){
|
||||
doWrite( dbUpdate , r , *i );
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -231,24 +225,19 @@ namespace mongo {
|
||||
uassert( 10203 , "bad delete message" , d.moreJSObjs() );
|
||||
BSONObj pattern = d.nextJsObj();
|
||||
|
||||
vector<shared_ptr<ChunkRange> > chunks;
|
||||
manager->getChunksForQuery( chunks , pattern );
|
||||
log(2) << "delete : " << pattern << " \t " << chunks.size() << " justOne: " << justOne << endl;
|
||||
if ( chunks.size() == 1 ){
|
||||
doWrite( dbDelete , r , chunks[0]->getShard() );
|
||||
set<Shard> shards;
|
||||
manager->getShardsForQuery( shards , pattern );
|
||||
log(2) << "delete : " << pattern << " \t " << shards.size() << " justOne: " << justOne << endl;
|
||||
if ( shards.size() == 1 ){
|
||||
doWrite( dbDelete , r , *shards.begin() );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( justOne && ! pattern.hasField( "_id" ) )
|
||||
throw UserException( 8015 , "can only delete with a non-shard key pattern if can delete as many as we find" );
|
||||
|
||||
set<Shard> seen;
|
||||
for ( vector<shared_ptr<ChunkRange> >::iterator i=chunks.begin(); i!=chunks.end(); i++){
|
||||
shared_ptr<ChunkRange> c = *i;
|
||||
if ( seen.count( c->getShard() ) )
|
||||
continue;
|
||||
seen.insert( c->getShard() );
|
||||
doWrite( dbDelete , r , c->getShard() );
|
||||
for ( set<Shard>::iterator i=shards.begin(); i!=shards.end(); i++){
|
||||
doWrite( dbDelete , r , *i );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user