summaryrefslogtreecommitdiff
path: root/src/mongo/s/shardkey.cpp
diff options
context:
space:
mode:
authorKevin Matulef <matulef@gmail.com>2012-09-25 02:00:26 -0400
committerKevin Matulef <matulef@gmail.com>2012-09-25 02:00:26 -0400
commitc470ef7c9c3df63ecf4b06b416292fe0102fe9f2 (patch)
tree862e5f040879cdf5b8863a09e4650e252eadfe33 /src/mongo/s/shardkey.cpp
parent924d00cee993434dd139ade27b358fbc8ce44fe2 (diff)
downloadmongo-c470ef7c9c3df63ecf4b06b416292fe0102fe9f2.tar.gz
Separate functions for locating documents vs locating points in the shard-key space
Diffstat (limited to 'src/mongo/s/shardkey.cpp')
-rw-r--r--src/mongo/s/shardkey.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/mongo/s/shardkey.cpp b/src/mongo/s/shardkey.cpp
index 8b768c0e8dd..d7521c91510 100644
--- a/src/mongo/s/shardkey.cpp
+++ b/src/mongo/s/shardkey.cpp
@@ -42,16 +42,6 @@ namespace mongo {
gMax = max.obj();
}
- int ShardKeyPattern::compare( const BSONObj& lObject , const BSONObj& rObject ) const {
- BSONObj L = extractKey(lObject);
- uassert( 10198 , str::stream() << "left object (" << lObject << ") doesn't have full shard key (" << pattern << ')',
- L.nFields() == (int)patternfields.size());
- BSONObj R = extractKey(rObject);
- uassert( 10199 , str::stream() << "right object (" << rObject << ") doesn't have full shard key (" << pattern << ')',
- R.nFields() == (int)patternfields.size());
- return L.woCompare(R);
- }
-
bool ShardKeyPattern::hasShardKey( const BSONObj& obj ) const {
/* this is written s.t. if obj has lots of fields, if the shard key fields are early,
it is fast. so a bit more work to try to be semi-fast.
@@ -229,10 +219,9 @@ namespace mongo {
BSONObj k1 = BSON( "key" << 5 );
- verify( k.compare( min , max ) < 0 );
- verify( k.compare( min , k1 ) < 0 );
- verify( k.compare( max , min ) > 0 );
- verify( k.compare( min , min ) == 0 );
+ verify( min < max );
+ verify( min < k.extractKey( k1 ) );
+ verify( max > min );
hasshardkeytest();
verify( k.hasShardKey( k1 ) );
@@ -241,7 +230,7 @@ namespace mongo {
BSONObj a = k1;
BSONObj b = BSON( "key" << 999 );
- verify( k.compare(a,b) < 0 );
+ verify( k.extractKey( a ) < k.extractKey( b ) );
// add middle multitype tests