mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
ChunkMatcher compound key support SERVER-951
This commit is contained in:
parent
38c27222e7
commit
72bab0e0d2
@ -30,9 +30,6 @@ namespace mongo {
|
||||
|
||||
// -----------
|
||||
|
||||
/**
|
||||
* TODO: this only works with single fields at the moment
|
||||
*/
|
||||
class ChunkMatcher {
|
||||
typedef map<BSONObj,pair<BSONObj,BSONObj>,BSONObjCmp> MyMap;
|
||||
public:
|
||||
@ -45,7 +42,7 @@ namespace mongo {
|
||||
void gotRange( const BSONObj& min , const BSONObj& max );
|
||||
|
||||
ConfigVersion _version;
|
||||
string _field;
|
||||
BSONObj _key;
|
||||
MyMap _map;
|
||||
|
||||
friend class ShardingState;
|
||||
|
@ -541,8 +541,20 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void ChunkMatcher::gotRange( const BSONObj& min , const BSONObj& max ){
|
||||
assert( min.nFields() == 1 );
|
||||
_field = min.firstElement().fieldName();
|
||||
if (_key.isEmpty()){
|
||||
BSONObjBuilder b;
|
||||
|
||||
BSONForEach(e, min) {
|
||||
b.append(e.fieldName(), 1);
|
||||
}
|
||||
|
||||
_key = b.obj();
|
||||
}
|
||||
|
||||
//TODO debug mode only?
|
||||
assert(min.nFields() == _key.nFields());
|
||||
assert(max.nFields() == _key.nFields());
|
||||
|
||||
_map[min] = make_pair(min,max);
|
||||
}
|
||||
|
||||
@ -550,7 +562,7 @@ namespace mongo {
|
||||
if ( _map.size() == 0 )
|
||||
return false;
|
||||
|
||||
BSONObj x = loc.obj().getFieldDotted( _field.c_str() ).wrap( _field.c_str() ); // TODO: this is slow
|
||||
BSONObj x = loc.obj().extractFieldsDotted(_key);
|
||||
|
||||
MyMap::const_iterator a = _map.upper_bound( x );
|
||||
a--;
|
||||
|
Loading…
Reference in New Issue
Block a user