Permalink
Browse files

bigger KeyMax index maximum key size for btree v1 indexes. (3kb)

  • Loading branch information...
1 parent 3f169b9 commit a7ca16a65141da6cef00313b984c694fc65e8fc3 @dwight dwight committed Jul 1, 2011
Showing with 33 additions and 16 deletions.
  1. +4 −4 db/btree.cpp
  2. +5 −3 db/btree.h
  3. +1 −2 db/btreebuilder.cpp
  4. +23 −7 jstests/index11.js
View
@@ -1217,7 +1217,7 @@ namespace mongo {
const Ordering ord = Ordering::make(id.keyPattern());
DiskLoc loc = locate(id, thisLoc, key, ord, pos, found, recordLoc, 1);
if ( found ) {
- if ( key.objsize() > KeyMax ) {
+ if ( key.objsize() > this->KeyMax ) {
OCCASIONALLY problem() << "unindex: key too large to index but was found for " << id.indexNamespace() << " reIndex suggested" << endl;
}
loc.btreemod<V>()->delKeyAtPos(loc, id, pos, ord);
@@ -1677,8 +1677,8 @@ namespace mongo {
int BtreeBucket<V>::_insert(const DiskLoc thisLoc, const DiskLoc recordLoc,
const Key& key, const Ordering &order, bool dupsAllowed,
const DiskLoc lChild, const DiskLoc rChild, IndexDetails& idx) const {
- if ( key.dataSize() > KeyMax ) {
- problem() << "ERROR: key too large len:" << key.dataSize() << " max:" << KeyMax << ' ' << key.dataSize() << ' ' << idx.indexNamespace() << endl;
+ if ( key.dataSize() > this->KeyMax ) {
+ problem() << "ERROR: key too large len:" << key.dataSize() << " max:" << this->KeyMax << ' ' << key.dataSize() << ' ' << idx.indexNamespace() << endl;
return 2;
}
assert( key.dataSize() > 0 );
@@ -1754,7 +1754,7 @@ namespace mongo {
KeyOwned key(_key);
if ( toplevel ) {
- if ( key.dataSize() > KeyMax ) {
+ if ( key.dataSize() > this->KeyMax ) {
problem() << "Btree::insert: key too large to index, skipping " << idx.indexNamespace() << ' ' << key.dataSize() << ' ' << key.toString() << endl;
return 3;
}
View
@@ -65,9 +65,6 @@ namespace mongo {
const int OldBucketSize = 8192;
- // largest key size we allow. note we very much need to support bigger keys (somehow) in the future.
- const int KeyMax = OldBucketSize / 10;
-
#pragma pack(1)
template< class Version > class BucketBasics;
@@ -180,6 +177,9 @@ namespace mongo {
typedef KeyBson Key;
typedef KeyBson KeyOwned;
enum { BucketSize = 8192 };
+
+ // largest key size we allow. note we very much need to support bigger keys (somehow) in the future.
+ static const int KeyMax = OldBucketSize / 10;
};
// a a a ofs ofs ofs ofs
@@ -260,6 +260,8 @@ namespace mongo {
typedef KeyV1 Key;
typedef KeyV1Owned KeyOwned;
enum { BucketSize = 8192-16 }; // leave room for Record header
+ // largest key size we allow. note we very much need to support bigger keys (somehow) in the future.
+ static const int KeyMax = 3*1024;
protected:
/** Parent bucket of this bucket, which isNull() for the root bucket. */
Loc parent;
View
@@ -63,8 +63,7 @@ namespace mongo {
template<class V>
void BtreeBuilder<V>::addKey(BSONObj& _key, DiskLoc loc) {
auto_ptr< KeyOwned > key( new KeyOwned(_key) );
-
- if ( key->dataSize() > KeyMax ) {
+ if ( key->dataSize() > BtreeBucket<V>::KeyMax ) {
problem() << "Btree::insert: key too large to index, skipping " << idx.indexNamespace()
<< ' ' << key->dataSize() << ' ' << key->toString() << endl;
return;
View
@@ -1,13 +1,29 @@
// Reindex w/ field too large to index
coll = db.jstests_index11;
-coll.drop();
+coll.drop();
+
+var str = "xxxxxxxxxxxxxxxx";
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + str;
+str = str + 'q';
+
+coll.insert({ k: 'a', v: str });
+
+assert.eq(0, coll.find({ "k": "x" }).count(), "expected zero keys 1");
-coll.ensureIndex({"k": 1, "v": 1});
-coll.insert({k: "x", v: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"});
-assert.eq(0, coll.find({"k": "x"}).count()); // SERVER-1716
+coll.ensureIndex({"k": 1, "v": 1});
+coll.insert({ k: "x", v: str });
-coll.dropIndexes();
-coll.ensureIndex({"k": 1, "v": 1});
+assert.eq(0, coll.find({"k": "x"}).count(), "B"); // SERVER-1716
-assert.eq(0, coll.find({"k": "x"}).count());
+coll.dropIndexes();
+coll.ensureIndex({"k": 1, "v": 1});
+
+assert.eq(0, coll.find({ "k": "x" }).count(), "expected zero keys 2");

0 comments on commit a7ca16a

Please sign in to comment.