矩阵乘法apache猪

时间:2015-10-06 17:57:45

标签: apache-pig

我正在尝试在猪拉丁语中进行矩阵乘法。这是我到目前为止的尝试:

A = COGROUP matrix1...

然而,这不起作用。

我停了下来
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 14, column 37>  mismatched input 'matrix1' expecting LEFT_PAREN

{{1}}

1 个答案:

答案 0 :(得分:4)

经过一番游戏后,我想通了:

matrix1 = LOAD 'mat1' AS (row,col,value);
matrix2 = LOAD 'mat2' AS (row,col,value);

A = JOIN matrix1 BY column FULL OUTER, matrix2 BY row;

B = FOREACH A GENERATE matrix1::row AS m1r, matrix2::column AS m2c, (matrix1::value)*(matrix2::value) AS value;

C = GROUP B BY (m1r, m2c);

multiplied_matrices = FOREACH C GENERATE group.$0 as row, group.$1 as column, SUM(B.value) AS val;

乘法矩阵应以与输入2个矩阵相同的格式(行,列,值)返回matrix1 * matrix2的乘积。