summaryrefslogtreecommitdiff
path: root/src/mongo/db/keypattern.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/keypattern.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/keypattern.cpp')
-rw-r--r--src/mongo/db/keypattern.cpp105
1 files changed, 52 insertions, 53 deletions
diff --git a/src/mongo/db/keypattern.cpp b/src/mongo/db/keypattern.cpp
index b62885b97d1..9ef77deb639 100644
--- a/src/mongo/db/keypattern.cpp
+++ b/src/mongo/db/keypattern.cpp
@@ -35,68 +35,67 @@
namespace mongo {
- KeyPattern::KeyPattern( const BSONObj& pattern ): _pattern( pattern ) {}
+KeyPattern::KeyPattern(const BSONObj& pattern) : _pattern(pattern) {}
- bool KeyPattern::isIdKeyPattern(const BSONObj& pattern) {
- BSONObjIterator i(pattern);
- BSONElement e = i.next();
- // _id index must have form exactly {_id : 1} or {_id : -1}.
- // Allows an index of form {_id : "hashed"} to exist but
- // do not consider it to be the primary _id index
- return (0 == strcmp(e.fieldName(), "_id"))
- && (e.numberInt() == 1 || e.numberInt() == -1)
- && i.next().eoo();
- }
+bool KeyPattern::isIdKeyPattern(const BSONObj& pattern) {
+ BSONObjIterator i(pattern);
+ BSONElement e = i.next();
+ // _id index must have form exactly {_id : 1} or {_id : -1}.
+ // Allows an index of form {_id : "hashed"} to exist but
+ // do not consider it to be the primary _id index
+ return (0 == strcmp(e.fieldName(), "_id")) && (e.numberInt() == 1 || e.numberInt() == -1) &&
+ i.next().eoo();
+}
- bool KeyPattern::isOrderedKeyPattern(const BSONObj& pattern) {
- return IndexNames::BTREE == IndexNames::findPluginName(pattern);
- }
+bool KeyPattern::isOrderedKeyPattern(const BSONObj& pattern) {
+ return IndexNames::BTREE == IndexNames::findPluginName(pattern);
+}
- bool KeyPattern::isHashedKeyPattern(const BSONObj& pattern) {
- return IndexNames::HASHED == IndexNames::findPluginName(pattern);
- }
+bool KeyPattern::isHashedKeyPattern(const BSONObj& pattern) {
+ return IndexNames::HASHED == IndexNames::findPluginName(pattern);
+}
- BSONObj KeyPattern::extendRangeBound( const BSONObj& bound , bool makeUpperInclusive ) const {
- BSONObjBuilder newBound( bound.objsize() );
+BSONObj KeyPattern::extendRangeBound(const BSONObj& bound, bool makeUpperInclusive) const {
+ BSONObjBuilder newBound(bound.objsize());
- BSONObjIterator src( bound );
- BSONObjIterator pat( _pattern );
+ BSONObjIterator src(bound);
+ BSONObjIterator pat(_pattern);
- while( src.more() ){
- massert( 16649 ,
- str::stream() << "keyPattern " << _pattern << " shorter than bound " << bound,
- pat.more() );
- BSONElement srcElt = src.next();
- BSONElement patElt = pat.next();
- massert( 16634 ,
- str::stream() << "field names of bound " << bound
- << " do not match those of keyPattern " << _pattern ,
- str::equals( srcElt.fieldName() , patElt.fieldName() ) );
- newBound.append( srcElt );
- }
- while( pat.more() ){
- BSONElement patElt = pat.next();
- // for non 1/-1 field values, like {a : "hashed"}, treat order as ascending
- int order = patElt.isNumber() ? patElt.numberInt() : 1;
- // flip the order semantics if this is an upper bound
- if ( makeUpperInclusive ) order *= -1;
+ while (src.more()) {
+ massert(16649,
+ str::stream() << "keyPattern " << _pattern << " shorter than bound " << bound,
+ pat.more());
+ BSONElement srcElt = src.next();
+ BSONElement patElt = pat.next();
+ massert(16634,
+ str::stream() << "field names of bound " << bound
+ << " do not match those of keyPattern " << _pattern,
+ str::equals(srcElt.fieldName(), patElt.fieldName()));
+ newBound.append(srcElt);
+ }
+ while (pat.more()) {
+ BSONElement patElt = pat.next();
+ // for non 1/-1 field values, like {a : "hashed"}, treat order as ascending
+ int order = patElt.isNumber() ? patElt.numberInt() : 1;
+ // flip the order semantics if this is an upper bound
+ if (makeUpperInclusive)
+ order *= -1;
- if( order > 0 ){
- newBound.appendMinKey( patElt.fieldName() );
- }
- else {
- newBound.appendMaxKey( patElt.fieldName() );
- }
+ if (order > 0) {
+ newBound.appendMinKey(patElt.fieldName());
+ } else {
+ newBound.appendMaxKey(patElt.fieldName());
}
- return newBound.obj();
}
+ return newBound.obj();
+}
- BSONObj KeyPattern::globalMin() const {
- return extendRangeBound(BSONObj(), false);
- }
+BSONObj KeyPattern::globalMin() const {
+ return extendRangeBound(BSONObj(), false);
+}
- BSONObj KeyPattern::globalMax() const {
- return extendRangeBound(BSONObj(), true);
- }
+BSONObj KeyPattern::globalMax() const {
+ return extendRangeBound(BSONObj(), true);
+}
-} // namespace mongo
+} // namespace mongo