private void processBinaryCombineInstruction(CombineBinaryInstruction ins, Reporter reporter) throws IOException { IndexedMatrixValue in1 = cachedValues.getFirst(ins.input1); IndexedMatrixValue in2 = cachedValues.getFirst(ins.input2); if (in1 == null && in2 == null) return; MatrixIndexes indexes; if (in1 != null) indexes = in1.getIndexes(); else indexes = in2.getIndexes(); // if one of the inputs is null, then it is a all zero block if (in1 == null) { in1 = zeroInput; in1.getValue().reset(in2.getValue().getNumRows(), in2.getValue().getNumColumns()); } if (in2 == null) { in2 = zeroInput; in2.getValue().reset(in1.getValue().getNumRows(), in1.getValue().getNumColumns()); } // System.out.println("in1:"+in1); // System.out.println("in2:"+in2); // process instruction try { /*in1.getValue().combineOperations(in2.getValue(), collectFinalMultipleOutputs, reporter, keyBuff, valueBuff, getOutputIndexes(ins.output));*/ ArrayList<Integer> outputIndexes = outputIndexesMapping.get(ins.output); for (int r = 0; r < in1.getValue().getNumRows(); r++) for (int c = 0; c < in1.getValue().getNumColumns(); c++) { Pair<Integer, Integer> blockSize = outputBlockSizes.get(ins.output); keyBuff.setIndexes( UtilFunctions.cellIndexCalculation(indexes.getRowIndex(), blockSize.getKey(), r), UtilFunctions.cellIndexCalculation( indexes.getColumnIndex(), blockSize.getValue(), c)); valueBuff.setValue(in1.getValue().getValue(r, c)); double temp = in2.getValue().getValue(r, c); if (ins.isSecondInputWeight()) { valueBuff.setWeight(temp); valueBuff.setOtherValue(0); } else { valueBuff.setWeight(1); valueBuff.setOtherValue(temp); } for (int i : outputIndexes) { collectFinalMultipleOutputs.collectOutput(keyBuff, valueBuff, i, reporter); // System.out.println("output: "+keyBuff+" -- "+valueBuff); } } } catch (Exception e) { throw new RuntimeException(e); } }
private void processTernaryCombineInstruction(CombineTernaryInstruction ins, Reporter reporter) throws IOException { IndexedMatrixValue in1 = cachedValues.getFirst(ins.input1); IndexedMatrixValue in2 = cachedValues.getFirst(ins.input2); IndexedMatrixValue in3 = cachedValues.getFirst(ins.input3); if (in1 == null && in2 == null && in3 == null) return; int nr = 0, nc = 0; if (in1 != null) { nr = in1.getValue().getNumRows(); nc = in1.getValue().getNumColumns(); } else if (in2 != null) { nr = in2.getValue().getNumRows(); nc = in2.getValue().getNumColumns(); } else { nr = in3.getValue().getNumRows(); nc = in3.getValue().getNumColumns(); } // if one of the inputs is null, then it is a all zero block if (in1 == null) { in1 = zeroInput; in1.getValue().reset(nr, nc); } if (in2 == null) { in2 = zeroInput; in2.getValue().reset(nr, nc); } if (in3 == null) { in3 = zeroInput; in3.getValue().reset(nr, nc); } // process instruction try { ArrayList<Integer> outputIndexes = outputIndexesMapping.get(ins.output); for (int r = 0; r < nr; r++) for (int c = 0; c < nc; c++) { Pair<Integer, Integer> blockSize = outputBlockSizes.get(ins.output); keyBuff.setIndexes( UtilFunctions.cellIndexCalculation( in1.getIndexes().getRowIndex(), blockSize.getKey(), r), UtilFunctions.cellIndexCalculation( in1.getIndexes().getColumnIndex(), blockSize.getValue(), c)); valueBuff.setValue(in1.getValue().getValue(r, c)); valueBuff.setOtherValue(in2.getValue().getValue(r, c)); valueBuff.setWeight(in3.getValue().getValue(r, c)); for (int i : outputIndexes) { collectFinalMultipleOutputs.collectOutput(keyBuff, valueBuff, i, reporter); // System.out.println("output: "+keyBuff+" -- "+valueBuff); } } } catch (Exception e) { throw new RuntimeException(e); } }