SlideShare a Scribd company logo
1 of 1
Download to read offline
db.runCommand({
mapreduce: "DenormAggCollection",
query: {
filter1: { '$in': [ 'A', 'B' ] },
filter2: 'C',
filter3: { '$gt': 123 }
},
map: function() { emit(
{ d1: this.Dim1, d2: this.Dim2 },
{ msum: this.measure1, recs: 1, mmin: this.measure1,
mmax: this.measure2 < 100 ? this.measure2 : 0 }
);},
reduce: function(key, vals) {
var ret = { msum: 0, recs: 0, mmin: 0, mmax: 0 };
for(var i = 0; i < vals.length; i++) {
ret.msum += vals[i].msum;
ret.recs += vals[i].recs;
if(vals[i].mmin < ret.mmin) ret.mmin = vals[i].mmin;
if((vals[i].mmax < 100) && (vals[i].mmax > ret.mmax))
ret.mmax = vals[i].mmax;
}
return ret;
},
finalize: function(key, val) {
val.mavg = val.msum / val.recs;
return val;
},
out: 'result1',
verbose: true
});
db.result1.
find({ mmin: { '$gt': 0 } }).
sort({ recs: -1 }).
skip(4).
limit(8);
SELECT
Dim1, Dim2,
SUM(Measure1) AS MSum,
COUNT(*) AS RecordCount,
AVG(Measure2) AS MAvg,
MIN(Measure1) AS MMin
MAX(CASE
WHEN Measure2 < 100
THEN Measure2
END) AS MMax
FROM DenormAggTable
WHERE (Filter1 IN (’A’,’B’))
AND (Filter2 = ‘C’)
AND (Filter3 > 123)
GROUP BY Dim1, Dim2
HAVING (MMin > 0)
ORDER BY RecordCount DESC
LIMIT 4, 8
1
2
3
4
5
1
7
6
1
2
3
4
5
Grouped dimension columns are pulled
out as keys in the map function,
reducing the size of the working set.
Measures must be manually aggregated.
Aggregates depending on record counts
must wait until finalization.
Measures can use procedural logic.
Filters have an ORM/ActiveRecord-
looking style.
6 Aggregate filtering must be applied to
the result set, not in the map/reduce.
7 Ascending: 1; Descending: -1
Revision4,Created2010-03-06
RickOsborne,rickosborne.org
mySQL MongoDB

More Related Content

What's hot

Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileKushagraChadha1
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Denpong Soodphakdee
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package ExamplesDr. Volkan OBAN
 
Using Petri Net Invariants in State Space Construction
Using Petri Net Invariants in State Space ConstructionUsing Petri Net Invariants in State Space Construction
Using Petri Net Invariants in State Space ConstructionUniversität Rostock
 
Programming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EESProgramming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EESNaveed Rehman
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 

What's hot (16)

Script jantung copy
Script jantung   copyScript jantung   copy
Script jantung copy
 
Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
 
OLS gradient descent
OLS gradient descentOLS gradient descent
OLS gradient descent
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package Examples
 
Gradient
GradientGradient
Gradient
 
Using Petri Net Invariants in State Space Construction
Using Petri Net Invariants in State Space ConstructionUsing Petri Net Invariants in State Space Construction
Using Petri Net Invariants in State Space Construction
 
Programming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EESProgramming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EES
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
R
RR
R
 
CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...
CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...
CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...
 

Viewers also liked

καπνισμα
καπνισμακαπνισμα
καπνισμαxpapas
 
Selección española de fútbol
Selección española de fútbolSelección española de fútbol
Selección española de fútbolMarialoveMurcia
 
υπνος και οδοντικη φροντιδα
υπνος και οδοντικη φροντιδαυπνος και οδοντικη φροντιδα
υπνος και οδοντικη φροντιδαxpapas
 
λογοι χρησησ
λογοι χρησησλογοι χρησησ
λογοι χρησησxpapas
 
Definiciones basicas relacionadas con el beneficio del ganado
Definiciones basicas relacionadas con el beneficio del ganadoDefiniciones basicas relacionadas con el beneficio del ganado
Definiciones basicas relacionadas con el beneficio del ganadoAlejita Carbonero
 
υγιεινός τρόπος ζωής Project 2012 13
υγιεινός τρόπος ζωής Project 2012 13υγιεινός τρόπος ζωής Project 2012 13
υγιεινός τρόπος ζωής Project 2012 13xpapas
 
Laporan akhir
Laporan akhirLaporan akhir
Laporan akhircy950605
 
CRM. Внутренние планы, цели и автоматизация лидогенерации
CRM. Внутренние планы, цели и автоматизация лидогенерацииCRM. Внутренние планы, цели и автоматизация лидогенерации
CRM. Внутренние планы, цели и автоматизация лидогенерацииM.C.Art
 
Hine Automation Corporate Presentation - SC - 2014-04-24
Hine Automation Corporate Presentation - SC - 2014-04-24Hine Automation Corporate Presentation - SC - 2014-04-24
Hine Automation Corporate Presentation - SC - 2014-04-24Todd Smith
 
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...Antony Upward
 
Convite - Formatura Kheas
Convite - Formatura KheasConvite - Formatura Kheas
Convite - Formatura KheasKheas CardOso
 
P.P.P. HOW TO EXPORT A PRODUCT
P.P.P. HOW TO EXPORT A PRODUCTP.P.P. HOW TO EXPORT A PRODUCT
P.P.P. HOW TO EXPORT A PRODUCTAngela Palacio
 
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...Khoaairblade
 
April 5, 2016: Colorado Coach Connection
April 5, 2016: Colorado Coach ConnectionApril 5, 2016: Colorado Coach Connection
April 5, 2016: Colorado Coach ConnectionICF Colorado
 

Viewers also liked (20)

καπνισμα
καπνισμακαπνισμα
καπνισμα
 
Selección española de fútbol
Selección española de fútbolSelección española de fútbol
Selección española de fútbol
 
υπνος και οδοντικη φροντιδα
υπνος και οδοντικη φροντιδαυπνος και οδοντικη φροντιδα
υπνος και οδοντικη φροντιδα
 
λογοι χρησησ
λογοι χρησησλογοι χρησησ
λογοι χρησησ
 
2
22
2
 
Catalyst
CatalystCatalyst
Catalyst
 
Definiciones basicas relacionadas con el beneficio del ganado
Definiciones basicas relacionadas con el beneficio del ganadoDefiniciones basicas relacionadas con el beneficio del ganado
Definiciones basicas relacionadas con el beneficio del ganado
 
υγιεινός τρόπος ζωής Project 2012 13
υγιεινός τρόπος ζωής Project 2012 13υγιεινός τρόπος ζωής Project 2012 13
υγιεινός τρόπος ζωής Project 2012 13
 
Laporan akhir
Laporan akhirLaporan akhir
Laporan akhir
 
CRM. Внутренние планы, цели и автоматизация лидогенерации
CRM. Внутренние планы, цели и автоматизация лидогенерацииCRM. Внутренние планы, цели и автоматизация лидогенерации
CRM. Внутренние планы, цели и автоматизация лидогенерации
 
La república
La repúblicaLa república
La república
 
Un mundo feliz
Un mundo felizUn mundo feliz
Un mundo feliz
 
Hine Automation Corporate Presentation - SC - 2014-04-24
Hine Automation Corporate Presentation - SC - 2014-04-24Hine Automation Corporate Presentation - SC - 2014-04-24
Hine Automation Corporate Presentation - SC - 2014-04-24
 
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...
An Ontology for Strongly Sustainable Business Models - O&E - Upward & Jones (...
 
Convite - Formatura Kheas
Convite - Formatura KheasConvite - Formatura Kheas
Convite - Formatura Kheas
 
Pentru Dani
Pentru DaniPentru Dani
Pentru Dani
 
P.P.P. HOW TO EXPORT A PRODUCT
P.P.P. HOW TO EXPORT A PRODUCTP.P.P. HOW TO EXPORT A PRODUCT
P.P.P. HOW TO EXPORT A PRODUCT
 
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...
David Beckham mới vừa tậu 5 căn Sunview Towm, Bạn có muốn làm hàng xóm với an...
 
Post from channel 123
Post from channel 123Post from channel 123
Post from channel 123
 
April 5, 2016: Colorado Coach Connection
April 5, 2016: Colorado Coach ConnectionApril 5, 2016: Colorado Coach Connection
April 5, 2016: Colorado Coach Connection
 

Similar to Staging post

Sql to-mongo db
Sql to-mongo dbSql to-mongo db
Sql to-mongo dbLouis liu
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...Revolution Analytics
 
Cdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupCdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupchristkv
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)MongoSF
 
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDBCDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDBAreski Belaid
 
Groovy collection api
Groovy collection apiGroovy collection api
Groovy collection apitrygvea
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»e-Legion
 
Bicubic interpolation codes
Bicubic interpolation codesBicubic interpolation codes
Bicubic interpolation codesmmjalbiaty
 
Day 4a iteration and functions.pptx
Day 4a   iteration and functions.pptxDay 4a   iteration and functions.pptx
Day 4a iteration and functions.pptxAdrien Melquiond
 
school-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfschool-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfashishkum805
 
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction Arulalan T
 
intro-to-metaprogramming-in-r.pdf
intro-to-metaprogramming-in-r.pdfintro-to-metaprogramming-in-r.pdf
intro-to-metaprogramming-in-r.pdfK. Matthew Dupree
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用iammutex
 

Similar to Staging post (20)

Sql to Mongodb
Sql to MongodbSql to Mongodb
Sql to Mongodb
 
Sql to-mongo db
Sql to-mongo dbSql to-mongo db
Sql to-mongo db
 
Sql to-mongo db
Sql to-mongo dbSql to-mongo db
Sql to-mongo db
 
RHadoop の紹介
RHadoop の紹介RHadoop の紹介
RHadoop の紹介
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
 
Cdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupCdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetup
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
 
CLUSTERGRAM
CLUSTERGRAMCLUSTERGRAM
CLUSTERGRAM
 
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDBCDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB
CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB
 
Groovy collection api
Groovy collection apiGroovy collection api
Groovy collection api
 
Vcs9
Vcs9Vcs9
Vcs9
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»Юрий Буянов «Squeryl — ORM с человеческим лицом»
Юрий Буянов «Squeryl — ORM с человеческим лицом»
 
Bicubic interpolation codes
Bicubic interpolation codesBicubic interpolation codes
Bicubic interpolation codes
 
Day 4a iteration and functions.pptx
Day 4a   iteration and functions.pptxDay 4a   iteration and functions.pptx
Day 4a iteration and functions.pptx
 
C programs
C programsC programs
C programs
 
school-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfschool-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdf
 
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
 
intro-to-metaprogramming-in-r.pdf
intro-to-metaprogramming-in-r.pdfintro-to-metaprogramming-in-r.pdf
intro-to-metaprogramming-in-r.pdf
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
 

More from Bhavani Testone

More from Bhavani Testone (20)

good one cloning the message
good one 
cloning the messagegood one 
cloning the message
good one cloning the message
 
notification
notificationnotification
notification
 
without CF
without CFwithout CF
without CF
 
03DOM.ppt
03DOM.ppt03DOM.ppt
03DOM.ppt
 
Empty:d-1:05
Empty:d-1:05Empty:d-1:05
Empty:d-1:05
 
Std10-Maths-EM-1.pdf
Std10-Maths-EM-1.pdfStd10-Maths-EM-1.pdf
Std10-Maths-EM-1.pdf
 
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
 
Tales-29th
Tales-29thTales-29th
Tales-29th
 
New text document-29th
New text document-29thNew text document-29th
New text document-29th
 
uPoGPpb.ppt
uPoGPpb.pptuPoGPpb.ppt
uPoGPpb.ppt
 
Reporting & Analytics.pdf
Reporting & Analytics.pdfReporting & Analytics.pdf
Reporting & Analytics.pdf
 
Tales
TalesTales
Tales
 
Puzzles to puzzle you
Puzzles to puzzle youPuzzles to puzzle you
Puzzles to puzzle you
 
New text document
New text documentNew text document
New text document
 
1
11
1
 
1.txt
1.txt1.txt
1.txt
 
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
http---cdata.nqa.sprinklr.com-DAM-5-2010blast-100530124747-Blast-cc20d154-5e0...
 
Presentation_NEW.PPTX
Presentation_NEW.PPTXPresentation_NEW.PPTX
Presentation_NEW.PPTX
 
HTML_Basics.pdf
HTML_Basics.pdfHTML_Basics.pdf
HTML_Basics.pdf
 
Presentation_NEW.PPTX
Presentation_NEW.PPTXPresentation_NEW.PPTX
Presentation_NEW.PPTX
 

Staging post

  • 1. db.runCommand({ mapreduce: "DenormAggCollection", query: { filter1: { '$in': [ 'A', 'B' ] }, filter2: 'C', filter3: { '$gt': 123 } }, map: function() { emit( { d1: this.Dim1, d2: this.Dim2 }, { msum: this.measure1, recs: 1, mmin: this.measure1, mmax: this.measure2 < 100 ? this.measure2 : 0 } );}, reduce: function(key, vals) { var ret = { msum: 0, recs: 0, mmin: 0, mmax: 0 }; for(var i = 0; i < vals.length; i++) { ret.msum += vals[i].msum; ret.recs += vals[i].recs; if(vals[i].mmin < ret.mmin) ret.mmin = vals[i].mmin; if((vals[i].mmax < 100) && (vals[i].mmax > ret.mmax)) ret.mmax = vals[i].mmax; } return ret; }, finalize: function(key, val) { val.mavg = val.msum / val.recs; return val; }, out: 'result1', verbose: true }); db.result1. find({ mmin: { '$gt': 0 } }). sort({ recs: -1 }). skip(4). limit(8); SELECT Dim1, Dim2, SUM(Measure1) AS MSum, COUNT(*) AS RecordCount, AVG(Measure2) AS MAvg, MIN(Measure1) AS MMin MAX(CASE WHEN Measure2 < 100 THEN Measure2 END) AS MMax FROM DenormAggTable WHERE (Filter1 IN (’A’,’B’)) AND (Filter2 = ‘C’) AND (Filter3 > 123) GROUP BY Dim1, Dim2 HAVING (MMin > 0) ORDER BY RecordCount DESC LIMIT 4, 8 1 2 3 4 5 1 7 6 1 2 3 4 5 Grouped dimension columns are pulled out as keys in the map function, reducing the size of the working set. Measures must be manually aggregated. Aggregates depending on record counts must wait until finalization. Measures can use procedural logic. Filters have an ORM/ActiveRecord- looking style. 6 Aggregate filtering must be applied to the result set, not in the map/reduce. 7 Ascending: 1; Descending: -1 Revision4,Created2010-03-06 RickOsborne,rickosborne.org mySQL MongoDB