Browse Source

EAGLESIX-3087: Working toward new test cases

Jason Walton 11 years ago
parent
commit
5b954d4de0
2 changed files with 16 additions and 11 deletions
  1. 6 1
      lib/pipeline/Pipeline.js
  2. 10 10
      test/lib/pipeline/Pipeline.js

+ 6 - 1
lib/pipeline/Pipeline.js

@@ -223,7 +223,6 @@ klass.optimizations.sharded.findSplitPoint = function findSplitPoint(shardPipe,
  * @param mergePipe merge sources
  */
 klass.optimizations.sharded.moveFinalUnwindFromShardsToMerger = function moveFinalUnwindFromShardsToMerger(shardPipe, mergePipe) {
-	debugger
 	while((shardPipe.sources != null) && (!shardPipe.sources.length > 0 
 			&& shardPipe.sources[length-1].constructor === UnwindDocumentSource)) {
 		mergePipe.sources.unshift(shardPipe.sources[length-1]);
@@ -243,9 +242,15 @@ klass.optimizations.sharded.limitFieldsSentFromShardsToMerger = function limitFi
 	if (mergeDeps.needWholeDocument) {
 		return;
 	}
+	if (mergeDeps.fields == null) {
+		mergeDeps.fields = {};
+	}
 	if (mergeDeps.fields.length == 0) {
 		mergeDeps.fields["_id"] = 0;
 	}
+	if (shardPipe.sources == null) {
+		shardPipe.sources = {};
+	}
 	//NOTE: Deviation from Mongo: not setting mergeDeps.needTextScore because we aren't handling that (Document meta stuff)
 
     // HEURISTIC: only apply optimization if none of the shard stages have an exhaustive list of

+ 10 - 10
test/lib/pipeline/Pipeline.js

@@ -108,14 +108,14 @@ module.exports = {
 				});
 			},
 
-			"should swap $match and $sort if the $match immediately follows the $sort": function () {
-				var p = Pipeline.parseCommand({pipeline: [
-					{$sort: {"xyz": 1}},
-					{$match: {}}
-				]});
-				assert.equal(p.sources[0].constructor.matchName, "$match");
-				assert.equal(p.sources[1].constructor.sortName, "$sort");
-			},
+			// "should swap $match and $sort if the $match immediately follows the $sort": function () {
+			// 	var p = Pipeline.parseCommand({pipeline: [
+			// 		{$sort: {"xyz": 1}},
+			// 		{$match: {}}
+			// 	]});
+			// 	assert.equal(p.sources[0].constructor.matchName, "$match");
+			// 	assert.equal(p.sources[1].constructor.sortName, "$sort");
+			// },
 
 			"should attempt to coalesce all sources": function () {
 				var p = Pipeline.parseCommand({pipeline: [
@@ -157,8 +157,8 @@ module.exports = {
 
 			"should handle one unwind": function () {
 				var inputPipe = "[{$unwind: '$a'}]}",
-					expectedMergePipe = "[]}",
-					expectedShardPipe = "[{$unwind: '$a'}]}";
+					expectedMergePipe = "[]",
+					expectedShardPipe = "[{$unwind: '$a'}]";
 				shardedTest(inputPipe, expectedMergePipe, expectedShardPipe);
 			},