4
* Copyright (C) 2012 10gen Inc.
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.
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.
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/>.
23
#include "mongo/db/hasher.h"
24
#include "mongo/db/jsobj.h"
25
#include "mongo/db/record.h"
26
#include "mongo/util/unordered_fast_key_table.h"
32
extern const std::string WILDCARD;
33
extern const std::string INDEX_NAME;
38
inline void makeLower( std::string* s ) {
39
std::string::size_type sz = s->size();
40
for ( std::string::size_type i = 0; i < sz; i++ )
41
(*s)[i] = (char)tolower( (int)(*s)[i] );
45
* ScoredLocation stores the total score for a document (record *) wrt a search
48
struct ScoredLocation {
49
ScoredLocation( Record* r, double sc )
56
bool operator<( const ScoredLocation& other ) const {
57
if ( other.score < score )
59
if ( other.score > score )
61
return rec < other.rec;
65
// scored location comparison is done based on score
66
class ScoredLocationComp {
68
bool operator() (const ScoredLocation& lhs, const ScoredLocation& rhs) const {
69
return (lhs.score > rhs.score);
74
size_t operator()( const BSONElement& e ) const {
75
return static_cast<size_t>( BSONElementHasher::hash64( e, 17 ) );
80
bool operator()( const BSONElement& a, const BSONElement& b ) const {
86
BSONElement operator()( const BSONObj& o ) const {
87
const BSONElement& x = o.firstElement();
88
BSONElement y( x.rawdata() );
93
struct _be_convert_other {
94
BSONObj operator()( const BSONElement& e ) const {
99
template< typename V >
100
class BSONElementMap : public UnorderedFastKeyTable<BSONElement,
106
_be_convert_other > {