SlideShare a Scribd company logo
1 of 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

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

Escanear0008
Escanear0008Escanear0008
Escanear0008ojrojas
 
Leaflet hsc 36 b
Leaflet hsc 36 bLeaflet hsc 36 b
Leaflet hsc 36 bShane1977
 
.Teorias de aprendizaje en cuadro.
.Teorias de aprendizaje en cuadro..Teorias de aprendizaje en cuadro.
.Teorias de aprendizaje en cuadro.Mauricio Leonardo
 
Tarea reciclaje
Tarea reciclajeTarea reciclaje
Tarea reciclajeernesto207
 
07 a320 palace_dining
07 a320 palace_dining07 a320 palace_dining
07 a320 palace_diningwarjaborges
 
netzstrategen | Google Adwords | Überblick
netzstrategen | Google Adwords | Überblicknetzstrategen | Google Adwords | Überblick
netzstrategen | Google Adwords | Überblickstephansperling
 
շոկոլադ
շոկոլադշոկոլադ
շոկոլադGohar11
 
Xxii tacb2013 class apuramento ao regional (1)
Xxii tacb2013   class apuramento ao regional (1)Xxii tacb2013   class apuramento ao regional (1)
Xxii tacb2013 class apuramento ao regional (1)Clube Naval Maria
 
Gloria cediel actividad1_mapa_c
Gloria cediel actividad1_mapa_cGloria cediel actividad1_mapa_c
Gloria cediel actividad1_mapa_cgloriacediel
 
Blanca yineth garzon oviedo actividad 1 mapa c.pdf
Blanca yineth garzon oviedo actividad 1 mapa c.pdfBlanca yineth garzon oviedo actividad 1 mapa c.pdf
Blanca yineth garzon oviedo actividad 1 mapa c.pdfI:E Promocion Social
 
Ilk sayfalar 2
Ilk sayfalar 2Ilk sayfalar 2
Ilk sayfalar 2kamil y
 

Viewers also liked (20)

slideshare
slideshareslideshare
slideshare
 
Escanear0008
Escanear0008Escanear0008
Escanear0008
 
Leaflet hsc 36 b
Leaflet hsc 36 bLeaflet hsc 36 b
Leaflet hsc 36 b
 
.Teorias de aprendizaje en cuadro.
.Teorias de aprendizaje en cuadro..Teorias de aprendizaje en cuadro.
.Teorias de aprendizaje en cuadro.
 
Tarea reciclaje
Tarea reciclajeTarea reciclaje
Tarea reciclaje
 
Tabla de viajes
Tabla de viajesTabla de viajes
Tabla de viajes
 
Imagechef
Imagechef Imagechef
Imagechef
 
ORIGEN DEL INTERNET
ORIGEN DEL INTERNETORIGEN DEL INTERNET
ORIGEN DEL INTERNET
 
07 a320 palace_dining
07 a320 palace_dining07 a320 palace_dining
07 a320 palace_dining
 
Convivencia
ConvivenciaConvivencia
Convivencia
 
Asdasdalçsk
AsdasdalçskAsdasdalçsk
Asdasdalçsk
 
Test 2
Test 2Test 2
Test 2
 
netzstrategen | Google Adwords | Überblick
netzstrategen | Google Adwords | Überblicknetzstrategen | Google Adwords | Überblick
netzstrategen | Google Adwords | Überblick
 
շոկոլադ
շոկոլադշոկոլադ
շոկոլադ
 
Xxii tacb2013 class apuramento ao regional (1)
Xxii tacb2013   class apuramento ao regional (1)Xxii tacb2013   class apuramento ao regional (1)
Xxii tacb2013 class apuramento ao regional (1)
 
Gloria cediel actividad1_mapa_c
Gloria cediel actividad1_mapa_cGloria cediel actividad1_mapa_c
Gloria cediel actividad1_mapa_c
 
Blanca yineth garzon oviedo actividad 1 mapa c.pdf
Blanca yineth garzon oviedo actividad 1 mapa c.pdfBlanca yineth garzon oviedo actividad 1 mapa c.pdf
Blanca yineth garzon oviedo actividad 1 mapa c.pdf
 
Janet
JanetJanet
Janet
 
Adrgaerhaerh
AdrgaerhaerhAdrgaerhaerh
Adrgaerhaerh
 
Ilk sayfalar 2
Ilk sayfalar 2Ilk sayfalar 2
Ilk sayfalar 2
 

Similar to for approval

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 for approval (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 plutoone TestTwo (20)

Sam_V01.ppt
Sam_V01.pptSam_V01.ppt
Sam_V01.ppt
 
Scare at 13:59
Scare at 13:59Scare at 13:59
Scare at 13:59
 
Presentation1.PPTX
Presentation1.PPTXPresentation1.PPTX
Presentation1.PPTX
 
Presentation1.PPTX
Presentation1.PPTXPresentation1.PPTX
Presentation1.PPTX
 
Presentation1.PPTX
Presentation1.PPTXPresentation1.PPTX
Presentation1.PPTX
 
Effective_presentation.ppt
Effective_presentation.pptEffective_presentation.ppt
Effective_presentation.ppt
 
Effective_presentation.ppt
Effective_presentation.pptEffective_presentation.ppt
Effective_presentation.ppt
 
Effective_presentation.ppt
Effective_presentation.pptEffective_presentation.ppt
Effective_presentation.ppt
 
from app
from appfrom app
from app
 
example.pdf
example.pdfexample.pdf
example.pdf
 
7.2edited
7.2edited7.2edited
7.2edited
 
LAtest Doc
LAtest DocLAtest Doc
LAtest Doc
 
hello plutoone
hello plutoonehello plutoone
hello plutoone
 
plutoone channel
plutoone channelplutoone channel
plutoone channel
 
Document.docx.docx
Document.docx.docxDocument.docx.docx
Document.docx.docx
 
format.txt.txt
format.txt.txtformat.txt.txt
format.txt.txt
 
Presentation1.PPTX
Presentation1.PPTXPresentation1.PPTX
Presentation1.PPTX
 
Sample.ppt
Sample.pptSample.ppt
Sample.ppt
 
newdocument.txt
newdocument.txtnewdocument.txt
newdocument.txt
 
NetworkSecurity.ppt
NetworkSecurity.pptNetworkSecurity.ppt
NetworkSecurity.ppt
 

for approval

  • 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