瀏覽代碼

EAGLESIX-3087: Initial edits to Pipeline.js

Jason Walton 11 年之前
父節點
當前提交
5ff512ca18
共有 1 個文件被更改,包括 35 次插入0 次删除
  1. 35 0
      lib/pipeline/Pipeline.js

+ 35 - 0
lib/pipeline/Pipeline.js

@@ -423,3 +423,38 @@ proto.writeExplainOps = function writeExplainOps() {
 proto.addInitialSource = function addInitialSource(source) {
 	this.sources.unshift(source);
 };
+
+//SKIPPED: canRunInMongos
+
+proto.getDependencies = function getDependencies (initialQuery) {
+    var deps, knowAllFields = false;
+
+    //NOTE: Deviation from Mongo -- We aren't using Meta and textscore
+    for (var i=0; i < sources.length() && !knowAllFields; i++) {
+        var localDeps,
+        	status = sources[i].getDependencies(localDeps);
+
+        if (status == DocumentSource.GetDepsReturn.NOT_SUPPORTED) {
+            // Assume this stage needs everything. We may still know something about our
+            // dependencies if an earlier stage returned either EXHAUSTIVE_FIELDS or
+            // EXHAUSTIVE_META.
+            break;
+        }
+
+        if (!knowAllFields) {
+            //C++ insert this range: deps.fields.insert(localDeps.fields.begin(), localDeps.fields.end());
+        	for (var j = 0; j < localDeps.fields.length; j++) {
+        		deps.fields[localDeps.fields[i].fieldName] = localDeps.fields[i];
+        	}
+            if (localDeps.needWholeDocument)
+                deps.needWholeDocument = true;
+            knowAllFields = status & DocumentSource.GetDepsReturn.EXHAUSTIVE_FIELDS;
+        }
+
+    }
+
+    if (!knowAllFields)
+        deps.needWholeDocument = true; // don't know all fields we need
+
+    return deps;
+};