summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-02-19 13:33:36 -0500
committerMathias Stearn <mathias@10gen.com>2015-03-27 14:32:37 -0400
commitcafa5d7815509e5ce4fa65f4def89cf18e087bcf (patch)
tree5293417470ae7e0432eeb943f81d9e988880e669 /src/mongo
parentee8ebe091acd1c519b6e5485e8da642f3c4af892 (diff)
downloadmongo-cafa5d7815509e5ce4fa65f4def89cf18e087bcf.tar.gz
Merge bsonobjiterator.h/cpp into bsonobj.h/cpp
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/bson/bsonobj.cpp41
-rw-r--r--src/mongo/bson/bsonobj.h149
-rw-r--r--src/mongo/bson/bsonobjiterator.cpp74
-rw-r--r--src/mongo/bson/bsonobjiterator.h182
-rw-r--r--src/mongo/bson/ordering.h1
-rw-r--r--src/mongo/db/fts/fts_element_iterator.h1
-rw-r--r--src/mongo/db/global_environment_experiment.cpp2
-rw-r--r--src/mongo/db/jsobj.h1
-rw-r--r--src/mongo/db/matcher/expression.cpp1
-rw-r--r--src/mongo/db/matcher/expression_leaf.cpp1
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp1
-rw-r--r--src/mongo/db/matcher/expression_parser_tree.cpp1
-rw-r--r--src/mongo/db/matcher/expression_tree.cpp1
-rw-r--r--src/mongo/db/matcher/path.h1
-rw-r--r--src/mongo/logger/parse_log_component_settings.cpp1
-rw-r--r--src/mongo/s/mock_ns_targeter.h2
-rw-r--r--src/mongo/s/write_ops/batched_command_request.cpp2
-rw-r--r--src/mongo/util/options_parser/environment.cpp1
19 files changed, 191 insertions, 273 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 485932242ac..660ae1c2522 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -119,7 +119,6 @@ env.Library('bson', [
'bson/bsonmisc.cpp',
'bson/bsonobj.cpp',
'bson/bsonobjbuilder.cpp',
- 'bson/bsonobjiterator.cpp',
'bson/bsontypes.cpp',
'db/json.cpp'
], LIBDEPS=[
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp
index cb57e1ed233..b9e76532fe0 100644
--- a/src/mongo/bson/bsonobj.cpp
+++ b/src/mongo/bson/bsonobj.cpp
@@ -39,6 +39,7 @@
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/stringutils.h"
namespace mongo {
using namespace std;
@@ -814,4 +815,44 @@ namespace mongo {
return s;
}
+ /** Compare two bson elements, provided as const char *'s, by field name. */
+ class BSONIteratorSorted::ElementFieldCmp {
+ public:
+ ElementFieldCmp( bool isArray );
+ bool operator()( const char *s1, const char *s2 ) const;
+ private:
+ LexNumCmp _cmp;
+ };
+
+ BSONIteratorSorted::ElementFieldCmp::ElementFieldCmp( bool isArray ) :
+ _cmp( !isArray ) {
+ }
+
+ bool BSONIteratorSorted::ElementFieldCmp::operator()( const char *s1, const char *s2 )
+ const {
+ // Skip the type byte and compare field names.
+ return _cmp( s1 + 1, s2 + 1 );
+ }
+
+ BSONIteratorSorted::BSONIteratorSorted( const BSONObj &o, const ElementFieldCmp &cmp )
+ : _nfields(o.nFields()), _fields(new const char*[_nfields]) {
+ int x = 0;
+ BSONObjIterator i( o );
+ while ( i.more() ) {
+ _fields[x++] = i.next().rawdata();
+ verify( _fields[x-1] );
+ }
+ verify( x == _nfields );
+ std::sort( _fields.get() , _fields.get() + _nfields , cmp );
+ _cur = 0;
+ }
+
+ BSONObjIteratorSorted::BSONObjIteratorSorted( const BSONObj &object ) :
+ BSONIteratorSorted( object, ElementFieldCmp( false ) ) {
+ }
+
+ BSONArrayIteratorSorted::BSONArrayIteratorSorted( const BSONArray &array ) :
+ BSONIteratorSorted( array, ElementFieldCmp( true ) ) {
+ }
+
} // namespace mongo
diff --git a/src/mongo/bson/bsonobj.h b/src/mongo/bson/bsonobj.h
index ccb20fd59ec..3a5d8a086a0 100644
--- a/src/mongo/bson/bsonobj.h
+++ b/src/mongo/bson/bsonobj.h
@@ -29,14 +29,17 @@
#pragma once
-#include <set>
+#include <boost/preprocessor/cat.hpp> // like the ## operator but works with __LINE__
+#include <boost/scoped_array.hpp>
#include <list>
+#include <set>
#include <string>
-#include <vector>
#include <utility>
+#include <vector>
#include "mongo/bson/bsonelement.h"
#include "mongo/base/data_view.h"
+#include "mongo/base/disallow_copying.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/util/builder.h"
#include "mongo/platform/atomic_word.h"
@@ -585,4 +588,146 @@ namespace mongo {
explicit BSONArray(const BSONObj& obj): BSONObj(obj) {}
};
+ /** iterator for a BSONObj
+
+ Note each BSONObj ends with an EOO element: so you will get more() on an empty
+ object, although next().eoo() will be true.
+
+ The BSONObj must stay in scope for the duration of the iterator's execution.
+
+ todo: we may want to make a more stl-like iterator interface for this
+ with things like begin() and end()
+ */
+ class BSONObjIterator {
+ public:
+ /** Create an iterator for a BSON object.
+ */
+ BSONObjIterator(const BSONObj& jso) {
+ int sz = jso.objsize();
+ if ( MONGO_unlikely(sz == 0) ) {
+ _pos = _theend = 0;
+ return;
+ }
+ _pos = jso.objdata() + 4;
+ _theend = jso.objdata() + sz - 1;
+ }
+
+ BSONObjIterator( const char * start , const char * end ) {
+ _pos = start + 4;
+ _theend = end - 1;
+ }
+
+ /** @return true if more elements exist to be enumerated. */
+ bool more() { return _pos < _theend; }
+
+ /** @return true if more elements exist to be enumerated INCLUDING the EOO element which is always at the end. */
+ bool moreWithEOO() { return _pos <= _theend; }
+
+ /** @return the next element in the object. For the final element, element.eoo() will be true. */
+ BSONElement next( bool checkEnd ) {
+ verify( _pos <= _theend );
+
+ int maxLen = -1;
+ if ( checkEnd ) {
+ maxLen = _theend + 1 - _pos;
+ verify( maxLen > 0 );
+ }
+
+ BSONElement e( _pos, maxLen );
+ int esize = e.size( maxLen );
+ massert( 16446, "BSONElement has bad size", esize > 0 );
+ _pos += esize;
+
+ return e;
+ }
+ BSONElement next() {
+ verify( _pos <= _theend );
+ BSONElement e(_pos);
+ _pos += e.size();
+ return e;
+ }
+ void operator++() { next(); }
+ void operator++(int) { next(); }
+
+ BSONElement operator*() {
+ verify( _pos <= _theend );
+ return BSONElement(_pos);
+ }
+
+ private:
+ const char* _pos;
+ const char* _theend;
+ };
+
+ /** Base class implementing ordered iteration through BSONElements. */
+ class BSONIteratorSorted {
+ MONGO_DISALLOW_COPYING(BSONIteratorSorted);
+ public:
+ ~BSONIteratorSorted() {
+ verify( _fields );
+ }
+
+ bool more() {
+ return _cur < _nfields;
+ }
+
+ BSONElement next() {
+ verify( _fields );
+ if ( _cur < _nfields )
+ return BSONElement( _fields[_cur++] );
+ return BSONElement();
+ }
+
+ protected:
+ class ElementFieldCmp;
+ BSONIteratorSorted( const BSONObj &o, const ElementFieldCmp &cmp );
+
+ private:
+ const int _nfields;
+ const boost::scoped_array<const char *> _fields;
+ int _cur;
+ };
+
+ /** Provides iteration of a BSONObj's BSONElements in lexical field order. */
+ class BSONObjIteratorSorted : public BSONIteratorSorted {
+ public:
+ BSONObjIteratorSorted( const BSONObj &object );
+ };
+
+ /**
+ * Provides iteration of a BSONArray's BSONElements in numeric field order.
+ * The elements of a bson array should always be numerically ordered by field name, but this
+ * implementation re-sorts them anyway.
+ */
+ class BSONArrayIteratorSorted : public BSONIteratorSorted {
+ public:
+ BSONArrayIteratorSorted( const BSONArray &array );
+ };
+
+ /** Similar to BOOST_FOREACH
+ *
+ * because the iterator is defined outside of the for, you must use {} around
+ * the surrounding scope. Don't do this:
+ *
+ * if (foo)
+ * BSONForEach(e, obj)
+ * doSomething(e);
+ *
+ * but this is OK:
+ *
+ * if (foo) {
+ * BSONForEach(e, obj)
+ * doSomething(e);
+ * }
+ *
+ */
+
+#define BSONForEach(e, obj) \
+ BSONObjIterator BOOST_PP_CAT(it_,__LINE__)(obj); \
+ for ( BSONElement e; \
+ (BOOST_PP_CAT(it_,__LINE__).more() ? \
+ (e = BOOST_PP_CAT(it_,__LINE__).next(), true) : \
+ false) ; \
+ /*nothing*/ )
+
}
diff --git a/src/mongo/bson/bsonobjiterator.cpp b/src/mongo/bson/bsonobjiterator.cpp
deleted file mode 100644
index c4c922e6580..00000000000
--- a/src/mongo/bson/bsonobjiterator.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright (C) 2014 MongoDB 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/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/db/jsobj.h"
-
-#include "mongo/util/stringutils.h"
-
-namespace mongo {
- /** Compare two bson elements, provided as const char *'s, by field name. */
- class BSONIteratorSorted::ElementFieldCmp {
- public:
- ElementFieldCmp( bool isArray );
- bool operator()( const char *s1, const char *s2 ) const;
- private:
- LexNumCmp _cmp;
- };
-
- BSONIteratorSorted::ElementFieldCmp::ElementFieldCmp( bool isArray ) :
- _cmp( !isArray ) {
- }
-
- bool BSONIteratorSorted::ElementFieldCmp::operator()( const char *s1, const char *s2 )
- const {
- // Skip the type byte and compare field names.
- return _cmp( s1 + 1, s2 + 1 );
- }
-
- BSONIteratorSorted::BSONIteratorSorted( const BSONObj &o, const ElementFieldCmp &cmp )
- : _nfields(o.nFields()), _fields(new const char*[_nfields]) {
- int x = 0;
- BSONObjIterator i( o );
- while ( i.more() ) {
- _fields[x++] = i.next().rawdata();
- verify( _fields[x-1] );
- }
- verify( x == _nfields );
- std::sort( _fields.get() , _fields.get() + _nfields , cmp );
- _cur = 0;
- }
-
- BSONObjIteratorSorted::BSONObjIteratorSorted( const BSONObj &object ) :
- BSONIteratorSorted( object, ElementFieldCmp( false ) ) {
- }
-
- BSONArrayIteratorSorted::BSONArrayIteratorSorted( const BSONArray &array ) :
- BSONIteratorSorted( array, ElementFieldCmp( true ) ) {
- }
-} // namespace mongo
diff --git a/src/mongo/bson/bsonobjiterator.h b/src/mongo/bson/bsonobjiterator.h
deleted file mode 100644
index aabad674487..00000000000
--- a/src/mongo/bson/bsonobjiterator.h
+++ /dev/null
@@ -1,182 +0,0 @@
-// bsonobjiterator.h
-
-/* Copyright 2009 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/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-#pragma once
-
-#include <boost/preprocessor/cat.hpp> // like the ## operator but works with __LINE__
-#include <boost/scoped_array.hpp>
-
-#include "mongo/bson/bsonobj.h"
-#include "mongo/base/disallow_copying.h"
-
-namespace mongo {
-
- /** iterator for a BSONObj
-
- Note each BSONObj ends with an EOO element: so you will get more() on an empty
- object, although next().eoo() will be true.
-
- The BSONObj must stay in scope for the duration of the iterator's execution.
-
- todo: we may want to make a more stl-like iterator interface for this
- with things like begin() and end()
- */
- class BSONObjIterator {
- public:
- /** Create an iterator for a BSON object.
- */
- BSONObjIterator(const BSONObj& jso) {
- int sz = jso.objsize();
- if ( MONGO_unlikely(sz == 0) ) {
- _pos = _theend = 0;
- return;
- }
- _pos = jso.objdata() + 4;
- _theend = jso.objdata() + sz - 1;
- }
-
- BSONObjIterator( const char * start , const char * end ) {
- _pos = start + 4;
- _theend = end - 1;
- }
-
- /** @return true if more elements exist to be enumerated. */
- bool more() { return _pos < _theend; }
-
- /** @return true if more elements exist to be enumerated INCLUDING the EOO element which is always at the end. */
- bool moreWithEOO() { return _pos <= _theend; }
-
- /** @return the next element in the object. For the final element, element.eoo() will be true. */
- BSONElement next( bool checkEnd ) {
- verify( _pos <= _theend );
-
- int maxLen = -1;
- if ( checkEnd ) {
- maxLen = _theend + 1 - _pos;
- verify( maxLen > 0 );
- }
-
- BSONElement e( _pos, maxLen );
- int esize = e.size( maxLen );
- massert( 16446, "BSONElement has bad size", esize > 0 );
- _pos += esize;
-
- return e;
- }
- BSONElement next() {
- verify( _pos <= _theend );
- BSONElement e(_pos);
- _pos += e.size();
- return e;
- }
- void operator++() { next(); }
- void operator++(int) { next(); }
-
- BSONElement operator*() {
- verify( _pos <= _theend );
- return BSONElement(_pos);
- }
-
- private:
- const char* _pos;
- const char* _theend;
- };
-
- /** Base class implementing ordered iteration through BSONElements. */
- class BSONIteratorSorted {
- MONGO_DISALLOW_COPYING(BSONIteratorSorted);
- public:
- ~BSONIteratorSorted() {
- verify( _fields );
- }
-
- bool more() {
- return _cur < _nfields;
- }
-
- BSONElement next() {
- verify( _fields );
- if ( _cur < _nfields )
- return BSONElement( _fields[_cur++] );
- return BSONElement();
- }
-
- protected:
- class ElementFieldCmp;
- BSONIteratorSorted( const BSONObj &o, const ElementFieldCmp &cmp );
-
- private:
- const int _nfields;
- const boost::scoped_array<const char *> _fields;
- int _cur;
- };
-
- /** Provides iteration of a BSONObj's BSONElements in lexical field order. */
- class BSONObjIteratorSorted : public BSONIteratorSorted {
- public:
- BSONObjIteratorSorted( const BSONObj &object );
- };
-
- /**
- * Provides iteration of a BSONArray's BSONElements in numeric field order.
- * The elements of a bson array should always be numerically ordered by field name, but this
- * implementation re-sorts them anyway.
- */
- class BSONArrayIteratorSorted : public BSONIteratorSorted {
- public:
- BSONArrayIteratorSorted( const BSONArray &array );
- };
-
- /** Similar to BOOST_FOREACH
- *
- * because the iterator is defined outside of the for, you must use {} around
- * the surrounding scope. Don't do this:
- *
- * if (foo)
- * BSONForEach(e, obj)
- * doSomething(e);
- *
- * but this is OK:
- *
- * if (foo) {
- * BSONForEach(e, obj)
- * doSomething(e);
- * }
- *
- */
-
-#define BSONForEach(e, obj) \
- BSONObjIterator BOOST_PP_CAT(it_,__LINE__)(obj); \
- for ( BSONElement e; \
- (BOOST_PP_CAT(it_,__LINE__).more() ? \
- (e = BOOST_PP_CAT(it_,__LINE__).next(), true) : \
- false) ; \
- /*nothing*/ )
-
-}
diff --git a/src/mongo/bson/ordering.h b/src/mongo/bson/ordering.h
index 3a774686b51..cb21dfb22d7 100644
--- a/src/mongo/bson/ordering.h
+++ b/src/mongo/bson/ordering.h
@@ -30,7 +30,6 @@
#pragma once
#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjiterator.h"
namespace mongo {
diff --git a/src/mongo/db/fts/fts_element_iterator.h b/src/mongo/db/fts/fts_element_iterator.h
index 3ca2372d1be..17f72fff7f9 100644
--- a/src/mongo/db/fts/fts_element_iterator.h
+++ b/src/mongo/db/fts/fts_element_iterator.h
@@ -31,7 +31,6 @@
#pragma once
#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/fts/fts_language.h"
#include "mongo/db/fts/fts_spec.h"
diff --git a/src/mongo/db/global_environment_experiment.cpp b/src/mongo/db/global_environment_experiment.cpp
index ebb7b9eb21c..8981a4104a2 100644
--- a/src/mongo/db/global_environment_experiment.cpp
+++ b/src/mongo/db/global_environment_experiment.cpp
@@ -30,7 +30,7 @@
#include "mongo/db/global_environment_experiment.h"
-#include "mongo/bson/bsonobjiterator.h"
+#include "mongo/bson/bsonobj.h"
#include "mongo/db/operation_context.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/jsobj.h b/src/mongo/db/jsobj.h
index de16b723e35..83bb1d80879 100644
--- a/src/mongo/db/jsobj.h
+++ b/src/mongo/db/jsobj.h
@@ -50,7 +50,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/ordering.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/bson_db.h"
diff --git a/src/mongo/db/matcher/expression.cpp b/src/mongo/db/matcher/expression.cpp
index e4778bb75d9..99975a88815 100644
--- a/src/mongo/db/matcher/expression.cpp
+++ b/src/mongo/db/matcher/expression.cpp
@@ -30,7 +30,6 @@
#include "mongo/db/matcher/expression.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp
index 4242e6b0d2f..f0a91cffbbf 100644
--- a/src/mongo/db/matcher/expression_leaf.cpp
+++ b/src/mongo/db/matcher/expression_leaf.cpp
@@ -33,7 +33,6 @@
#include <cmath>
#include <pcrecpp.h>
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/field_ref.h"
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index 40fd48e5ea2..3564d71a907 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -33,7 +33,6 @@
#include "mongo/bson/bsonmisc.h"
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/matcher/expression_array.h"
#include "mongo/db/matcher/expression_leaf.h"
#include "mongo/db/matcher/expression_tree.h"
diff --git a/src/mongo/db/matcher/expression_parser_tree.cpp b/src/mongo/db/matcher/expression_parser_tree.cpp
index 27b2ff247a6..8e2582e52e0 100644
--- a/src/mongo/db/matcher/expression_parser_tree.cpp
+++ b/src/mongo/db/matcher/expression_parser_tree.cpp
@@ -32,7 +32,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/matcher/expression_array.h"
#include "mongo/db/matcher/expression_leaf.h"
#include "mongo/db/matcher/expression_tree.h"
diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp
index 7c63d93ead2..84c929f4c37 100644
--- a/src/mongo/db/matcher/expression_tree.cpp
+++ b/src/mongo/db/matcher/expression_tree.cpp
@@ -33,7 +33,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
namespace mongo {
diff --git a/src/mongo/db/matcher/path.h b/src/mongo/db/matcher/path.h
index 93f754d9884..4aae82af3ef 100644
--- a/src/mongo/db/matcher/path.h
+++ b/src/mongo/db/matcher/path.h
@@ -35,7 +35,6 @@
#include "mongo/base/status.h"
#include "mongo/base/string_data.h"
#include "mongo/bson/bsonobj.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/field_ref.h"
namespace mongo {
diff --git a/src/mongo/logger/parse_log_component_settings.cpp b/src/mongo/logger/parse_log_component_settings.cpp
index 0db7186464f..536a1c9cfd5 100644
--- a/src/mongo/logger/parse_log_component_settings.cpp
+++ b/src/mongo/logger/parse_log_component_settings.cpp
@@ -36,7 +36,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/logger/log_component.h"
#include "mongo/util/assert_util.h"
diff --git a/src/mongo/s/mock_ns_targeter.h b/src/mongo/s/mock_ns_targeter.h
index 205f6422263..feb07602c69 100644
--- a/src/mongo/s/mock_ns_targeter.h
+++ b/src/mongo/s/mock_ns_targeter.h
@@ -29,8 +29,8 @@
#pragma once
#include "mongo/base/owned_pointer_vector.h"
+#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/range_arithmetic.h"
#include "mongo/s/ns_targeter.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/s/write_ops/batched_command_request.cpp b/src/mongo/s/write_ops/batched_command_request.cpp
index 70bfd38327f..1dc014cb824 100644
--- a/src/mongo/s/write_ops/batched_command_request.cpp
+++ b/src/mongo/s/write_ops/batched_command_request.cpp
@@ -28,7 +28,7 @@
#include "mongo/s/write_ops/batched_command_request.h"
-#include "mongo/bson/bsonobjiterator.h"
+#include "mongo/bson/bsonobj.h"
#include "mongo/db/namespace_string.h"
namespace mongo {
diff --git a/src/mongo/util/options_parser/environment.cpp b/src/mongo/util/options_parser/environment.cpp
index 1178b6e356f..432c8735e1d 100644
--- a/src/mongo/util/options_parser/environment.cpp
+++ b/src/mongo/util/options_parser/environment.cpp
@@ -31,7 +31,6 @@
#include <iostream>
#include "mongo/bson/util/builder.h"
-#include "mongo/bson/bsonobjiterator.h"
#include "mongo/db/jsobj.h"
#include "mongo/util/options_parser/constraints.h"