0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Merge branch 'master' of git@github.com:mongodb/mongo

This commit is contained in:
Aaron 2009-02-26 11:35:01 -05:00
commit b2e5b2d024
3 changed files with 21 additions and 10 deletions

View File

@ -23,7 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dbtests", "dbtests", "{C72E
..\dbtests\matchertests.cpp = ..\dbtests\matchertests.cpp
..\dbtests\pairingtests.cpp = ..\dbtests\pairingtests.cpp
..\dbtests\pdfiletests.cpp = ..\dbtests\pdfiletests.cpp
..\dbtests\querytests.cpp = ..\dbtests\querytests.cpp
..\dbtests\socktests.cpp = ..\dbtests\socktests.cpp
EndProjectSection
EndProject

View File

@ -27,6 +27,8 @@
*/
namespace mongo {
ShardKeyPattern::ShardKeyPattern( BSONObj fieldsAndOrder ) : _fieldsAndOrder( fieldsAndOrder ){
if ( _fieldsAndOrder.nFields() > 0 ){
@ -143,15 +145,29 @@ namespace mongo {
BSONObj min = k.globalMin();
BSONObj max = k.globalMax();
log(3) << "globalMin: " << min << endl;
log(3) << "globalMax: " << max << endl;
BSONObj k1 = BSON( "key" << 5 );
assert( k.compare( min , max ) < 0 );
assert( k.compare( min , k1 ) < 0 );
assert( k.compare( max , min ) > 0 );
assert( k.compare( min , min ) == 0 );
assert( k.hasShardKey( BSON( "key" << 1 ) ) );
assert( k.hasShardKey( k1 ) );
assert( ! k.hasShardKey( BSON( "key2" << 1 ) ) );
BSONObj a = k1;
BSONObj b = BSON( "key" << 999 );
assert( k.compare(a,b) < 0 );
assert( k.compare(a,k.middle(a,a)) == 0 );
assert( k.compare(a,k.middle(a,b)) <= 0 );
assert( k.compare(k.middle(a,b),b) <= 0 );
assert( k.canOrder( fromjson("{key:1}") ) == 1 );
assert( k.canOrder( fromjson("{zz:1}") ) == 0 );
assert( k.canOrder( fromjson("{key:-1}") ) == -1 );
}
} shardKeyTest;

View File

@ -24,10 +24,6 @@ namespace mongo {
class Shard;
/**
NOTE: the implementation for this is temporary.
it only currently works for a single numeric field
*/
/* A ShardKeyPattern is a pattern indicating what data to extract from the object to make the shard key from.
Analogous to an index key pattern.
*/
@ -63,7 +59,7 @@ namespace mongo {
int compare( const BSONObj& l , const BSONObj& r ) const;
/**
* @return whether or not obj has all fields in this shard key
* @return whether or not obj has all fields in this shard key pattern
*/
bool hasShardKey( const BSONObj& obj );