summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2009-11-02 15:37:15 -0500
committerMathias Stearn <mathias@10gen.com>2009-11-04 15:06:36 -0500
commit19863b852e96cfe71e990e8fd3911916e574c8a1 (patch)
tree34ffb0f74e1ea32470062de939c2f81a08398d84
parent6e135afa267fa1b0cf454d50c24f1f1ace79cbe3 (diff)
downloadmongo-19863b852e96cfe71e990e8fd3911916e574c8a1.tar.gz
Chunk dotted support
-rw-r--r--s/chunk.cpp16
-rw-r--r--s/chunk.h17
2 files changed, 25 insertions, 8 deletions
diff --git a/s/chunk.cpp b/s/chunk.cpp
index 4aa02303df6..52dc0dbe6d4 100644
--- a/s/chunk.cpp
+++ b/s/chunk.cpp
@@ -113,15 +113,15 @@ namespace mongo {
Chunk * s = new Chunk( _manager );
s->_ns = _ns;
s->_shard = _shard;
- s->_min = m.getOwned();
- s->_max = _max;
+ s->setMin(m.getOwned());
+ s->setMax(_max);
s->_markModified();
_markModified();
_manager->_chunks.push_back( s );
- _max = m.getOwned();
+ setMax(m.getOwned());
log(1) << " after split:\n"
<< "\t left : " << toString() << "\n"
@@ -310,14 +310,18 @@ namespace mongo {
to << "ns" << _ns;
to << "min" << _min;
+ to << "minDotted" << _minDotted;
to << "max" << _max;
+ to << "maxDotted" << _maxDotted;
to << "shard" << _shard;
}
void Chunk::unserialize(const BSONObj& from){
_ns = from.getStringField( "ns" );
_min = from.getObjectField( "min" ).getOwned();
+ _minDotted = from.getObjectField( "minDotted" ).getOwned();
_max = from.getObjectField( "max" ).getOwned();
+ _maxDotted = from.getObjectField( "maxDotted" ).getOwned();
_shard = from.getStringField( "shard" );
_lastmod = from.hasField( "lastmod" ) ? from["lastmod"].date() : 0;
@@ -366,7 +370,7 @@ namespace mongo {
string Chunk::toString() const {
stringstream ss;
- ss << "shard ns:" << _ns << " shard: " << _shard << " min: " << _min << " max: " << _max;
+ ss << "shard ns:" << _ns << " shard: " << _shard << " min: " << _minDotted << " max: " << _maxDotted;
return ss.str();
}
@@ -397,8 +401,8 @@ namespace mongo {
if ( _chunks.size() == 0 ){
Chunk * c = new Chunk( this );
c->_ns = ns;
- c->_min = _key.globalMin();
- c->_max = _key.globalMax();
+ c->setMin(_key.globalMin());
+ c->setMax(_key.globalMax());
c->_shard = config->getPrimary();
c->_markModified();
diff --git a/s/chunk.h b/s/chunk.h
index 51e0590aaa7..5154c7733ec 100644
--- a/s/chunk.h
+++ b/s/chunk.h
@@ -52,7 +52,18 @@ namespace mongo {
Chunk( ChunkManager * info );
const BSONObj& getMin() const { return _min; }
+ const BSONObj& getMinDotted() const { return _minDotted; }
const BSONObj& getMax() const { return _max; }
+ const BSONObj& getMaxDotted() const { return _maxDotted; }
+
+ void setMin(const BSONObj& o){
+ _min = o;
+ _minDotted = nested2dotted(o);
+ }
+ void setMax(const BSONObj& o){
+ _max = o;
+ _maxDotted = nested2dotted(o);
+ }
string getShard(){
return _shard;
@@ -122,8 +133,10 @@ namespace mongo {
ShardKeyPattern skey();
string _ns;
- BSONObj _min;
- BSONObj _max;
+ BSONObj _min; //nested
+ BSONObj _minDotted;
+ BSONObj _max; //nested
+ BSONObj _maxDotted;
string _shard;
ShardChunkVersion _lastmod;