MapReduce w MongoDB
-
Upload
krzysztof-parjaszewski -
Category
Documents
-
view
1.007 -
download
0
Transcript of MapReduce w MongoDB
MapReduce w MongoDB
Krzysztof Parjaszewski, GliwiceSPUG vol.2, 20 września 2012
O mnie
w branży od 2006 roku, Gliwice i Wrocław
Prowadzę skygate.pl (software house),współtworzę sellekt.pl (agencja interaktywna).
http://www.goldenline.pl/krzysztof-parjaszewski
źródło: blog.nahurst.com
źródło: blog.nahurst.com
źródło: blog.nahurst.com
źródło: blog.nahurst.com
not ONLY SQL
http://nosql-database.org/
Subiektywnie o MongoDB
Przechowuje dokumenty(kontrprzykład to Magento i 300 tabel) MapReduce
brak full text search
MapReduceczyli
map() + reduce()
map (_id, object) → [(key, value)]
Przykład:
function() {
emit( this.kingdomName, {count: 1, inhabitants: this.inhabitants} );
}
Złożoność:O(#key) * średnia złożoność 1 wykonania map()
reduce (key, values) → resultPrzykład:
function(key, values) {
var result = { kingdomName: key, kingdomInhabitants: 0
}
values.forEach(function(value) {
result.kingdomInhabitants += value.inhabitants;
});
return result;
}
Złożoność:O(#values) * średnia złożoność 1 wykonania reduce()
Złożoność??
Złożoność~~ 2 pętle
Przykład: http://stat.gov.pl/
Okres sprawozdawczy: Dane roczne
Kategoria:SZKOLNICTWO WYŻSZE
Grupa: STUDENCI I ABSOLWENCI
Podgrupa: Studenci i absolwenci wg typów szkół, trybu nauczania, płci i kierunku studiów
Wymiary: Grupy osób, Typy szkół , Tryby nauczania , Płeć, Grupy kierunków studiów , Lata
Ostatnia aktualizacja: 2012-04-16
mapmap = function () {
if (this['Jednostka terytorialna'].indexOf("gliwic") != -1 ||
this['Jednostka terytorialna'].indexOf("bytom") != -1) {
emit(this.Kod, {liczba:this.pedagogiczne});
emit(this.Kod, {liczba:this.humanistyczne});
emit(this.Kod, {liczba:this.artystyczne});
emit(this.Kod, {liczba:this.spoleczne});
emit(this.Kod, {liczba:this.prawne});
}
}
reduce
reduce = function (key, values) {
wynik = {kod:key, liczba:0};
values.forEach( function (value) { wynik.liczba += value.liczba; });
return wynik;
}
NoSQL Summer in 27 cities
A seasonal, worldwide reading club for databases, distributed systems & NOSQL-related scientific papers.
Currently featuring 1054 participants in 39 cities, from 20 different countries on 5 continents.
139 meetings (and counting) since June 3, 2010!
http://nosqlsummer.org/
Pytania?