Jelajahi Sumber

EAGLESIX-3157: del unused reset/dispose methods

* also fixed a call to boost shared_ptr reset which just resets the pointer so we use undefined
Kyle P Davis 11 tahun lalu
induk
melakukan
9cda1e24f7

+ 5 - 5
lib/pipeline/documentSources/SortDocumentSource.js

@@ -52,7 +52,7 @@ proto.getFactory = function getFactory(){
 proto.dispose = function dispose() {
 proto.dispose = function dispose() {
 	this.docIterator = 0;
 	this.docIterator = 0;
 	this.documents = [];
 	this.documents = [];
-	this._output.reset();
+	this._output = undefined;
 	this.source.dispose();
 	this.source.dispose();
 };
 };
 
 
@@ -258,9 +258,8 @@ proto.populateFromCursors = function populateFromCursors(cursors){
 	// 	// TODO Create class
 	// 	// TODO Create class
 	// 	//this.iterators.push(boost::make_shared<IteratorFromBsonArray>(this, cursors[i]));
 	// 	//this.iterators.push(boost::make_shared<IteratorFromBsonArray>(this, cursors[i]));
 	// }
 	// }
-
-	this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
-
+	//this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
+	throw new Error("this implementation is broken"); //TODO: fix?
 };
 };
 
 
 klass.IteratorFromBsonArray = (function(){
 klass.IteratorFromBsonArray = (function(){
@@ -293,7 +292,8 @@ proto.populateFromBsonArrays = function populateFromBsonArrays(arrays){
 	// 	// TODO Create class
 	// 	// TODO Create class
 	// 	//this.iterators.push(boost::make_shared<IteratorFromBsonArray>(this, arrays[i]));
 	// 	//this.iterators.push(boost::make_shared<IteratorFromBsonArray>(this, arrays[i]));
 	// }
 	// }
-	this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
+	// this._output.reset( ); // TODO: MySorter::Iterator::merge(iterators, makeSortOptions(), Comparator(*this))
+	throw new Error("this implementation is broken"); //TODO: fix?
 };
 };
 
 
 /**
 /**

+ 0 - 10
lib/query/ArrayRunner.js

@@ -70,13 +70,3 @@ proto.getInfo = function getInfo(explain) {
 	}
 	}
 	return undefined;
 	return undefined;
 };
 };
-
-/**
- * dispose of the Runner.
- * @method reset
- */
-proto.reset = function reset(){
-	this._array = [];
-	this._position = 0;
-	this._state = Runner.RunnerState.RUNNER_DEAD;
-};

+ 0 - 10
lib/query/DocumentSourceRunner.js

@@ -81,13 +81,3 @@ proto.getInfo = function getInfo(explain) {
 	}
 	}
 	return undefined;
 	return undefined;
 };
 };
-
-/**
- * dispose of the Runner.
- * @method dispose
- */
-proto.dispose = function dispose(){
-	this._docSrc.dispose();
-	this._docSrc = undefined;
-	this._state = Runner.RunnerState.RUNNER_DEAD;
-};

+ 0 - 9
lib/query/Runner.js

@@ -211,12 +211,3 @@ proto.collection = function collection() {
 proto.getInfo = function getInfo(explain, planInfo) {
 proto.getInfo = function getInfo(explain, planInfo) {
 	throw new Error("Not implemented");
 	throw new Error("Not implemented");
 };
 };
-
-/**
- * dispose of the Runner.
- *
- * @method reset
- */
-proto.reset = function reset(){
-	throw new Error("Not implemented");
-};

+ 59 - 64
test/lib/query/ArrayRunner_test.js

@@ -4,84 +4,79 @@ var assert = require("assert"),
 	Runner = require("../../../lib/query/Runner"),
 	Runner = require("../../../lib/query/Runner"),
 	ArrayRunner = require("../../../lib/query/ArrayRunner");
 	ArrayRunner = require("../../../lib/query/ArrayRunner");
 
 
-module.exports = {
+exports.ArrayRunner = {
 
 
-	"ArrayRunner": {
-		"#constructor": {
-			"should accept an array of data": function(){
-				assert.doesNotThrow(function(){
-					new ArrayRunner([1,2,3]);
-				});
-			},
-			"should fail if not given an array": function(){
-				assert.throws(function(){
-					new ArrayRunner();
-				});
-				assert.throws(function(){
-					new ArrayRunner(123);
-				});
-			}
+	"#constructor": {
+
+		"should accept an array of data": function(){
+			assert.doesNotThrow(function(){
+				new ArrayRunner([1,2,3]);
+			});
 		},
 		},
-		"#getNext": {
-			"should return the next item in the array": function(done){
-				var ar = new ArrayRunner([1,2,3]);
 
 
+		"should fail if not given an array": function(){
+			assert.throws(function(){
+				new ArrayRunner();
+			});
+			assert.throws(function(){
+				new ArrayRunner(123);
+			});
+		}
+	},
+
+	"#getNext": {
+
+		"should return the next item in the array": function(done){
+			var ar = new ArrayRunner([1,2,3]);
+
+			ar.getNext(function(err, out, state){
+				assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
+				assert.strictEqual(out, 1);
 				ar.getNext(function(err, out, state){
 				ar.getNext(function(err, out, state){
 					assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
 					assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
-					assert.strictEqual(out, 1);
+					assert.strictEqual(out, 2);
 					ar.getNext(function(err, out, state){
 					ar.getNext(function(err, out, state){
 						assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
 						assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
-						assert.strictEqual(out, 2);
-						ar.getNext(function(err, out, state){
-							assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
-							assert.strictEqual(out, 3);
-							done();
-						});
+						assert.strictEqual(out, 3);
+						done();
 					});
 					});
 				});
 				});
-			},
-			"should return EOF if there is nothing left in the array": function(done){
-				var ar = new ArrayRunner([1]);
+			});
+		},
+
+		"should return EOF if there is nothing left in the array": function(done){
+			var ar = new ArrayRunner([1]);
 
 
+			ar.getNext(function(err, out, state){
+				assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
+				assert.strictEqual(out, 1);
 				ar.getNext(function(err, out, state){
 				ar.getNext(function(err, out, state){
-					assert.strictEqual(state, Runner.RunnerState.RUNNER_ADVANCED);
-					assert.strictEqual(out, 1);
-					ar.getNext(function(err, out, state){
-						assert.strictEqual(state, Runner.RunnerState.RUNNER_EOF);
-						assert.strictEqual(out, undefined);
-						done();
-					});
+					assert.strictEqual(state, Runner.RunnerState.RUNNER_EOF);
+					assert.strictEqual(out, undefined);
+					done();
 				});
 				});
-			}
+			});
 		},
 		},
-		"#getInfo": {
-			"should return nothing if explain flag is not set": function(){
-				var ar = new ArrayRunner([1,2,3]);
-				assert.strictEqual(ar.getInfo(), undefined);
-			},
-			"should return information about the runner if explain flag is set": function(){
-				var ar = new ArrayRunner([1,2,3]);
-				assert.deepEqual(ar.getInfo(true), {
-					"type":"ArrayRunner",
-					"nDocs":3,
-					"position":0,
-					"state": Runner.RunnerState.RUNNER_ADVANCED
-				});
-			}
+
+	},
+
+	"#getInfo": {
+
+		"should return nothing if explain flag is not set": function(){
+			var ar = new ArrayRunner([1,2,3]);
+			assert.strictEqual(ar.getInfo(), undefined);
 		},
 		},
-		"#reset": {
-			"should clear out the runner": function(){
-				var ar = new ArrayRunner([1,2,3]);
-				ar.reset();
 
 
-				assert.deepEqual(ar.getInfo(true), {
-					"type":"ArrayRunner",
-					"nDocs":0,
-					"position":0,
-					"state": Runner.RunnerState.RUNNER_DEAD
-				});
-			}
-		}
-	}
+		"should return information about the runner if explain flag is set": function(){
+			var ar = new ArrayRunner([1,2,3]);
+			assert.deepEqual(ar.getInfo(true), {
+				"type":"ArrayRunner",
+				"nDocs":3,
+				"position":0,
+				"state": Runner.RunnerState.RUNNER_ADVANCED
+			});
+		},
+
+	},
 
 
 };
 };

+ 0 - 11
test/lib/query/DocumentSourceRunner_test.js

@@ -124,15 +124,4 @@ exports.DocumentSourceRunner = {
 
 
 	},
 	},
 
 
-	"#dispose": {
-
-		"should dispose of the documentSource": function() {
-			var cds = new CursorDocumentSource(null, new ArrayRunner([1,2,3]), null),
-				pipeline = [new LimitDocumentSource({}, 1)],
-				ds = new DocumentSourceRunner(cds, pipeline);
-			ds.dispose();
-			assert.strictEqual(ds._docSrc, undefined);
-		}
-	},
-
 };
 };