|
|
@@ -1,10 +1,26 @@
|
|
|
"use strict";
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
-var Matcher2 = module.exports = function (){
|
|
|
-
|
|
|
+var Matcher2 = module.exports = function (docMatcher, constrainIndexKey){
|
|
|
+ // File: matcher.cpp lines: 94-102
|
|
|
+ var indexExpression = this.spliceForIndex(constrainIndexKey, docMatcher._expression.get(), this._spliceInfo);
|
|
|
+ if (indexExpression) {
|
|
|
+ this._expression.reset(indexExpression);
|
|
|
+ }
|
|
|
}, klass = Matcher2, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
+// DEPENDENCIES
|
|
|
+var errors = require("../../Errors.js"),
|
|
|
+ ErrorCodes = errors.ErrorCodes,
|
|
|
+ MatchExpression = require("./MatchExpression.js"),
|
|
|
+ FalseMatchExpression = require("./FalseMatchExpression.js"),
|
|
|
+ ComparisonMatchExpression = require("./ComparisonMatchExpression.js"),
|
|
|
+ InMatchExpression = require("./InMatchExpression.js"),
|
|
|
+ AndMatchExpression = require("./AndMatchExpression.js"),
|
|
|
+ OrMatchExpression = require("./OrMatchExpression.js"),
|
|
|
+ IndexKeyMatchableDocument = require('./IndexKeyMatchableDocument.js'),
|
|
|
+ LeafMatchExpression = require("./LeafMatchExpression.js");
|
|
|
+
|
|
|
// File: matcher.h lines: 82-82
|
|
|
// boost.scoped_ptr<MatchExpression> _expression;
|
|
|
proto._expression = undefined;
|
|
|
@@ -37,21 +53,6 @@ proto._pattern = undefined;
|
|
|
// IndexSpliceInfo _spliceInfo;
|
|
|
proto._spliceInfo = undefined;
|
|
|
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method Matcher2
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.Matcher2 = function Matcher2(docMatcher, constrainIndexKey){
|
|
|
- // File: matcher.cpp lines: 94-102
|
|
|
- var indexExpression = this.spliceForIndex(constrainIndexKey, docMatcher._expression.get(), this._spliceInfo);
|
|
|
- if (indexExpression) {
|
|
|
- this._expression.reset(indexExpression);
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* This documentation was automatically generated. Please update when you touch this function.
|
|
|
@@ -61,6 +62,7 @@ proto.Matcher2 = function Matcher2(docMatcher, constrainIndexKey){
|
|
|
*/
|
|
|
proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
// File: matcher.cpp lines: 236-380
|
|
|
+ var dup, i, obj, lme;
|
|
|
switch (full.matchType()) {
|
|
|
case MatchExpression.ALWAYS_FALSE:
|
|
|
return new FalseMatchExpression();
|
|
|
@@ -69,13 +71,13 @@ proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
case MatchExpression.NOT:
|
|
|
case MatchExpression.NOR:
|
|
|
// maybe?
|
|
|
- return NULL;
|
|
|
+ return null;
|
|
|
|
|
|
case MatchExpression.OR:
|
|
|
|
|
|
case MatchExpression.AND:
|
|
|
- var dup = new ListOfMatchExpression();
|
|
|
- for (var i = 0; i < full.numChildren(); i++) {
|
|
|
+ dup = new ListOfMatchExpression();
|
|
|
+ for (i = 0; i < full.numChildren(); i++) {
|
|
|
var sub = this._spliceForIndex(keys, full.getChild(i), spliceInfo);
|
|
|
if (!sub)
|
|
|
continue;
|
|
|
@@ -114,12 +116,12 @@ proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
return null;
|
|
|
|
|
|
if (cmp.getRHS().Obj().isEmpty())
|
|
|
- newIn.getArrayFilterEntries().addEquality(myUndefinedElement);
|
|
|
+ newIn.getArrayFilterEntries().addEquality(undefined);
|
|
|
|
|
|
- var obj = cmp.getRHS().Obj();
|
|
|
- for(var i in obj) {
|
|
|
+ obj = cmp.getRHS().Obj();
|
|
|
+ for(i in obj) {
|
|
|
var s = newIn.getArrayFilterEntries().addEquality( obj[i].next() );
|
|
|
- if (s.code != ErrorCode.OK)
|
|
|
+ if (s.code != ErrorCodes.OK)
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -135,7 +137,7 @@ proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
case MatchExpression.LT:
|
|
|
case MatchExpression.GT:
|
|
|
case MatchExpression.GTE:
|
|
|
- var cmp = new ComparisonMatchExpression(full);
|
|
|
+ cmp = new ComparisonMatchExpression(full);
|
|
|
|
|
|
if ( cmp.getRHS().type() === null) {
|
|
|
// null and indexes don't play nice
|
|
|
@@ -146,26 +148,25 @@ proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
|
|
|
case MatchExpression.REGEX:
|
|
|
case MatchExpression.MOD:
|
|
|
- var lme = new LeafMatchExpression(full);
|
|
|
+ lme = new LeafMatchExpression(full);
|
|
|
if (!keys.count(lme.path().toString()))
|
|
|
return null;
|
|
|
return lme.shallowClone();
|
|
|
|
|
|
case MatchExpression.MATCH_IN:
|
|
|
- var lme = new LeafMatchExpression(full);
|
|
|
+ lme = new LeafMatchExpression(full);
|
|
|
if (!keys.count(lme.path().toString()))
|
|
|
return null;
|
|
|
var cloned = new InMatchExpression(lme.shallowClone());
|
|
|
if (cloned.getArrayFilterEntries().hasEmptyArray())
|
|
|
- cloned.getArrayFilterEntries().addEquality(myUndefinedElement);
|
|
|
+ cloned.getArrayFilterEntries().addEquality(undefined);
|
|
|
|
|
|
// since { $in : [[1]] } matches [1], need to explode
|
|
|
- for (var i = cloned.getArrayFilterEntries().equalities().begin(); i != cloned.getArrayFilterEntries().equalities().end(); ++i) {
|
|
|
- var x = *i;
|
|
|
+ for (i = cloned.getArrayFilterEntries().equalities().begin(); i != cloned.getArrayFilterEntries().equalities().end(); ++i) {
|
|
|
+ var x = cloned[i];
|
|
|
if (x.type() == Array) {
|
|
|
- BSONObjIterator j( x.Obj() );
|
|
|
- while ( j.more() ) {
|
|
|
- cloned.getArrayFilterEntries().addEquality( j.next() );
|
|
|
+ for(var j in x) {
|
|
|
+ cloned.getArrayFilterEntries().addEquality(x[j]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -173,7 +174,7 @@ proto._spliceForIndex = function _spliceForIndex(keys, full, spliceInfo){
|
|
|
return cloned;
|
|
|
|
|
|
case MatchExpression.ALL:
|
|
|
- // TODO: conver to $in
|
|
|
+ // TODO: convert to $in
|
|
|
return null;
|
|
|
|
|
|
case MatchExpression.ELEM_MATCH_OBJECT:
|
|
|
@@ -285,7 +286,7 @@ proto.matches = function matches(doc, details){
|
|
|
if (!doc.isEmpty() && doc.firstElement().fieldName()[0])
|
|
|
return this._expression.matchesBSON(doc, details);
|
|
|
|
|
|
- mydoc = new IndexKeyMatchableDocument(this._indexKey, doc);
|
|
|
+ var mydoc = new IndexKeyMatchableDocument(this._indexKey, doc);
|
|
|
return this._expression.matches(mydoc, details);
|
|
|
};
|
|
|
|
|
|
@@ -319,8 +320,9 @@ proto.singleSimpleCriterion = function singleSimpleCriterion(){
|
|
|
*/
|
|
|
proto.spliceForIndex = function spliceForIndex(key, full, spliceInfo){
|
|
|
// File: matcher.cpp lines: 209-217
|
|
|
- var keys = [];
|
|
|
- for (var i in key) {
|
|
|
+ var keys = [],
|
|
|
+ e, i;
|
|
|
+ for (i in key) {
|
|
|
e = key[i];
|
|
|
keys.insert(e.fieldName());
|
|
|
}
|