mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
get rid of final mongos query filter SERVER-1245
This commit is contained in:
parent
14344eeea3
commit
3fe48e37f1
31
jstests/sharding/sort1.js
Normal file
31
jstests/sharding/sort1.js
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
s = new ShardingTest( "sort1" , 2 , 0 , 2 )
|
||||
|
||||
s.adminCommand( { enablesharding : "test" } );
|
||||
s.adminCommand( { shardcollection : "test.data" , key : { num : 1 } } );
|
||||
|
||||
db = s.getDB( "test" );
|
||||
|
||||
for ( i=0; i<100; i++ ){
|
||||
db.data.insert( { _id : i , num : i } );
|
||||
}
|
||||
db.getLastError();
|
||||
|
||||
s.adminCommand( { split : "test.data" , middle : { num : 33 } } )
|
||||
s.adminCommand( { split : "test.data" , middle : { num : 66 } } )
|
||||
|
||||
s.adminCommand( { movechunk : "test.data" , find : { num : 50 } , to : s.getOther( s.getServer( "test" ) ).name } );
|
||||
|
||||
assert.eq( 3 , s.config.chunks.find().itcount() , "A1" );
|
||||
|
||||
temp = s.config.chunks.find().sort( { min : 1 } ).toArray();
|
||||
assert.eq( temp[0].shard , temp[2].shard , "A2" );
|
||||
assert.neq( temp[0].shard , temp[1].shard , "A3" );
|
||||
|
||||
temp = db.data.find().sort( { num : 1 } ).toArray();
|
||||
assert.eq( 100 , temp.length , "B1" );
|
||||
for ( i=0; i<100; i++ ){
|
||||
assert.eq( i , temp[i].num , "B2" )
|
||||
}
|
||||
|
||||
s.stop();
|
@ -51,7 +51,6 @@ namespace mongo {
|
||||
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() ) );
|
||||
//servers.insert( ServerAndQuery( c->getShard().getConnString() , c->getFilter() ) ); // this is what does mongod size filtering, TODO: clean up apis
|
||||
}
|
||||
|
||||
if ( logLevel > 4 ){
|
||||
@ -69,24 +68,10 @@ namespace mongo {
|
||||
BSONObj sort = query.getSort();
|
||||
|
||||
if ( sort.isEmpty() ){
|
||||
// 1. no sort, can just hit them in serial
|
||||
cursor = new SerialServerClusteredCursor( servers , q );
|
||||
}
|
||||
else {
|
||||
int shardKeyOrder = info->getShardKey().canOrder( sort );
|
||||
if ( shardKeyOrder ){
|
||||
// 2. sort on shard key, can do in serial intelligently
|
||||
set<ServerAndQuery> buckets;
|
||||
for ( vector<shared_ptr<ChunkRange> >::iterator i = shards.begin(); i != shards.end(); i++ ){
|
||||
shared_ptr<ChunkRange> s = *i;
|
||||
buckets.insert( ServerAndQuery( s->getShard().getConnString() , s->getFilter() , s->getMin() ) );
|
||||
}
|
||||
cursor = new SerialServerClusteredCursor( buckets , q , shardKeyOrder );
|
||||
}
|
||||
else {
|
||||
// 3. sort on non-sharded key, pull back a portion from each server and iterate slowly
|
||||
cursor = new ParallelSortClusteredCursor( servers , q , sort );
|
||||
}
|
||||
cursor = new ParallelSortClusteredCursor( servers , q , sort );
|
||||
}
|
||||
|
||||
assert( cursor );
|
||||
|
Loading…
Reference in New Issue
Block a user