large-scale sorting (5 novembre 2014) Tri de 100 To de données Hadoop MR : 72 minutes avec 2100 noeuds (50400 cores) Spark : 23 minutes avec 206 noeuds (6592 cores) 7 / 37
Exemples : map() : une valeur → une valeur mapToPair() : une valeur → un tuple filter() : filtre les valeurs/tuples groupByKey() : regroupe la valeurs par clés reduceByKey() : aggrège les valeurs par clés join(), cogroup()... : jointure entre deux RDD 13 / 37
: compte les valeurs/tuples saveAsHadoopFile() : sauve les résultats au format Hadoop foreach() : exécute une fonction sur chaque valeur/tuple collect() : récupère les valeurs dans une liste (List< T >) 14 / 37
(framework) Découpage des fragments par lignes (framework) Découpage des lignes en mots (map) Comptage des mots (reduce) Sur chaque noeud Puis sur un noeud pour le résultat final 16 / 37
F i l e ( " s o m e / t e x t / f i l e s / * " ) . f l a t M a p ( l i n e - > A r r a y s . a s L i s t ( l i n e . s p l i t ( " \ \ W " ) ) ) . m a p T o P a i r ( w o r d - > n e w T u p l e 2 < S t r i n g , I n t e g e r > ( w o r d , 1 ) ) . r e d u c e B y K e y ( ( x , y ) - > x + y ) . c o l l e c t ( ) ; 18 / 37
- s h e l l > v a r l i n e s = s c . t e x t F i l e ( " . . . / d a t a / a r b r e s a l i g n e m e n t p a r i s 2 0 1 0 . c s v " ) > l i n e s . c o u n t ( ) > v a r t r e e s = l i n e s . f i l t e r ( s = > ! s . s t a r t s W i t h ( " g e o m " ) ) > v a r t r e e s S p l i t = t r e e s . m a p ( l i n e = > l i n e . s p l i t ( " ; " ) ) > v a r h e i g h t s = t r e e s S p l i t . m a p ( f i e l d s = > f i e l d s ( 3 ) . t o F l o a t ) > h e i g h t s = h e i g h t s . f i l t e r ( h = > h > 0 ) > h e i g h t s . s u m ( ) / h e i g h t s . c o u n t ( ) 20 / 37
O M E / s b i n / s t a r t - m a s t e r . s h $ $ S P A R K _ H O M E / b i n / s p a r k - c l a s s o r g . a p a c h e . s p a r k . d e p l o y . w o r k e r . W o r k e r s p a r k : / / M B P - d e - A l e x i s : 7 0 7 7 - - c o r e s 2 - - m e m o r y 2 G $ m v n c l e a n p a c k a g e $ $ S P A R K _ H O M E / b i n / s p a r k - s u b m i t - - m a s t e r s p a r k : / / M B P - d e - A l e x i s : 7 0 7 7 - - c l a s s c o m . s e i g n e u r i n . s p a r k . W i k i p e d i a M a p R e d u c e B y K e y - - d e p l o y - m o d e c l u s t e r t a r g e t / p r e s - s p a r k - 0 . 0 . 1 - S N A P S H O T . j a r 28 / 37
D E L E T E l o c a l h o s t : 9 2 0 0 $ c u r l - X P U T l o c a l h o s t : 9 2 0 0 / s p a r k / _ m a p p i n g / t w e e t s ' { " t w e e t s " : { " p r o p e r t i e s " : { " u s e r " : { " t y p e " : " s t r i n g " , " i n d e x " : " n o t _ a n a l y z e d " } , " t e x t " : { " t y p e " : " s t r i n g " } , " c r e a t e d A t " : { " t y p e " : " d a t e " , " f o r m a t " : " d a t e _ t i m e " } , " l a n g u a g e " : { " t y p e " : " s t r i n g " , " i n d e x " : " n o t _ a n a l y z e d " } } } } ' Lancer Kibana http://localhost:5601 Lancer le traitement 36 / 37