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

« back to all changes in this revision

Viewing changes to src/mongo/db/fts/fts_search.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:
 
1
// fts_search.h
 
2
 
 
3
/**
 
4
*    Copyright (C) 2012 10gen Inc.
 
5
*
 
6
*    This program is free software: you can redistribute it and/or  modify
 
7
*    it under the terms of the GNU Affero General Public License, version 3,
 
8
*    as published by the Free Software Foundation.
 
9
*
 
10
*    This program is distributed in the hope that it will be useful,
 
11
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
*    GNU Affero General Public License for more details.
 
14
*
 
15
*    You should have received a copy of the GNU Affero General Public License
 
16
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
 
19
#pragma once
 
20
 
 
21
#include <map>
 
22
#include <set>
 
23
#include <vector>
 
24
#include <queue>
 
25
 
 
26
#include "mongo/base/disallow_copying.h"
 
27
#include "mongo/db/fts/fts_index.h"
 
28
#include "mongo/db/fts/fts_matcher.h"
 
29
#include "mongo/db/fts/fts_query.h"
 
30
#include "mongo/db/fts/fts_util.h"
 
31
#include "mongo/db/matcher.h"
 
32
 
 
33
namespace mongo {
 
34
 
 
35
    class BtreeCursor;
 
36
 
 
37
    namespace fts {
 
38
 
 
39
        // priority queue template, for use when we're populating results
 
40
        // vector returned to the user. extends the default priority_queue
 
41
        // by providing direct access to the underlying vector, which should
 
42
        // be used CAREFULLY because you can get into trouble..
 
43
        template <class T, class S, class C>
 
44
        class a_priority_queue : public std::priority_queue<T, S, C> {
 
45
        public:
 
46
            // return the value of an element at position n when we call pq[n]
 
47
            T operator[](const int &n) { return this->c[n]; }
 
48
            // return underlying data structure. called dangerous because it is.
 
49
            S dangerous() { return this->c; }
 
50
        };
 
51
 
 
52
        typedef a_priority_queue<ScoredLocation, vector<ScoredLocation>, ScoredLocationComp> Results;
 
53
 
 
54
        class FTSSearch {
 
55
            MONGO_DISALLOW_COPYING(FTSSearch);
 
56
        public:
 
57
 
 
58
            typedef std::map<Record*,double> Scores;
 
59
 
 
60
            FTSSearch( NamespaceDetails* ns,
 
61
                       const IndexDetails& id,
 
62
                       const BSONObj& indexPrefix,
 
63
                       const FTSQuery& query,
 
64
                       const BSONObj& filter );
 
65
 
 
66
 
 
67
            void go(Results* results, unsigned limit );
 
68
 
 
69
            const FTSIndex * getIndex() const { return _fts; }
 
70
 
 
71
            long long getKeysLookedAt() const { return _keysLookedAt; }
 
72
            long long getObjLookedAt() const { return _objectsLookedAt; }
 
73
 
 
74
        private:
 
75
 
 
76
            void _process( BtreeCursor* cursor );
 
77
 
 
78
            /**
 
79
             * checks not index pieces
 
80
             * i.e. prhases & negated terms
 
81
             */
 
82
            bool _ok( Record* record ) const;
 
83
 
 
84
            NamespaceDetails* _ns;
 
85
            const IndexDetails& _id;
 
86
            FTSIndex* _fts;
 
87
            BSONObj _indexPrefix;
 
88
            FTSQuery _query;
 
89
            FTSMatcher _ftsMatcher;
 
90
 
 
91
            scoped_ptr<CoveredIndexMatcher> _matcher;
 
92
 
 
93
            long long _keysLookedAt;
 
94
            long long _objectsLookedAt;
 
95
 
 
96
            Scores _scores;
 
97
 
 
98
        };
 
99
 
 
100
    } // namespace fts
 
101
 
 
102
} // namespace mongo
 
103