summaryrefslogtreecommitdiff
path: root/src/mongo/bson/util/bsoncolumnbuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/bson/util/bsoncolumnbuilder.cpp')
-rw-r--r--src/mongo/bson/util/bsoncolumnbuilder.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/bson/util/bsoncolumnbuilder.cpp b/src/mongo/bson/util/bsoncolumnbuilder.cpp
index 3a77fdbd83c..9156b56a5f4 100644
--- a/src/mongo/bson/util/bsoncolumnbuilder.cpp
+++ b/src/mongo/bson/util/bsoncolumnbuilder.cpp
@@ -360,7 +360,17 @@ BSONColumnBuilder& BSONColumnBuilder::append(BSONElement elem) {
BSONColumnBuilder& BSONColumnBuilder::skip() {
if (_mode == Mode::kRegular) {
_state.skip();
- } else if (_mode == Mode::kSubObjDeterminingReference) {
+ return *this;
+ }
+
+ // If the reference object contain any empty subobjects we need to end interleaved mode as
+ // skipping in all substreams would not be encoded as skipped root object.
+ if (_hasEmptyObj(_referenceSubObj)) {
+ _flushSubObjMode();
+ return skip();
+ }
+
+ if (_mode == Mode::kSubObjDeterminingReference) {
_bufferedObjElements.push_back(BSONObj());
} else {
for (auto&& state : _subobjStates) {