inputMatrix.put(2, vector2);
inputMatrix.put(3, vector3);
writeMatrix(matrixPath, conf, inputMatrix);
HashMap<Integer, Writable> inputVector = new HashMap<Integer, Writable>();
DenseVectorWritable vector = new DenseVectorWritable();
vector.setSize(size);
vector.addCell(0, 2);
vector.addCell(1, 3);
vector.addCell(2, 6);
vector.addCell(3, 1);
inputVector.put(0, vector);
writeMatrix(vectorPath, conf, inputVector);
SpMV.main(new String[] { matrixPath, vectorPath, outputPath, "4" });
String resultPath = SpMV.getResultPath();
DenseVectorWritable result = new DenseVectorWritable();
SpMV.readFromFile(resultPath, result, conf);
LOG.info("result is a file: " + fs.isFile(new Path(resultPath)));
double expected[] = { 38, 12, 24, 11 };
if (result.getSize() != size)
throw new Exception("Incorrect size of output vector");
for (int i = 0; i < result.getSize(); i++)
if ((result.get(i) - expected[i]) < 0.01)
expected[i] = 0;
for (int i = 0; i < expected.length; i++)
if (expected[i] != 0)
throw new Exception("Result doesn't meets expectations");