summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher_covered.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-05-07 17:57:02 -0400
committerEliot Horowitz <eliot@10gen.com>2013-05-07 23:13:20 -0400
commit7490373462b0d3dd475b99252d7d0a14f3c69c4b (patch)
tree87704bd774de531153312d9a7ea2bf5eb0b4d991 /src/mongo/db/matcher_covered.h
parent38a311afb70d4abf940b3c23c479d2c46ee59eac (diff)
downloadmongo-7490373462b0d3dd475b99252d7d0a14f3c69c4b.tar.gz
SERVER-6400: move CoveredIndexMatcher declaration to its own file
Diffstat (limited to 'src/mongo/db/matcher_covered.h')
-rw-r--r--src/mongo/db/matcher_covered.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mongo/db/matcher_covered.h b/src/mongo/db/matcher_covered.h
new file mode 100644
index 00000000000..fe24b07a87c
--- /dev/null
+++ b/src/mongo/db/matcher_covered.h
@@ -0,0 +1,76 @@
+// matcher_covered.h
+
+/* Matcher is our boolean expression evaluator for "where" clauses */
+
+/**
+* Copyright (C) 2008 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 "mongo/db/diskloc.h"
+#include "mongo/db/geo/geoquery.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/matcher.h"
+#include "mongo/db/matcher/match_details.h"
+
+namespace mongo {
+
+ // If match succeeds on index key, then attempt to match full document.
+ class CoveredIndexMatcher : boost::noncopyable {
+ public:
+ CoveredIndexMatcher(const BSONObj &pattern, const BSONObj &indexKeyPattern);
+ bool matchesWithSingleKeyIndex( const BSONObj& key, const DiskLoc& recLoc,
+ MatchDetails* details = 0 ) const {
+ return matches( key, recLoc, details, true );
+ }
+ /**
+ * This is the preferred method for matching against a cursor, as it
+ * can handle both multi and single key cursors.
+ */
+ bool matchesCurrent( Cursor * cursor , MatchDetails * details = 0 ) const;
+ bool needRecord() const { return _needRecord; }
+
+ const Matcher &docMatcher() const { return *_docMatcher; }
+
+ /**
+ * @return a matcher for a following $or clause.
+ * @param prevClauseFrs The index range scanned by the previous $or clause. May be empty.
+ * @param nextClauseIndexKeyPattern The index key of the following $or clause.
+ */
+ CoveredIndexMatcher *nextClauseMatcher( const shared_ptr<FieldRangeVector>& prevClauseFrv,
+ const BSONObj& nextClauseIndexKeyPattern ) const {
+ return new CoveredIndexMatcher( *this, prevClauseFrv, nextClauseIndexKeyPattern );
+ }
+
+ string toString() const;
+
+ private:
+ bool matches( const BSONObj& key, const DiskLoc& recLoc, MatchDetails* details = 0,
+ bool keyUsable = true ) const;
+ bool isOrClauseDup( const BSONObj &obj ) const;
+ CoveredIndexMatcher( const CoveredIndexMatcher &prevClauseMatcher,
+ const shared_ptr<FieldRangeVector> &prevClauseFrv,
+ const BSONObj &nextClauseIndexKeyPattern );
+ void init();
+ shared_ptr< Matcher > _docMatcher;
+ Matcher _keyMatcher;
+ vector<shared_ptr<FieldRangeVector> > _orDedupConstraints;
+
+ bool _needRecord; // if the key itself isn't good enough to determine a positive match
+ };
+
+} // namespace mongo
+