~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/db/indexkey.h

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    class IndexType; // TODO: this name sucks
35
35
    class IndexPlugin;
36
36
    class IndexDetails;
 
37
    class FieldRangeSet;
37
38
 
38
39
    enum IndexSuitability { USELESS = 0 , HELPFUL = 1 , OPTIMAL = 2 };
39
40
 
49
50
        virtual ~IndexType();
50
51
 
51
52
        virtual void getKeys( const BSONObj &obj, BSONObjSet &keys ) const = 0;
 
53
 
 
54
        /**
 
55
         * Returns the element placed in an index key when indexing a field absent from a document.
 
56
         * By default this is a null BSONElement.
 
57
         */
 
58
        virtual BSONElement missingField() const;
 
59
 
 
60
        /* Full semantics of numWanted:
 
61
         * numWanted == 0 : Return any number of results, but try to return in batches of 101.
 
62
         * numWanted == 1 : Return exactly one result.
 
63
         * numWanted  > 1 : Return any number of results, but try to return in batches of numWanted.
 
64
         *
 
65
         * In practice, your cursor can ignore numWanted, as enforcement of limits is done
 
66
         * by the caller.
 
67
         */
52
68
        virtual shared_ptr<Cursor> newCursor( const BSONObj& query , const BSONObj& order , int numWanted ) const = 0;
53
69
 
54
70
        /** optional op : changes query to match what's in the index */
62
78
 
63
79
        const BSONObj& keyPattern() const;
64
80
 
65
 
        virtual IndexSuitability suitability( const BSONObj& query , const BSONObj& order ) const ;
 
81
        /* Determines the suitability level of this index for answering a given query. The query is
 
82
         * represented as a set of constraints given by a FieldRangeSet, and a desired ordering of
 
83
         * the output.
 
84
         *
 
85
         * Note: it is the responsibility of the caller to pass in the correct FieldRangeSet, which
 
86
         * may depend upon whether this is a single or multi-key index at the time of calling.
 
87
         */
 
88
        virtual IndexSuitability suitability( const FieldRangeSet& queryConstraints ,
 
89
                                              const BSONObj& order ) const;
66
90
 
67
91
        virtual bool scanAndOrderRequired( const BSONObj& query , const BSONObj& order ) const ;
68
92
 
92
116
         */
93
117
        virtual BSONObj adjustIndexSpec( const BSONObj& spec ) const { return spec; }
94
118
 
 
119
        /**
 
120
         * Hook function to run after an index that uses this plugin is built.
 
121
         *
 
122
         * This will be called with an active write context (and lock) on the database.
 
123
         *
 
124
         * @param spec The IndexSpec of the newly built index.
 
125
         */
 
126
        virtual void postBuildHook( const IndexSpec& spec ) const { }
 
127
 
95
128
        // ------- static below -------
96
129
 
97
130
        static IndexPlugin* get( const string& name ) {
109
142
         */
110
143
        static string findPluginName( const BSONObj& keyPattern );
111
144
 
 
145
        /**
 
146
         * True if is a regular (non-plugin) index or uses a plugin that existed before 2.4.
 
147
         * These plugins are grandfathered in and allowed to exist in DBs with
 
148
         * PDFILE_MINOR_VERSION_22_AND_OLDER
 
149
         */
 
150
        static bool existedBefore24(const string& name) {
 
151
            return name.empty()
 
152
                || name == "2d"
 
153
                || name == "geoHaystack"
 
154
                || name == "hashed"
 
155
                ;
 
156
        }
 
157
 
112
158
    private:
113
159
        string _name;
114
160
        static map<string,IndexPlugin*> * _plugins;
119
165
       */
120
166
    class IndexSpec {
121
167
    public:
 
168
        enum PluginRules {
 
169
            NoPlugins,
 
170
            RulesFor22, // if !IndexPlugin::existedBefore24() treat as ascending
 
171
            RulesFor24, // allow new plugins but error if unknown
 
172
        };
 
173
 
122
174
        BSONObj keyPattern; // e.g., { name : 1 }
123
175
        BSONObj info; // this is the same as IndexDetails::info.obj()
124
176
 
126
178
            : _details(0) , _finishedInit(false) {
127
179
        }
128
180
 
129
 
        explicit IndexSpec( const BSONObj& k , const BSONObj& m = BSONObj() )
 
181
        explicit IndexSpec(const BSONObj& k, const BSONObj& m=BSONObj(),
 
182
                           PluginRules rules=RulesFor24)
130
183
            : keyPattern(k) , info(m) , _details(0) , _finishedInit(false) {
131
 
            _init();
 
184
            _init(rules);
132
185
        }
133
186
 
134
187
        /**
135
188
           this is a DiscLoc of an IndexDetails info
136
189
           should have a key field
137
190
         */
138
 
        explicit IndexSpec( const DiskLoc& loc ) {
139
 
            reset( loc );
 
191
        explicit IndexSpec(const DiskLoc& loc, PluginRules rules=RulesFor24) {
 
192
            reset(loc, rules);
140
193
        }
141
194
 
142
 
        void reset( const BSONObj& info );
143
 
        void reset( const DiskLoc& infoLoc ) { reset(infoLoc.obj()); }
144
 
        void reset( const IndexDetails * details );
 
195
        void reset(const BSONObj& info, PluginRules rules=RulesFor24);
 
196
        void reset(const IndexDetails * details); // determines rules based on pdfile version
 
197
        void reset(const DiskLoc& infoLoc, PluginRules rules=RulesFor24) {
 
198
            reset(infoLoc.obj(), rules);
 
199
        }
145
200
 
146
201
        void getKeys( const BSONObj &obj, BSONObjSet &keys ) const;
147
202
 
148
 
        BSONElement missingField() const { return _nullElt; }
 
203
        /**
 
204
         * Returns the element placed in an index key when indexing a field absent from a document.
 
205
         * By default this is a null BSONElement.
 
206
         */
 
207
        BSONElement missingField() const {
 
208
            if ( _indexType.get() )
 
209
                return _indexType->missingField();
 
210
            return _nullElt;
 
211
        }
149
212
 
150
213
        string getTypeName() const {
151
214
            if ( _indexType.get() )
161
224
            return _details;
162
225
        }
163
226
 
164
 
        IndexSuitability suitability( const BSONObj& query , const BSONObj& order ) const ;
 
227
        IndexSuitability suitability( const FieldRangeSet& queryConstraints ,
 
228
                                      const BSONObj& order ) const ;
165
229
 
166
230
        bool isSparse() const { return _sparse; }
167
231
 
 
232
        string toString() const;
 
233
 
168
234
    protected:
169
235
 
170
236
        int indexVersion() const;
171
237
        
172
 
        IndexSuitability _suitability( const BSONObj& query , const BSONObj& order ) const ;
 
238
        IndexSuitability _suitability( const FieldRangeSet& queryConstraints ,
 
239
                                       const BSONObj& order ) const ;
173
240
 
174
241
        BSONSizeTracker _sizeTracker;
175
242
        vector<const char*> _fieldNames;
187
254
        shared_ptr<IndexType> _indexType;
188
255
        const IndexDetails * _details;
189
256
 
190
 
        void _init();
 
257
        void _init(PluginRules rules);
191
258
 
192
259
        friend class IndexType;
193
260
        friend class KeyGeneratorV0;