Mapper & Reducer Program using Aggregation Framework of MongoDB

Mapper & Reducer Program using Aggregation Framework of MongoDB

Hello everyone, hope all are doing good. In this article I will be explaining a bit about MongoDB & its Aggregation Framework , then we'll see how the Mapper Reducer program can be created using that...

What is MongoDB ?

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need. MongoDB’s document model is simple for developers to learn and use, while still providing all the capabilities needed to meet the most complex requirements at any scale.

Some of the Features of MongoDB are :

  1. MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time.
  2. The document model maps to the objects in your application code, making data easy to work with.
  3. Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data.
  4. MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use.
  5. MongoDB is free to use.?

What is Aggregation Framework in Mongo ?

In MongoDB, aggregation operations process the data records/documents and return computed results. It collects values from various documents and groups them together and then performs different types of operations on that grouped data like sum, average, minimum, maximum, etc to return a computed result.

Here is an example of simple MongoDB.

No alt text provided for this image

MongoDB provides three ways to perform aggregation

  • Aggregation pipeline
  • Map-reduce function
  • Single-purpose aggregation

Now let's have a look as Aggregation Pipeline :

No alt text provided for this image

In MongoDB, the aggregation pipeline consists of stages and each stage transforms the document. Or in other words, the aggregation pipeline is a multi-stage pipeline, so in each state, the documents taken as input and produce the resultant set of documents now in the next stage(id available) the resultant documents taken as input and produce output, this process is going on till the last stage. The basic pipeline stages provide filters that will perform like queries and the document transformation modifies the resultant document and the other pipeline provides tools for grouping and sorting documents. You can also use the aggregation pipeline in sharded collection.

Now let's use Aggregation Framework & create Mapper Reducer program...

No alt text provided for this image

That's all Guys !! We have seen how to use Aggregation Framework for Mapper & Reducer Program.

Thank You???


要查看或添加评论,请登录

Krushna Prasad Sahoo的更多文章

社区洞察