mapreduce w mongodb

21
MapReduce w MongoDB Krzysztof Parjaszewski, Gliwice SPUG vol.2, 20 września 2012

Upload: krzysztof-parjaszewski

Post on 13-Jul-2015

1.007 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MapReduce w MongoDB

MapReduce w MongoDB

Krzysztof Parjaszewski, GliwiceSPUG vol.2, 20 września 2012

Page 2: MapReduce w MongoDB

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

Page 3: MapReduce w MongoDB
Page 4: MapReduce w MongoDB

źródło: blog.nahurst.com

Page 5: MapReduce w MongoDB

źródło: blog.nahurst.com

Page 6: MapReduce w MongoDB

źródło: blog.nahurst.com

Page 7: MapReduce w MongoDB

źródło: blog.nahurst.com

Page 8: MapReduce w MongoDB

not ONLY SQL

http://nosql-database.org/

Page 9: MapReduce w MongoDB

Subiektywnie o MongoDB

Przechowuje dokumenty(kontrprzykład to Magento i 300 tabel) MapReduce

brak full text search

Page 10: MapReduce w MongoDB

MapReduceczyli

map() + reduce()

Page 11: MapReduce w MongoDB

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()

Page 12: MapReduce w MongoDB

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()

Page 13: MapReduce w MongoDB

Złożoność??

Page 14: MapReduce w MongoDB

Złożoność~~ 2 pętle

Page 15: MapReduce w MongoDB

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

Page 16: MapReduce w MongoDB
Page 17: MapReduce w MongoDB

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});

}

}

Page 18: MapReduce w MongoDB

reduce

reduce = function (key, values) {

wynik = {kod:key, liczba:0};

values.forEach( function (value) { wynik.liczba += value.liczba; });

return wynik;

}

Page 19: MapReduce w MongoDB
Page 20: MapReduce w MongoDB

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/

Page 21: MapReduce w MongoDB

Pytania?

[email protected]