Matcher2.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. "use strict"
  2. // Autogenerated by cport.py on 2013-09-17 14:37
  3. var Matcher2 = module.exports = function (){
  4. }, klass = Matcher2, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  5. // File: matcher.h lines: 82-82
  6. // boost::scoped_ptr<MatchExpression> _expression;
  7. proto._expression = undefined;
  8. // File: matcher.h lines: 80-80
  9. // BSONObj _indexKey;
  10. proto._indexKey = undefined;
  11. // File: matcher.h lines: 79-79
  12. // BSONObj _pattern;
  13. proto._pattern = undefined;
  14. // File: matcher.h lines: 84-84
  15. // IndexSpliceInfo _spliceInfo;
  16. proto._spliceInfo = undefined;
  17. // File: matcher.h lines: 82-82
  18. // boost::scoped_ptr<MatchExpression> _expression;
  19. proto._expression = undefined;
  20. // File: matcher.h lines: 80-80
  21. // BSONObj _indexKey;
  22. proto._indexKey = undefined;
  23. // File: matcher.h lines: 79-79
  24. // BSONObj _pattern;
  25. proto._pattern = undefined;
  26. // File: matcher.h lines: 84-84
  27. // IndexSpliceInfo _spliceInfo;
  28. proto._spliceInfo = undefined;
  29. /**
  30. *
  31. * This documentation was automatically generated. Please update when you touch this function.
  32. * @method Matcher2
  33. * @param
  34. *
  35. */
  36. proto.Matcher2 = function Matcher2( /* const Matcher2 &docMatcher, const BSONObj &constrainIndexKey */ ){
  37. // File: matcher.cpp lines: 94-102
  38. // Matcher2::Matcher2( const Matcher2 &docMatcher, const BSONObj &constrainIndexKey )
  39. // : _indexKey( constrainIndexKey ) {
  40. //
  41. // MatchExpression* indexExpression = spliceForIndex( constrainIndexKey,
  42. // docMatcher._expression.get(),
  43. // &_spliceInfo );
  44. // if ( indexExpression ) {
  45. // _expression.reset( indexExpression );
  46. // }
  47. // }
  48. }
  49. /**
  50. *
  51. * This documentation was automatically generated. Please update when you touch this function.
  52. * @method _spliceForIndex
  53. * @param
  54. *
  55. */
  56. proto._spliceForIndex = function _spliceForIndex( /* const set<string>& keys,$/;" */ ){
  57. // File: matcher.cpp lines: 236-380
  58. // MatchExpression* Matcher2::_spliceForIndex( const set<string>& keys,
  59. // const MatchExpression* full,
  60. // Matcher2::IndexSpliceInfo* spliceInfo ) {
  61. //
  62. // switch ( full->matchType() ) {
  63. // case MatchExpression::ALWAYS_FALSE:
  64. // return new FalseMatchExpression();
  65. //
  66. // case MatchExpression::GEO_NEAR:
  67. // case MatchExpression::NOT:
  68. // case MatchExpression::NOR:
  69. // // maybe?
  70. // return NULL;
  71. //
  72. // case MatchExpression::OR:
  73. //
  74. // case MatchExpression::AND: {
  75. // auto_ptr<ListOfMatchExpression> dup;
  76. // for ( unsigned i = 0; i < full->numChildren(); i++ ) {
  77. // MatchExpression* sub = _spliceForIndex( keys, full->getChild( i ), spliceInfo );
  78. // if ( !sub )
  79. // continue;
  80. // if ( !dup.get() ) {
  81. // if ( full->matchType() == MatchExpression::AND )
  82. // dup.reset( new AndMatchExpression() );
  83. // else
  84. // dup.reset( new OrMatchExpression() );
  85. // }
  86. // dup->add( sub );
  87. // }
  88. // if ( dup.get() ) {
  89. // if ( full->matchType() == MatchExpression::OR &&
  90. // dup->numChildren() != full->numChildren() ) {
  91. // // TODO: I think this should actuall get a list of all the fields
  92. // // and make sure that's the same
  93. // // with an $or, have to make sure its all or nothing
  94. // return NULL;
  95. // }
  96. // return dup.release();
  97. // }
  98. // return NULL;
  99. // }
  100. //
  101. // case MatchExpression::EQ: {
  102. // const ComparisonMatchExpression* cmp =
  103. // static_cast<const ComparisonMatchExpression*>( full );
  104. //
  105. // if ( cmp->getRHS().type() == Array ) {
  106. // // need to convert array to an $in
  107. //
  108. // if ( !keys.count( cmp->path().toString() ) )
  109. // return NULL;
  110. //
  111. // auto_ptr<InMatchExpression> newIn( new InMatchExpression() );
  112. // newIn->init( cmp->path() );
  113. //
  114. // if ( newIn->getArrayFilterEntries()->addEquality( cmp->getRHS() ).isOK() )
  115. // return NULL;
  116. //
  117. // if ( cmp->getRHS().Obj().isEmpty() )
  118. // newIn->getArrayFilterEntries()->addEquality( myUndefinedElement );
  119. //
  120. // BSONObjIterator i( cmp->getRHS().Obj() );
  121. // while ( i.more() ) {
  122. // Status s = newIn->getArrayFilterEntries()->addEquality( i.next() );
  123. // if ( !s.isOK() )
  124. // return NULL;
  125. // }
  126. //
  127. // return newIn.release();
  128. // }
  129. // else if ( cmp->getRHS().type() == jstNULL ) {
  130. // //spliceInfo->hasNullEquality = true;
  131. // return NULL;
  132. // }
  133. // }
  134. //
  135. // case MatchExpression::LTE:
  136. // case MatchExpression::LT:
  137. // case MatchExpression::GT:
  138. // case MatchExpression::GTE: {
  139. // const ComparisonMatchExpression* cmp =
  140. // static_cast<const ComparisonMatchExpression*>( full );
  141. //
  142. // if ( cmp->getRHS().type() == jstNULL ) {
  143. // // null and indexes don't play nice
  144. // //spliceInfo->hasNullEquality = true;
  145. // return NULL;
  146. // }
  147. // }
  148. // case MatchExpression::REGEX:
  149. // case MatchExpression::MOD: {
  150. // const LeafMatchExpression* lme = static_cast<const LeafMatchExpression*>( full );
  151. // if ( !keys.count( lme->path().toString() ) )
  152. // return NULL;
  153. // return lme->shallowClone();
  154. // }
  155. //
  156. // case MatchExpression::MATCH_IN: {
  157. // const LeafMatchExpression* lme = static_cast<const LeafMatchExpression*>( full );
  158. // if ( !keys.count( lme->path().toString() ) )
  159. // return NULL;
  160. // InMatchExpression* cloned = static_cast<InMatchExpression*>(lme->shallowClone());
  161. // if ( cloned->getArrayFilterEntries()->hasEmptyArray() )
  162. // cloned->getArrayFilterEntries()->addEquality( myUndefinedElement );
  163. //
  164. // // since { $in : [[1]] } matches [1], need to explode
  165. // for ( BSONElementSet::const_iterator i = cloned->getArrayFilterEntries()->equalities().begin();
  166. // i != cloned->getArrayFilterEntries()->equalities().end();
  167. // ++i ) {
  168. // const BSONElement& x = *i;
  169. // if ( x.type() == Array ) {
  170. // BSONObjIterator j( x.Obj() );
  171. // while ( j.more() ) {
  172. // cloned->getArrayFilterEntries()->addEquality( j.next() );
  173. // }
  174. // }
  175. // }
  176. //
  177. // return cloned;
  178. // }
  179. //
  180. // case MatchExpression::ALL:
  181. // // TODO: conver to $in
  182. // return NULL;
  183. //
  184. // case MatchExpression::ELEM_MATCH_OBJECT:
  185. // case MatchExpression::ELEM_MATCH_VALUE:
  186. // // future
  187. // return NULL;
  188. //
  189. // case MatchExpression::GEO:
  190. // case MatchExpression::SIZE:
  191. // case MatchExpression::EXISTS:
  192. // case MatchExpression::NIN:
  193. // case MatchExpression::TYPE_OPERATOR:
  194. // case MatchExpression::ATOMIC:
  195. // case MatchExpression::WHERE:
  196. // // no go
  197. // return NULL;
  198. //
  199. //
  200. // }
  201. //
  202. // return NULL;
  203. // }
  204. }
  205. /**
  206. *
  207. * This documentation was automatically generated. Please update when you touch this function.
  208. * @method atomic
  209. * @param
  210. *
  211. */
  212. proto.atomic = function atomic( /* */ ){
  213. // File: matcher.cpp lines: 120-133
  214. // bool Matcher2::atomic() const {
  215. // if ( !_expression )
  216. // return false;
  217. //
  218. // if ( _expression->matchType() == MatchExpression::ATOMIC )
  219. // return true;
  220. //
  221. // // we only go down one level
  222. // for ( unsigned i = 0; i < _expression->numChildren(); i++ ) {
  223. // if ( _expression->getChild( i )->matchType() == MatchExpression::ATOMIC )
  224. // return true;
  225. // }
  226. //
  227. // return false;
  228. // }
  229. }
  230. /**
  231. *
  232. * This documentation was automatically generated. Please update when you touch this function.
  233. * @method getQuery
  234. * @param
  235. *
  236. */
  237. proto.getQuery = function getQuery( /* */ ){
  238. // File: matcher.h lines: 65-64
  239. // const BSONObj* getQuery() const { return &_pattern; };
  240. }
  241. /**
  242. *
  243. * This documentation was automatically generated. Please update when you touch this function.
  244. * @method hasExistsFalse
  245. * @param
  246. *
  247. */
  248. proto.hasExistsFalse = function hasExistsFalse( /* */ ){
  249. // File: matcher.cpp lines: 172-180
  250. // bool Matcher2::hasExistsFalse() const {
  251. // if ( _spliceInfo.hasNullEquality ) {
  252. // // { a : NULL } is very dangerous as it may not got indexed in some cases
  253. // // so we just totally ignore
  254. // return true;
  255. // }
  256. //
  257. // return _isExistsFalse( _expression.get(), false,
  258. // _expression->matchType() == MatchExpression::AND ? -1 : 0 );
  259. // }
  260. }
  261. /**
  262. *
  263. * This documentation was automatically generated. Please update when you touch this function.
  264. * @method keyMatch
  265. * @param
  266. *
  267. */
  268. proto.keyMatch = function keyMatch( /* const Matcher2 &docMatcher */ ){
  269. // File: matcher.cpp lines: 199-206
  270. // bool Matcher2::keyMatch( const Matcher2 &docMatcher ) const {
  271. // if ( !_expression )
  272. // return docMatcher._expression.get() == NULL;
  273. // if ( !docMatcher._expression )
  274. // return false;
  275. // if ( _spliceInfo.hasNullEquality )
  276. // return false;
  277. // return _expression->equivalent( docMatcher._expression.get() );
  278. // }
  279. }
  280. /**
  281. *
  282. * This documentation was automatically generated. Please update when you touch this function.
  283. * @method matches
  284. * @param
  285. *
  286. */
  287. proto.matches = function matches( /* const BSONObj& doc, MatchDetails* details */ ){
  288. // File: matcher.cpp lines: 105-116
  289. // bool Matcher2::matches(const BSONObj& doc, MatchDetails* details ) const {
  290. // if ( !_expression )
  291. // return true;
  292. //
  293. // if ( _indexKey.isEmpty() )
  294. // return _expression->matchesBSON( doc, details );
  295. //
  296. // if ( !doc.isEmpty() && doc.firstElement().fieldName()[0] )
  297. // return _expression->matchesBSON( doc, details );
  298. //
  299. // IndexKeyMatchableDocument mydoc( _indexKey, doc );
  300. // return _expression->matches( &mydoc, details );
  301. // }
  302. }
  303. /**
  304. *
  305. * This documentation was automatically generated. Please update when you touch this function.
  306. * @method singleSimpleCriterion
  307. * @param
  308. *
  309. */
  310. proto.singleSimpleCriterion = function singleSimpleCriterion( /* */ ){
  311. // File: matcher.cpp lines: 184-196
  312. // bool Matcher2::singleSimpleCriterion() const {
  313. // if ( !_expression )
  314. // return false;
  315. //
  316. // if ( _expression->matchType() == MatchExpression::EQ )
  317. // return true;
  318. //
  319. // if ( _expression->matchType() == MatchExpression::AND &&
  320. // _expression->numChildren() == 1 &&
  321. // _expression->getChild(0)->matchType() == MatchExpression::EQ )
  322. // return true;
  323. //
  324. // return false;
  325. // }
  326. }
  327. /**
  328. *
  329. * This documentation was automatically generated. Please update when you touch this function.
  330. * @method spliceForIndex
  331. * @param
  332. *
  333. */
  334. proto.spliceForIndex = function spliceForIndex( /* const BSONObj& key,$/;" */ ){
  335. // File: matcher.cpp lines: 209-217
  336. // MatchExpression* Matcher2::spliceForIndex( const BSONObj& key,
  337. // const MatchExpression* full,
  338. // Matcher2::IndexSpliceInfo* spliceInfo ) {
  339. // set<string> keys;
  340. // for ( BSONObjIterator i(key); i.more(); ) {
  341. // BSONElement e = i.next();
  342. // keys.insert( e.fieldName() );
  343. // }
  344. // return _spliceForIndex( keys, full, spliceInfo );
  345. // }
  346. }
  347. /**
  348. *
  349. * This documentation was automatically generated. Please update when you touch this function.
  350. * @method toString
  351. * @param
  352. *
  353. */
  354. proto.toString = function toString( /* */ ){
  355. // File: matcher.h lines: 66-65
  356. // std::string toString() const { return _pattern.toString(); }
  357. }