Browse Source

Refs #3361. Switched sift out for new matcher.

Spencer Rathbun 12 years ago
parent
commit
9586d0a136

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

@@ -1,5 +1,5 @@
 "use strict";
-var sift = require("sift");	//TODO: DEVIATION FROM MONGO: this was a temporary hack to get this done quickly but it is too inconsistent to keep; need a real port of MatchDocumentSource
+var matcher = require("../matcher/Matcher2.js");
 
 /**
  * A match document source built off of FilterBaseDocumentSource
@@ -19,7 +19,7 @@ var MatchDocumentSource = module.exports = function MatchDocumentSource(query, c
 	if (!query) throw new Error("arg `query` is required");
 	base.call(this, ctx);
 	this.query = query; // save the query, so we can check it for deps later. THIS IS A DEVIATION FROM THE MONGO IMPLEMENTATION
-	this.matcher = sift(query);
+	this.matcher = matcher(query);
 }, klass = MatchDocumentSource, base = require('./FilterBaseDocumentSource'), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 klass.matchName = "$match";
@@ -59,7 +59,7 @@ proto.accept = function accept(document) {
 	* in here, and give that pDocument to create the created subset of
 	* fields, and then convert that instead.
 	**/
-	return this.matcher.test(document);
+	return this.matcher.matches(document);
 };
 
 /**

+ 0 - 19
lib/pipeline/matcher/IndexKeyMatchableDocument.js

@@ -6,10 +6,6 @@ var IndexKeyMatchableDocument = module.exports = function IndexKeyMatchableDocum
 	this._doc = doc;
 }, klass = IndexKeyMatchableDocument, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
-// DEPENDENCIES
-var SimpleArrayElementIterator = require('./SimpleArrayElementIterator.js'),
-	SingleElementElementIterator = require('./SingleElementElementIterator.js');
-
 // File: matcher.cpp lines: 52-52
 proto._doc = undefined;
 
@@ -47,21 +43,6 @@ proto._getElement = function _getElement(path){
 	return {};
 };
 
-/**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method getIterator
- * @param path
- *
- */
-proto.getIterator = function getIterator(path){
-	// File: matcher.cpp lines: 55-59
-	var e = this._getElement(path.fieldRef());
-	if (e instanceof Array)
-		return new SimpleArrayElementIterator( e, true );
-	return new SingleElementElementIterator( e );
-};
-
 /**
  *
  * This method returns a JSON representation of the Document