summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/and_common-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/and_common-inl.h')
-rw-r--r--src/mongo/db/exec/and_common-inl.h99
1 files changed, 50 insertions, 49 deletions
diff --git a/src/mongo/db/exec/and_common-inl.h b/src/mongo/db/exec/and_common-inl.h
index 02956df537a..ea650a2a3ad 100644
--- a/src/mongo/db/exec/and_common-inl.h
+++ b/src/mongo/db/exec/and_common-inl.h
@@ -28,65 +28,66 @@
namespace mongo {
- class AndCommon {
- public:
- /**
- * If src has any data dest doesn't, add that data to dest.
- */
- static void mergeFrom(WorkingSetMember* dest, const WorkingSetMember& src) {
- // Both 'src' and 'dest' must have a RecordId (and they must be the same RecordId), as
- // we should have just matched them according to this RecordId while doing an
- // intersection.
- verify(dest->hasLoc());
- verify(src.hasLoc());
- verify(dest->loc == src.loc);
+class AndCommon {
+public:
+ /**
+ * If src has any data dest doesn't, add that data to dest.
+ */
+ static void mergeFrom(WorkingSetMember* dest, const WorkingSetMember& src) {
+ // Both 'src' and 'dest' must have a RecordId (and they must be the same RecordId), as
+ // we should have just matched them according to this RecordId while doing an
+ // intersection.
+ verify(dest->hasLoc());
+ verify(src.hasLoc());
+ verify(dest->loc == src.loc);
- // Merge computed data.
- typedef WorkingSetComputedDataType WSCD;
- for (WSCD i = WSCD(0); i < WSM_COMPUTED_NUM_TYPES; i = WSCD(i + 1)) {
- if (!dest->hasComputed(i) && src.hasComputed(i)) {
- dest->addComputed(src.getComputed(i)->clone());
- }
+ // Merge computed data.
+ typedef WorkingSetComputedDataType WSCD;
+ for (WSCD i = WSCD(0); i < WSM_COMPUTED_NUM_TYPES; i = WSCD(i + 1)) {
+ if (!dest->hasComputed(i) && src.hasComputed(i)) {
+ dest->addComputed(src.getComputed(i)->clone());
}
+ }
- if (dest->hasObj()) {
- // The merged WSM that we're creating already has the full document, so there's
- // nothing left to do.
- return;
- }
+ if (dest->hasObj()) {
+ // The merged WSM that we're creating already has the full document, so there's
+ // nothing left to do.
+ return;
+ }
- if (src.hasObj()) {
- // 'src' has the full document but 'dest' doesn't so we need to copy it over.
- dest->obj = src.obj;
+ if (src.hasObj()) {
+ // 'src' has the full document but 'dest' doesn't so we need to copy it over.
+ dest->obj = src.obj;
- // We have an object so we don't need key data.
- dest->keyData.clear();
+ // We have an object so we don't need key data.
+ dest->keyData.clear();
- // 'dest' should have the same state as 'src'. If 'src' has an unowned obj, then
- // 'dest' also should have an unowned obj; if 'src' has an owned obj, then dest
- // should also have an owned obj.
- dest->state = src.state;
+ // 'dest' should have the same state as 'src'. If 'src' has an unowned obj, then
+ // 'dest' also should have an unowned obj; if 'src' has an owned obj, then dest
+ // should also have an owned obj.
+ dest->state = src.state;
- // Now 'dest' has the full object. No more work to do.
- return;
- }
+ // Now 'dest' has the full object. No more work to do.
+ return;
+ }
- // If we're here, then both WSMs getting merged contain index keys. We need
- // to merge the key data.
- //
- // This is N^2 but N is probably pretty small. Easy enough to revisit.
- for (size_t i = 0; i < src.keyData.size(); ++i) {
- bool found = false;
- for (size_t j = 0; j < dest->keyData.size(); ++j) {
- if (dest->keyData[j].indexKeyPattern == src.keyData[i].indexKeyPattern) {
- found = true;
- break;
- }
+ // If we're here, then both WSMs getting merged contain index keys. We need
+ // to merge the key data.
+ //
+ // This is N^2 but N is probably pretty small. Easy enough to revisit.
+ for (size_t i = 0; i < src.keyData.size(); ++i) {
+ bool found = false;
+ for (size_t j = 0; j < dest->keyData.size(); ++j) {
+ if (dest->keyData[j].indexKeyPattern == src.keyData[i].indexKeyPattern) {
+ found = true;
+ break;
}
- if (!found) { dest->keyData.push_back(src.keyData[i]); }
+ }
+ if (!found) {
+ dest->keyData.push_back(src.keyData[i]);
}
}
- };
+ }
+};
} // namespace mongo
-