@Override
 public void step(IFrameTupleReference tuple) throws AlgebricksException {
   try {
     readKeyValue(tuple);
     if (!isFinalStage) {
       if (!partialAggAsInput) {
         combiner.stepPartial(key, value);
       } else {
         combiner.stepPartial2(key, value);
       }
     } else {
       combiner.stepFinal(key, value);
     }
   } catch (Exception e) {
     throw new AlgebricksException(e);
   }
 }
 private void finishInternal(IPointable result) throws AlgebricksException {
   try {
     if (!isFinalStage) {
       if (!partialAggAsInput) {
         combinedResult = combiner.finishPartial();
       } else {
         combinedResult = combiner.finishPartial2();
       }
     } else {
       combinedResult = combiner.finishFinal();
     }
     // Writes combined result.
     combinedResult.write(resultStorage.getDataOutput());
     result.set(resultStorage);
   } catch (Exception e) {
     throw new AlgebricksException(e);
   }
 }
 @Override
 public void init() throws AlgebricksException {
   combiner.init(msgList);
   resultStorage.reset();
 }