1
8.4kviews
Show Map Reduce implementation for the following two tasks using pseudocode. i) Multiplication of two matrices ii) Computing Group-by and aggregation of a relational table
2 Answers
0
760views
  • Let A and B be the two metrics to be multiplied and result be matrix C.

  • Matrix A has dimension L, M and matrix . has dimension M, N

- Map phase.

  • For each element (i, j) of A, emit ( ( i, k), A [i, j] ) for K in 1,......N

  • For each element (j , k) of B, emit ( (j, k) , B[j, k) for j in 1,.....L

- Reduce phase.

In reduce phase emit

key (i, k)

value = sum j ( A [i, i] * B [j, k])

  • One reducer is used per output cell.

  • each reducer computes

sym j ( A [ i, j * B ( [ j, k])

  • The block diagram of two stage map reduce multiplication algorithm can be shown as follows:

enter image description here

  • Pseudo-code for the algorithm is as follows:

map (key values)

for ( i, k aij) in valve:

emit (i, aij * v [j] )

reduce (key values)

result = 0

for valve in values:

result + = valve

emit (key, result)

Please log in to add an answer.