Skip to content

Commit

Permalink
fix last commit breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Jun 27, 2011
1 parent 619650a commit 45032b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions db/btree.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ namespace mongo {
* does not bother returning that value. * does not bother returning that value.
*/ */
template< class V > template< class V >
void BucketBasics<V>::popBack(DiskLoc& recLoc, const Key *&key) { void BucketBasics<V>::popBack(DiskLoc& recLoc, Key &key) {
massert( 10282 , "n==0 in btree popBack()", this->n > 0 ); massert( 10282 , "n==0 in btree popBack()", this->n > 0 );
assert( k(this->n-1).isUsed() ); // no unused skipping in this function at this point - btreebuilder doesn't require that assert( k(this->n-1).isUsed() ); // no unused skipping in this function at this point - btreebuilder doesn't require that
KeyNode kn = keyNode(this->n-1); KeyNode kn = keyNode(this->n-1);
recLoc = kn.recordLoc; recLoc = kn.recordLoc;
key = &kn.key; key.assign(kn.key);
int keysize = kn.key.dataSize(); int keysize = kn.key.dataSize();


massert( 10283 , "rchild not null in btree popBack()", this->nextChild.isNull()); massert( 10283 , "rchild not null in btree popBack()", this->nextChild.isNull());
Expand Down
2 changes: 1 addition & 1 deletion db/btree.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ namespace mongo {
* - The last key of the bucket is removed, and its key and recLoc are * - The last key of the bucket is removed, and its key and recLoc are
* returned. As mentioned above, the key points to unallocated memory. * returned. As mentioned above, the key points to unallocated memory.
*/ */
void popBack(DiskLoc& recLoc, const Key *&key); void popBack(DiskLoc& recLoc, Key &key);


/** /**
* Preconditions: * Preconditions:
Expand Down
6 changes: 3 additions & 3 deletions db/btreebuilder.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ namespace mongo {
} }


BtreeBucket<V> *x = xloc.btreemod<V>(); BtreeBucket<V> *x = xloc.btreemod<V>();
const Key *k; Key k;
DiskLoc r; DiskLoc r;
x->popBack(r,k); x->popBack(r,k);
bool keepX = ( x->n != 0 ); bool keepX = ( x->n != 0 );
DiskLoc keepLoc = keepX ? xloc : x->nextChild; DiskLoc keepLoc = keepX ? xloc : x->nextChild;


if ( ! up->_pushBack(r, *k, ordering, keepLoc) ) { if ( ! up->_pushBack(r, k, ordering, keepLoc) ) {
// current bucket full // current bucket full
DiskLoc n = BtreeBucket<V>::addBucket(idx); DiskLoc n = BtreeBucket<V>::addBucket(idx);
up->setTempNext(n); up->setTempNext(n);
upLoc = n; upLoc = n;
up = upLoc.btreemod<V>(); up = upLoc.btreemod<V>();
up->pushBack(r, *k, ordering, keepLoc); up->pushBack(r, k, ordering, keepLoc);
} }


DiskLoc nextLoc = x->tempNext(); // get next in chain at current level DiskLoc nextLoc = x->tempNext(); // get next in chain at current level
Expand Down
8 changes: 7 additions & 1 deletion db/key.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace mongo {
KeyV1 is the new implementation. KeyV1 is the new implementation.
*/ */
class KeyBson { class KeyBson /* "KeyV0" */ {
public: public:
KeyBson() { } KeyBson() { }
explicit KeyBson(const char *keyData) : _o(keyData) { } explicit KeyBson(const char *keyData) : _o(keyData) { }
Expand All @@ -41,6 +41,7 @@ namespace mongo {
BSONElement _firstElement() const { return _o.firstElement(); } BSONElement _firstElement() const { return _o.firstElement(); }
bool isCompactFormat() const { return false; } bool isCompactFormat() const { return false; }
bool woEqual(const KeyBson& r) const; bool woEqual(const KeyBson& r) const;
void assign(const KeyBson& rhs) { *this = rhs; }
private: private:
BSONObj _o; BSONObj _o;
}; };
Expand All @@ -59,6 +60,11 @@ namespace mongo {
dassert( _keyData > (const unsigned char *) 1 ); dassert( _keyData > (const unsigned char *) 1 );
} }


// explicit version of operator= to be safe
void assign(const KeyV1& rhs) {
_keyData = rhs._keyData;
}

/** @param keyData can be a buffer containing data in either BSON format, OR in KeyV1 format. /** @param keyData can be a buffer containing data in either BSON format, OR in KeyV1 format.
when BSON, we are just a wrapper when BSON, we are just a wrapper
*/ */
Expand Down

0 comments on commit 45032b5

Please sign in to comment.