summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-04-29 14:02:47 -0400
committerEliot Horowitz <eliot@10gen.com>2013-04-29 14:51:37 -0400
commitb13db37280d9cfca51e1e5e59bf5956295ac61b6 (patch)
treee602017cc1e2dc9c630f48ea9698856eca65496b /src
parentf58d431f45a0db9812e67641f429c692c3207201 (diff)
downloadmongo-b13db37280d9cfca51e1e5e59bf5956295ac61b6.tar.gz
SERVER-6400 - move MatchDetails out of matcher.h
Diffstat (limited to 'src')
-rw-r--r--src/mongo/SConscript4
-rw-r--r--src/mongo/db/matcher.cpp19
-rw-r--r--src/mongo/db/matcher.h34
-rw-r--r--src/mongo/db/matcher/expression.cpp1
-rw-r--r--src/mongo/db/matcher/expression.h2
-rw-r--r--src/mongo/db/matcher/expression_array.cpp1
-rw-r--r--src/mongo/db/matcher/expression_array_test.cpp1
-rw-r--r--src/mongo/db/matcher/expression_leaf.cpp3
-rw-r--r--src/mongo/db/matcher/expression_leaf.h7
-rw-r--r--src/mongo/db/matcher/expression_leaf_test.cpp1
-rw-r--r--src/mongo/db/matcher/expression_parser_array_test.cpp5
-rw-r--r--src/mongo/db/matcher/expression_parser_leaf_test.cpp5
-rw-r--r--src/mongo/db/matcher/expression_parser_test.cpp19
-rw-r--r--src/mongo/db/matcher/expression_parser_tree_test.cpp1
-rw-r--r--src/mongo/db/matcher/expression_test.cpp16
-rw-r--r--src/mongo/db/matcher/expression_tree.cpp1
-rw-r--r--src/mongo/db/matcher/expression_tree_test.cpp1
-rw-r--r--src/mongo/db/matcher/match_details.cpp44
-rw-r--r--src/mongo/db/matcher/match_details.h58
19 files changed, 118 insertions, 105 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 6687cab89a7..360e4d89efa 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -119,7 +119,8 @@ env.StaticLibrary('expressions',
'db/matcher/expression_leaf.cpp',
'db/matcher/expression_tree.cpp',
'db/matcher/expression_parser.cpp',
- 'db/matcher/expression_parser_tree.cpp'],
+ 'db/matcher/expression_parser_tree.cpp',
+ 'db/matcher/match_details.cpp'],
LIBDEPS=['bson',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/third_party/pcrecpp'
@@ -312,6 +313,7 @@ env.StaticLibrary("coredb", [
'server_parameters',
'geoparser',
'geoquery',
+ 'expressions',
'$BUILD_DIR/mongo/foundation'])
coreServerFiles = [ "db/client_basic.cpp",
diff --git a/src/mongo/db/matcher.cpp b/src/mongo/db/matcher.cpp
index 2e679591f2c..ab0467d146d 100644
--- a/src/mongo/db/matcher.cpp
+++ b/src/mongo/db/matcher.cpp
@@ -230,25 +230,6 @@ namespace mongo {
}
}
- MatchDetails::MatchDetails() :
- _elemMatchKeyRequested() {
- resetOutput();
- }
-
- void MatchDetails::resetOutput() {
- _loadedRecord = false;
- _elemMatchKeyFound = false;
- _elemMatchKey = "";
- }
-
- string MatchDetails::toString() const {
- stringstream ss;
- ss << "loadedRecord: " << _loadedRecord << " ";
- ss << "elemMatchKeyRequested: " << _elemMatchKeyRequested << " ";
- ss << "elemMatchKey: " << ( _elemMatchKeyFound ? _elemMatchKey : "NONE" ) << " ";
- return ss.str();
- }
-
void Matcher::addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot) {
RegexMatcher rm;
diff --git a/src/mongo/db/matcher.h b/src/mongo/db/matcher.h
index a11ff54efc2..3c4d7cca783 100644
--- a/src/mongo/db/matcher.h
+++ b/src/mongo/db/matcher.h
@@ -23,6 +23,7 @@
#include "jsobj.h"
#include "pcrecpp.h"
#include "mongo/db/geo/geoquery.h"
+#include "mongo/db/matcher/match_details.h"
namespace mongo {
@@ -123,39 +124,6 @@ namespace mongo {
class Where; // used for $where javascript eval
class DiskLoc;
- /** Reports information about a match request. */
- class MatchDetails {
- public:
- MatchDetails();
- void resetOutput();
- string toString() const;
-
- /** Request that an elemMatchKey be recorded. */
- void requestElemMatchKey() { _elemMatchKeyRequested = true; }
-
- bool needRecord() const { return _elemMatchKeyRequested; }
-
- bool hasLoadedRecord() const { return _loadedRecord; }
- bool hasElemMatchKey() const { return _elemMatchKeyFound; }
- string elemMatchKey() const {
- verify( hasElemMatchKey() );
- return _elemMatchKey;
- }
-
- void setLoadedRecord( bool loadedRecord ) { _loadedRecord = loadedRecord; }
- void setElemMatchKey( const string &elemMatchKey ) {
- if ( _elemMatchKeyRequested ) {
- _elemMatchKeyFound = true;
- _elemMatchKey = elemMatchKey;
- }
- }
-
- private:
- bool _loadedRecord;
- bool _elemMatchKeyRequested;
- bool _elemMatchKeyFound;
- string _elemMatchKey;
- };
/* Match BSON objects against a query pattern.
diff --git a/src/mongo/db/matcher/expression.cpp b/src/mongo/db/matcher/expression.cpp
index 8d563c28711..a05d15926bb 100644
--- a/src/mongo/db/matcher/expression.cpp
+++ b/src/mongo/db/matcher/expression.cpp
@@ -21,7 +21,6 @@
#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
-#include "mongo/db/matcher.h"
#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h
index 734fb4e75c8..d292cf7fc9c 100644
--- a/src/mongo/db/matcher/expression.h
+++ b/src/mongo/db/matcher/expression.h
@@ -21,11 +21,11 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
#include "mongo/bson/bsonobj.h"
+#include "mongo/db/matcher/match_details.h"
namespace mongo {
class TreeExpression;
- class MatchDetails;
class Expression {
MONGO_DISALLOW_COPYING( Expression );
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp
index 6c1acc5f9a8..18582d7dfa6 100644
--- a/src/mongo/db/matcher/expression_array.cpp
+++ b/src/mongo/db/matcher/expression_array.cpp
@@ -20,7 +20,6 @@
#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/field_ref.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression_internal.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp
index 58d47d155a5..879e0a24404 100644
--- a/src/mongo/db/matcher/expression_array_test.cpp
+++ b/src/mongo/db/matcher/expression_array_test.cpp
@@ -20,7 +20,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_array.h"
#include "mongo/db/matcher/expression_tree.h"
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp
index fdbf50c9922..6d1ee7723ae 100644
--- a/src/mongo/db/matcher/expression_leaf.cpp
+++ b/src/mongo/db/matcher/expression_leaf.cpp
@@ -22,7 +22,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/field_ref.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression_internal.h"
#include "mongo/util/log.h"
@@ -177,7 +176,7 @@ namespace mongo {
Status RegexExpression::init( const StringData& path, const StringData& regex, const StringData& options ) {
_path = path;
- if ( regex.size() > RegexMatcher::MaxPatternSize ) {
+ if ( regex.size() > MaxPatternSize ) {
return Status( ErrorCodes::BadValue, "Regular expression is too long" );
}
diff --git a/src/mongo/db/matcher/expression_leaf.h b/src/mongo/db/matcher/expression_leaf.h
index 1b836366754..e55a5dea587 100644
--- a/src/mongo/db/matcher/expression_leaf.h
+++ b/src/mongo/db/matcher/expression_leaf.h
@@ -69,6 +69,13 @@ namespace mongo {
class RegexExpression : public LeafExpression {
public:
+ /**
+ * Maximum pattern size which pcre v8.3 can do matches correctly with
+ * LINK_SIZE define macro set to 2 @ pcre's config.h (based on
+ * experiments)
+ */
+ static const size_t MaxPatternSize = 32764;
+
Status init( const StringData& path, const StringData& regex, const StringData& options );
Status init( const StringData& path, const BSONElement& e );
diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp
index 9f11fad8c5e..be3255b0838 100644
--- a/src/mongo/db/matcher/expression_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_leaf_test.cpp
@@ -20,7 +20,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
diff --git a/src/mongo/db/matcher/expression_parser_array_test.cpp b/src/mongo/db/matcher/expression_parser_array_test.cpp
index ed4d091b6d0..3b0a6d0cc52 100644
--- a/src/mongo/db/matcher/expression_parser_array_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_array_test.cpp
@@ -20,11 +20,8 @@
#include "mongo/db/matcher/expression_parser.h"
-#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonmisc.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_array.h"
diff --git a/src/mongo/db/matcher/expression_parser_leaf_test.cpp b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
index 30c7c55c5d1..92246eead25 100644
--- a/src/mongo/db/matcher/expression_parser_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
@@ -20,11 +20,8 @@
#include "mongo/db/matcher/expression_parser.h"
-#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonmisc.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
diff --git a/src/mongo/db/matcher/expression_parser_test.cpp b/src/mongo/db/matcher/expression_parser_test.cpp
index 3cff591b299..92f5248a3bb 100644
--- a/src/mongo/db/matcher/expression_parser_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_test.cpp
@@ -20,30 +20,13 @@
#include "mongo/db/matcher/expression_parser.h"
-#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonmisc.h"
+#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
namespace mongo {
- /// HACK HACK HACK
-
- MatchDetails::MatchDetails() :
- _elemMatchKeyRequested() {
- resetOutput();
- }
- void MatchDetails::resetOutput() {
- _loadedRecord = false;
- _elemMatchKeyFound = false;
- _elemMatchKey = "";
- }
-
- // ----------------------------
-
TEST( ExpressionParserTest, SimpleEQ1 ) {
BSONObj query = BSON( "x" << 2 );
StatusWithExpression result = ExpressionParser::parse( query );
diff --git a/src/mongo/db/matcher/expression_parser_tree_test.cpp b/src/mongo/db/matcher/expression_parser_tree_test.cpp
index bd315b4ff1a..3598cccd080 100644
--- a/src/mongo/db/matcher/expression_parser_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_tree_test.cpp
@@ -24,7 +24,6 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
diff --git a/src/mongo/db/matcher/expression_test.cpp b/src/mongo/db/matcher/expression_test.cpp
index 44424e11d64..f9df13c253f 100644
--- a/src/mongo/db/matcher/expression_test.cpp
+++ b/src/mongo/db/matcher/expression_test.cpp
@@ -24,27 +24,11 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
namespace mongo {
- /// HACK HACK HACK
-
- MatchDetails::MatchDetails() :
- _elemMatchKeyRequested() {
- resetOutput();
- }
- void MatchDetails::resetOutput() {
- _loadedRecord = false;
- _elemMatchKeyFound = false;
- _elemMatchKey = "";
- }
-
-
- // ----------------------
-
TEST( ExpressionTest, Parse1 ) {
//TreeExpression* e = NULL;
//Status s = Expression::parse( BSON( "x" << 1 ), &e );
diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp
index e344e816158..d0bc7db9055 100644
--- a/src/mongo/db/matcher/expression_tree.cpp
+++ b/src/mongo/db/matcher/expression_tree.cpp
@@ -21,7 +21,6 @@
#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
-#include "mongo/db/matcher.h"
#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp
index 4dabbbbfef9..485e154951e 100644
--- a/src/mongo/db/matcher/expression_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_tree_test.cpp
@@ -20,7 +20,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/db/matcher.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_tree.h"
#include "mongo/db/matcher/expression_leaf.h"
diff --git a/src/mongo/db/matcher/match_details.cpp b/src/mongo/db/matcher/match_details.cpp
new file mode 100644
index 00000000000..85938c7a849
--- /dev/null
+++ b/src/mongo/db/matcher/match_details.cpp
@@ -0,0 +1,44 @@
+// match_details.cpp
+
+/**
+* Copyright (C) 2013 10gen Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "mongo/pch.h"
+
+#include "mongo/db/matcher/match_details.h"
+
+namespace mongo {
+
+ MatchDetails::MatchDetails() :
+ _elemMatchKeyRequested() {
+ resetOutput();
+ }
+
+ void MatchDetails::resetOutput() {
+ _loadedRecord = false;
+ _elemMatchKeyFound = false;
+ _elemMatchKey = "";
+ }
+
+ string MatchDetails::toString() const {
+ stringstream ss;
+ ss << "loadedRecord: " << _loadedRecord << " ";
+ ss << "elemMatchKeyRequested: " << _elemMatchKeyRequested << " ";
+ ss << "elemMatchKey: " << ( _elemMatchKeyFound ? _elemMatchKey : "NONE" ) << " ";
+ return ss.str();
+ }
+
+}
diff --git a/src/mongo/db/matcher/match_details.h b/src/mongo/db/matcher/match_details.h
new file mode 100644
index 00000000000..5acf7b4948b
--- /dev/null
+++ b/src/mongo/db/matcher/match_details.h
@@ -0,0 +1,58 @@
+// match_details.h
+
+/**
+* Copyright (C) 2013 10gen Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <string>
+
+namespace mongo {
+
+ /** Reports information about a match request. */
+ class MatchDetails {
+ public:
+ MatchDetails();
+ void resetOutput();
+ std::string toString() const;
+
+ /** Request that an elemMatchKey be recorded. */
+ void requestElemMatchKey() { _elemMatchKeyRequested = true; }
+
+ bool needRecord() const { return _elemMatchKeyRequested; }
+
+ bool hasLoadedRecord() const { return _loadedRecord; }
+ bool hasElemMatchKey() const { return _elemMatchKeyFound; }
+ std::string elemMatchKey() const {
+ verify( hasElemMatchKey() );
+ return _elemMatchKey;
+ }
+
+ void setLoadedRecord( bool loadedRecord ) { _loadedRecord = loadedRecord; }
+ void setElemMatchKey( const std::string &elemMatchKey ) {
+ if ( _elemMatchKeyRequested ) {
+ _elemMatchKeyFound = true;
+ _elemMatchKey = elemMatchKey;
+ }
+ }
+
+ private:
+ bool _loadedRecord;
+ bool _elemMatchKeyRequested;
+ bool _elemMatchKeyFound;
+ std::string _elemMatchKey;
+ };
+}