Browse Source

Refs #5124: Fix dependency calculation

Chris Sexton 11 years ago
parent
commit
1cecb97e78
2 changed files with 6 additions and 4 deletions
  1. 3 1
      lib/pipeline/PipelineD.js
  2. 3 3
      lib/pipeline/documentSources/DocumentSource.js

+ 3 - 1
lib/pipeline/PipelineD.js

@@ -42,6 +42,7 @@ klass.prepareCursorSource = function prepareCursorSource(pipeline, expCtx){
 
 	// Look for an initial simple project; we'll avoid constructing Values for fields that won't make it through the projection
 	var projection = {};
+	var dependencies;
 	var deps = {};
 	var status = DocumentSource.GetDepsReturn.SEE_NEXT;
 	for (var i=0; i < sources.length && status !== DocumentSource.GetDepsReturn.EXHAUSTIVE; i++) {
@@ -52,6 +53,7 @@ klass.prepareCursorSource = function prepareCursorSource(pipeline, expCtx){
 	}
 	if (status === DocumentSource.GetDepsReturn.EXHAUSTIVE) {
 		projection = DocumentSource.depsToProjection(deps);
+		dependencies = DocumentSource.parseDeps(deps);
 	}
 
 	// NOTE: SKIPPED: Look for an initial sort
@@ -81,7 +83,7 @@ klass.prepareCursorSource = function prepareCursorSource(pipeline, expCtx){
 
 		// NOTE: SKIPPED: Note the query and sort
 
-		if (Object.keys(projection).length) source.setProjection(projection);
+		if (Object.keys(projection).length) source.setProjection(projection, dependencies);
 
 		while(sources.length > 0 && source.coalesce(sources[0])) { //Note: Attempting to coalesce into the cursor source
 			sources.shift();

+ 3 - 3
lib/pipeline/documentSources/DocumentSource.js

@@ -237,14 +237,14 @@ proto.serializeToArray = function serializeToArray(array, explain) {
 	}
 };
 
-proto.parseDeps = function parseDeps(deps) {
+klass.parseDeps = function parseDeps(deps) {
 	var md = {};
 
 	var last,
 		depKeys = Object.keys(deps);
 	for (var i = 0; i < depKeys.length; i++) {
-		var key = depKeys[i],
-			it = deps[key];
+		var it = depKeys[i],
+			value = deps[it];
 
 		if (!last && it.indexOf(last) >= 0)
 			continue;