Kaynağa Gözat

EAGLESIX-812: fixed issues with getDependencies in Pipeline

Phil Murray 11 yıl önce
ebeveyn
işleme
682f931116
1 değiştirilmiş dosya ile 12 ekleme ve 9 silme
  1. 12 9
      lib/pipeline/Pipeline.js

+ 12 - 9
lib/pipeline/Pipeline.js

@@ -26,7 +26,8 @@ var DocumentSource = require("./documentSources/DocumentSource"),
 	OutDocumentSource = require('./documentSources/OutDocumentSource'),
 	GeoNearDocumentSource = require('./documentSources/GeoNearDocumentSource'),
 	RedactDocumentSource = require('./documentSources/RedactDocumentSource'),
-	SortDocumentSource = require('./documentSources/SortDocumentSource');
+	SortDocumentSource = require('./documentSources/SortDocumentSource'),
+	DepsTracker = require('./DepsTracker');
 
 klass.COMMAND_NAME = "aggregate";
 klass.PIPELINE_NAME = "pipeline";
@@ -523,17 +524,18 @@ proto.addInitialSource = function addInitialSource(source) {
 //SKIPPED: canRunInMongos
 
 proto.getDependencies = function getDependencies (initialQuery) {
-    var deps, knowAllFields = false;
+    var deps = new DepsTracker(), 
+		knowAllFields = false;
 
-    if (this.sources == null || this.sources.length == 0)
+    if (this.sources === null || this.sources.length === 0)
     	return {};
 
     //NOTE: Deviation from Mongo -- We aren't using Meta and textscore
-    for (var i=0; i < this.sources.length() && !knowAllFields; i++) {
-        var localDeps,
-        	status = sources[i].getDependencies(localDeps);
+    for (var i=0; i < this.sources.length && !knowAllFields; i++) {
+        var localDeps = new DepsTracker(),
+        	status = this.sources[i].getDependencies(localDeps);
 
-        if (status == DocumentSource.GetDepsReturn.NOT_SUPPORTED) {
+        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.
@@ -542,8 +544,9 @@ proto.getDependencies = function getDependencies (initialQuery) {
 
         if (!knowAllFields) {
             //C++ insert this range: deps.fields.insert(localDeps.fields.begin(), localDeps.fields.end());
-        	for (var j = 0; j < localDeps.fields.keys.length; j++) {
-        		var key = localDeps.fields.keys[i];
+            var keys = Object.keys(localDeps.fields);
+        	for (var j = 0; j < keys.length; j++) {
+        		var key = keys[j];
         		deps.fields[key] = localDeps.fields[key];
         	}
             if (localDeps.needWholeDocument)