summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/or.h
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-07-08 14:44:32 -0400
committerHari Khalsa <hkhalsa@10gen.com>2013-07-09 14:10:54 -0400
commitb8f0ec598013009c56dee527e76429ffa7b8c394 (patch)
treea7cf31d7fbf6bc525f4b1ded421dad8a97aed9a5 /src/mongo/db/exec/or.h
parentfedd312c424fc5f82f7be1dad13f3dd74403c4a4 (diff)
downloadmongo-b8f0ec598013009c56dee527e76429ffa7b8c394.tar.gz
SERVER-10026 fetch limit skip or
Diffstat (limited to 'src/mongo/db/exec/or.h')
-rw-r--r--src/mongo/db/exec/or.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/mongo/db/exec/or.h b/src/mongo/db/exec/or.h
new file mode 100644
index 00000000000..8df29a0c00b
--- /dev/null
+++ b/src/mongo/db/exec/or.h
@@ -0,0 +1,68 @@
+/**
+ * Copyright (C) 2013 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/>.
+ */
+
+#pragma once
+
+#include "mongo/db/diskloc.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/db/matcher.h"
+#include "mongo/db/exec/plan_stage.h"
+#include "mongo/platform/unordered_set.h"
+
+namespace mongo {
+
+ /**
+ * This stage outputs the union of its children. It optionally deduplicates on DiskLoc.
+ *
+ * Preconditions: Valid DiskLoc.
+ *
+ * If we're deduping, we may fail to dedup any invalidated DiskLoc properly.
+ */
+ class OrStage : public PlanStage {
+ public:
+ OrStage(WorkingSet* ws, bool dedup, Matcher* matcher);
+ virtual ~OrStage();
+
+ void addChild(PlanStage* child);
+
+ virtual bool isEOF();
+
+ virtual StageState work(WorkingSetID* out);
+
+ virtual void prepareToYield();
+ virtual void recoverFromYield();
+ virtual void invalidate(const DiskLoc& dl);
+
+ private:
+ // Not owned by us.
+ WorkingSet* _ws;
+
+ scoped_ptr<Matcher> _matcher;
+
+ // Owned by us.
+ vector<PlanStage*> _children;
+
+ // Which of _children are we calling work(...) on now?
+ size_t _currentChild;
+
+ // True if we dedup on DiskLoc, false otherwise.
+ bool _dedup;
+
+ // Which DiskLocs have we returned?
+ unordered_set<DiskLoc, DiskLoc::Hasher> _seen;
+ };
+
+} // namespace mongo