0% found this document useful (0 votes)
6 views2 pages

Mapreduce

this is mangoDB program of TE computer subject:DBMS

Uploaded by

kajal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Mapreduce

this is mangoDB program of TE computer subject:DBMS

Uploaded by

kajal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DBMS : MapReduce

db.students.insertMany([
{ "Name": "Nobita", "Department": "Physics", "Age": 20 },
{ "Name": "Doraemon", "Department": "Engineering", "Age": 21 },
{ "Name": "Shizuka", "Department": "Physics", "Age": 22 },
{ "Name": "Suneo", "Department": "Mathematics", "Age": 21 },
{ "Name": "Gian", "Department": "Mathematics", "Age": 23 }
])

{
acknowledged: true,
insertedIds: {
'0': ObjectId('671349485d2b31fff5dfb1e1'),
'1': ObjectId('671349485d2b31fff5dfb1e2'),
'2': ObjectId('671349485d2b31fff5dfb1e3'),
'3': ObjectId('671349485d2b31fff5dfb1e4'),
'4': ObjectId('671349485d2b31fff5dfb1e5')
}
}

db.Map.find()
{
_id: ObjectId('671349485d2b31fff5dfb1e1'),
Name: 'Nobita',
Department: 'Physics',
Age: 20
}
{
_id: ObjectId('671349485d2b31fff5dfb1e2'),
Name: 'Doraemon',
Department: 'Engineering',
Age: 21
}
{
_id: ObjectId('671349485d2b31fff5dfb1e3'),
Name: 'Shizuka',
Department: 'Physics',
Age: 22
}
{
_id: ObjectId('671349485d2b31fff5dfb1e4'),
Name: 'Suneo',
Department: 'Mathematics',
Age: 21
}
{
_id: ObjectId('671349485d2b31fff5dfb1e5'),
Name: 'Gian',
Department: 'Mathematics',
Age: 23
}
db.students.mapReduce(
function() { emit(this.Department, 1); }, // Map function
function(key, values) { return Array.sum(values); }, // Reduce function
{
out: "department_count" // Output collection
}
)
{ result: 'department_count', ok: 1 }
db.department_count.find()
{
_id: 'Physics',
value: 2
}
{
_id: 'Mathematics',
value: 2
}
{
_id: 'Engineering',
value: 1
}

You might also like