summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-11-15 16:35:46 -0500
committerEliot Horowitz <eliot@10gen.com>2010-11-15 16:36:04 -0500
commit62878d24b7b99c13f914f8d992d38f246f0bbb57 (patch)
tree557faae7818268ec292ff118a0a3f35478407936
parenta0de8044927534fcd80aa6f66f0be344a1c8505d (diff)
downloadmongo-62878d24b7b99c13f914f8d992d38f246f0bbb57.tar.gz
rename FieldMatcher to Projection
-rw-r--r--db/clientcursor.h2
-rw-r--r--db/projection.cpp24
-rw-r--r--db/projection.h6
-rw-r--r--db/query.h8
-rw-r--r--db/scanandorder.h6
-rw-r--r--dbtests/querytests.cpp6
6 files changed, 26 insertions, 26 deletions
diff --git a/db/clientcursor.h b/db/clientcursor.h
index 4793ed37c01..98cbdd8f7c2 100644
--- a/db/clientcursor.h
+++ b/db/clientcursor.h
@@ -355,7 +355,7 @@ namespace mongo {
public:
shared_ptr< ParsedQuery > pq;
- shared_ptr< FieldMatcher > fields; // which fields query wants returned
+ shared_ptr< Projection > fields; // which fields query wants returned
Message originalMessage; // this is effectively an auto ptr for data the matcher points to
diff --git a/db/projection.cpp b/db/projection.cpp
index 29d80fe703e..55d9e20d0f5 100644
--- a/db/projection.cpp
+++ b/db/projection.cpp
@@ -20,8 +20,8 @@
namespace mongo {
- void FieldMatcher::init( const BSONObj& o ){
- massert( 10371 , "can only add to FieldMatcher once", _source.isEmpty());
+ void Projection::init( const BSONObj& o ){
+ massert( 10371 , "can only add to Projection once", _source.isEmpty());
_source = o;
BSONObjIterator i( o );
@@ -77,7 +77,7 @@ namespace mongo {
}
}
- void FieldMatcher::add(const string& field, bool include){
+ void Projection::add(const string& field, bool include){
if (field.empty()){ // this is the field the user referred to
_include = include;
}
@@ -88,15 +88,15 @@ namespace mongo {
const string subfield = field.substr(0,dot);
const string rest = (dot == string::npos ? "" : field.substr(dot+1,string::npos));
- boost::shared_ptr<FieldMatcher>& fm = _fields[subfield];
+ boost::shared_ptr<Projection>& fm = _fields[subfield];
if (!fm)
- fm.reset(new FieldMatcher());
+ fm.reset(new Projection());
fm->add(rest, include);
}
}
- void FieldMatcher::add(const string& field, int skip, int limit){
+ void Projection::add(const string& field, int skip, int limit){
_special = true; // can't include or exclude whole object
if (field.empty()){ // this is the field the user referred to
@@ -107,15 +107,15 @@ namespace mongo {
const string subfield = field.substr(0,dot);
const string rest = (dot == string::npos ? "" : field.substr(dot+1,string::npos));
- boost::shared_ptr<FieldMatcher>& fm = _fields[subfield];
+ boost::shared_ptr<Projection>& fm = _fields[subfield];
if (!fm)
- fm.reset(new FieldMatcher());
+ fm.reset(new Projection());
fm->add(rest, skip, limit);
}
}
- BSONObj FieldMatcher::transform( const BSONObj& in ) const {
+ BSONObj Projection::transform( const BSONObj& in ) const {
BSONObjBuilder b;
BSONObjIterator i(in);
while ( i.more() )
@@ -125,7 +125,7 @@ namespace mongo {
//b will be the value part of an array-typed BSONElement
- void FieldMatcher::appendArray( BSONObjBuilder& b , const BSONObj& a , bool nested) const {
+ void Projection::appendArray( BSONObjBuilder& b , const BSONObj& a , bool nested) const {
int skip = nested ? 0 : _skip;
int limit = nested ? -1 : _limit;
@@ -170,7 +170,7 @@ namespace mongo {
}
}
- void FieldMatcher::append( BSONObjBuilder& b , const BSONElement& e ) const {
+ void Projection::append( BSONObjBuilder& b , const BSONElement& e ) const {
FieldMap::const_iterator field = _fields.find( e.fieldName() );
if (field == _fields.end()){
@@ -178,7 +178,7 @@ namespace mongo {
b.append(e);
}
else {
- FieldMatcher& subfm = *field->second;
+ Projection& subfm = *field->second;
if ((subfm._fields.empty() && !subfm._special) || !(e.type()==Object || e.type()==Array) ){
if (subfm._include)
diff --git a/db/projection.h b/db/projection.h
index 730fc8e69d4..5f15d20b2f3 100644
--- a/db/projection.h
+++ b/db/projection.h
@@ -25,9 +25,9 @@ namespace mongo {
/**
used for doing field limiting
*/
- class FieldMatcher {
+ class Projection {
public:
- FieldMatcher()
+ Projection()
: _include(true)
, _special(false)
, _includeID(true)
@@ -74,7 +74,7 @@ namespace mongo {
bool _special; // true if this level can't be skipped or included without recursing
//TODO: benchmark vector<pair> vs map
- typedef map<string, boost::shared_ptr<FieldMatcher> > FieldMap;
+ typedef map<string, boost::shared_ptr<Projection> > FieldMap;
FieldMap _fields;
BSONObj _source;
bool _includeID;
diff --git a/db/query.h b/db/query.h
index fb2949c3602..6a66ec2dc65 100644
--- a/db/query.h
+++ b/db/query.h
@@ -161,8 +161,8 @@ namespace mongo {
bool isLocalDB() const { return strncmp(_ns, "local.", 6) == 0; }
const BSONObj& getFilter() const { return _filter; }
- FieldMatcher* getFields() const { return _fields.get(); }
- shared_ptr<FieldMatcher> getFieldPtr() const { return _fields; }
+ Projection* getFields() const { return _fields.get(); }
+ shared_ptr<Projection> getFieldPtr() const { return _fields; }
int getSkip() const { return _ntoskip; }
int getNumToReturn() const { return _ntoreturn; }
@@ -293,7 +293,7 @@ namespace mongo {
void initFields( const BSONObj& fields ){
if ( fields.isEmpty() )
return;
- _fields.reset( new FieldMatcher() );
+ _fields.reset( new Projection() );
_fields->init( fields );
}
@@ -307,7 +307,7 @@ namespace mongo {
int _options;
BSONObj _filter;
- shared_ptr< FieldMatcher > _fields;
+ shared_ptr< Projection > _fields;
bool _wantMore;
diff --git a/db/scanandorder.h b/db/scanandorder.h
index 8d63b9ab34c..a9de954e736 100644
--- a/db/scanandorder.h
+++ b/db/scanandorder.h
@@ -50,7 +50,7 @@ namespace mongo {
_ response size limit from runquery; push it up a bit.
*/
- inline void fillQueryResultFromObj(BufBuilder& bb, FieldMatcher *filter, BSONObj& js, DiskLoc* loc=NULL) {
+ inline void fillQueryResultFromObj(BufBuilder& bb, Projection *filter, BSONObj& js, DiskLoc* loc=NULL) {
if ( filter ) {
BSONObjBuilder b( bb );
BSONObjIterator i( js );
@@ -140,7 +140,7 @@ namespace mongo {
_addIfBetter(k, o, i, loc);
}
- void _fill(BufBuilder& b, FieldMatcher *filter, int& nout, BestMap::iterator begin, BestMap::iterator end) {
+ void _fill(BufBuilder& b, Projection *filter, int& nout, BestMap::iterator begin, BestMap::iterator end) {
int n = 0;
int nFilled = 0;
for ( BestMap::iterator i = begin; i != end; i++ ) {
@@ -158,7 +158,7 @@ namespace mongo {
}
/* scanning complete. stick the query result in b for n objects. */
- void fill(BufBuilder& b, FieldMatcher *filter, int& nout) {
+ void fill(BufBuilder& b, Projection *filter, int& nout) {
_fill(b, filter, nout, best.begin(), best.end());
}
diff --git a/dbtests/querytests.cpp b/dbtests/querytests.cpp
index c303e6c4fbf..0a87193464c 100644
--- a/dbtests/querytests.cpp
+++ b/dbtests/querytests.cpp
@@ -1115,13 +1115,13 @@ namespace QueryTests {
}
};
- namespace fm { // FieldMatcher tests
+ namespace proj { // Projection tests
class T1 {
public:
void run(){
- FieldMatcher m;
+ Projection m;
m.init( BSON( "a" << 1 ) );
ASSERT_EQUALS( BSON( "a" << 5 ) , m.transform( BSON( "x" << 1 << "a" << 5 ) ) );
}
@@ -1185,7 +1185,7 @@ namespace QueryTests {
add< OrderingTest >();
- add< fm::T1 >();
+ add< proj::T1 >();
}
} myall;