MongoDB's newmatcher

Source: Internet
Author: User
DiscussonHackerNewsMongoDB2.5.0 (anunstabledevbuild) hasa? Newimplementationofthe "Matcher". theoldmatcheristhebitofcodein=thattakesaqueryanddecidesifadocumentmatchesaqueryexpression. Italsohasto

Discuss on Hacker News MongoDB 2.5.0 (an unstable dev build) has? New implementation of the "Matcher". The old Matcher is the bit of code in Mongo that takes a query and decides if a document matches a query expression. It also has

Discuss on Hacker News

MongoDB 2.5.0 (an unstable dev build) has? New implementation of the "Matcher ". the old Matcher is the bit of code in Mongo that takes a query and decides if a document matches a query expression. it also has to understand indexes so that it can do things like create a subsets of queries suitable for index covering. however, the structure of the Matcher code hasn't changed significantly in more than four years and until this release, it lacked the ability to be easily extended. it was also structured in such a way that its knowledge cocould not be reused for query optimization. it was clearly ready for a rewrite.

The "New Matcher" in 2.5.0 is a total rewrite. it contains three separate pieces: an abstract syntax tree (hereafter 'ast ') for expression match expressions, a parser from BSON into said AST, and a Matcher API layer that simulates the old Matcher interface while using all new internals. this new version is much easier to extend, easier to reason about, and will allow us to use the same structure for matching as for query analysis and rewriting.

This matcher rewrite is part of a larger project to restructure query execution, to optimize them, and to lay the groundwork for more advanced queries in the future. one planned optimization is index intersection. for example, if you have an index on each of 'A' and 'B' attributes, we want a query of the form? {A: 5, B: 6 }? To do an index intersection of the two indexes rather than just use one index and discard the documents from that index that don't match. index intersection wocould also be suitable for merging geo-spatial, text and regular indexes together in fun and interesting ways (I. e. a query to return all the users in a 3.5 mile radius of a location with a greater than # x # reputation who are RSVP 'ed' yes 'for an event ).

A good example of an extension we 'd like to enable is self referential queries, such as finding all privileges ents where a = B + c. (This wocould be written? {A: {$ sum: ["$ B", "$ c"]}). with the new Matcher, such queries are easy to implement as a native part of the language.

Now that the Matcher re-write is ready for testing, we 'd love people to help test it by trying out MongoDB 2.5.0. (Release Notes)

Code
  • AST Root
  • Parser Root

By Eliot Horowitz, 10gen CTO, MongoDB core contributor. You can find the original post on his personal blog .?

Original article address: MongoDB's New Matcher. Thank you for sharing it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.