summaryrefslogtreecommitdiff
path: root/db/index.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-02-15 23:58:08 -0500
committerEliot Horowitz <eliot@10gen.com>2010-02-15 23:58:08 -0500
commita330ad65dd86a1de3f001c8f21540ae58fa23cb0 (patch)
tree30ccdc1c7cef3ff027205721fb93a34bb187d13e /db/index.h
parentcfec75960b02b456ba6a582dec62ff083de31973 (diff)
downloadmongo-a330ad65dd86a1de3f001c8f21540ae58fa23cb0.tar.gz
some thoughts on extending indexing
Diffstat (limited to 'db/index.h')
-rw-r--r--db/index.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/db/index.h b/db/index.h
index 8bd877de4a0..9af4702c64e 100644
--- a/db/index.h
+++ b/db/index.h
@@ -19,9 +19,55 @@
#pragma once
#include "../stdafx.h"
+#include "diskloc.h"
+#include "jsobj.h"
+#include <map>
namespace mongo {
+ class IndexSpec;
+ class IndexType; // TODO: this name sucks
+
+ /**
+ * this represents an instance of a index plugin
+ * done this way so parsing, etc... can be cached
+ * so if there is a FTS IndexPlugin, for each index using FTS
+ * there will be 1 of these, and it can have things pre-parsed, etc...
+ */
+ class IndexType : boost::noncopyable {
+ public:
+ virtual ~IndexType();
+ virtual void getKeys( const BSONObj &obj, BSONObjSetDefaultOrder &keys ) const = 0;
+ virtual int compare( const IndexSpec& spec , const BSONObj& l , const BSONObj& r ) const;
+
+ };
+
+ /**
+ * this represents a plugin
+ * a plugin could be something like full text search, sparse index, etc...
+ * 1 of these exists per type of index per server
+ * 1 IndexType is created per index using this plugin
+ */
+ class IndexPlugin : boost::noncopyable {
+ public:
+ IndexPlugin( const string& name );
+ virtual ~IndexPlugin(){}
+
+ virtual IndexType* generate( const IndexSpec& spec ) const = 0;
+
+ static IndexPlugin* get( const string& name ){
+ if ( ! _plugins )
+ return 0;
+ map<string,IndexPlugin*>::iterator i = _plugins->find( name );
+ if ( i == _plugins->end() )
+ return 0;
+ return i->second;
+ }
+ 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
*/
@@ -68,6 +114,8 @@ namespace mongo {
BSONObj _nullObj;
BSONElement _nullElt;
+ IndexType * _indexType;
+
void _init();
};