diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-09-23 18:07:45 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-09-23 18:07:45 -0400 |
commit | 7f8ea97135b4d7c462cef9ccf3e6475794a9f2a2 (patch) | |
tree | 12d34eaa030073d6e498bf5144b06e17c19cbb43 | |
parent | 8d77298f6126f950492dffb996c5c25c53a7dd76 (diff) | |
download | mongo-7f8ea97135b4d7c462cef9ccf3e6475794a9f2a2.tar.gz |
some more IndexPlugin cleaning
-rw-r--r-- | db/indexkey.cpp | 4 | ||||
-rw-r--r-- | db/indexkey.h | 29 |
2 files changed, 21 insertions, 12 deletions
diff --git a/db/indexkey.cpp b/db/indexkey.cpp index ba8995f7aef..0137478bd50 100644 --- a/db/indexkey.cpp +++ b/db/indexkey.cpp @@ -46,7 +46,7 @@ namespace mongo { (*_plugins)[name] = this; } - string IndexPlugin::getPluginName( const BSONObj& keyPattern ){ + string IndexPlugin::findPluginName( const BSONObj& keyPattern ){ string pluginName = ""; BSONObjIterator i( keyPattern ); @@ -70,7 +70,7 @@ namespace mongo { void IndexSpec::_init(){ assert( keyPattern.objsize() ); - string pluginName = IndexPlugin::getPluginName( keyPattern ); + string pluginName = IndexPlugin::findPluginName( keyPattern ); BSONObjBuilder nullKeyB; BSONObjIterator i( keyPattern ); diff --git a/db/indexkey.h b/db/indexkey.h index d87f10ed5d8..96198755cea 100644 --- a/db/indexkey.h +++ b/db/indexkey.h @@ -79,6 +79,23 @@ namespace mongo { virtual ~IndexPlugin(){} virtual IndexType* generate( const IndexSpec * spec ) const = 0; + + string getName() const { return _name; } + + /** + * override this if an index format changes + * then logic in IndexType can change based on version # + * @return the current version for new indexes + */ + virtual int getCurrentVersion() const { return 0; } + + /** + * @return new keyPattern + * if nothing changes, should return keyPattern + */ + virtual BSONObj adjustKeyPattern( const BSONObj& keyPattern ) const { return keyPattern; } + + // ------- static below ------- static IndexPlugin* get( const string& name ){ if ( ! _plugins ) @@ -93,21 +110,13 @@ namespace mongo { * @param keyPattern { x : "fts" } * @return "" or the name */ - static string getPluginName( const BSONObj& keyPattern ); - - string getName() const { return _name; } + static string findPluginName( const BSONObj& keyPattern ); - /** - * override this if an index format changes - * then logic in IndexType can change based on version # - * @return the current version for new indexes - */ - virtual int getCurrentVersion() const { return 0; } private: string _name; static map<string,IndexPlugin*> * _plugins; }; - + /* precomputed details about an index, used for inserting keys on updates stored/cached in NamespaceDetailsTransient, or can be used standalone */ |