0
1.1kviews
Matrix Multiplication using MR
1 Answer
written 2.6 years ago by |
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])
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)