use of ml.shifu.shifu.message.StatsValueObjectMessage in project shifu by ShifuML.
the class DataPrepareWorker method handleMsg.
/*
* (non-Javadoc)
*
* @see akka.actor.UntypedActor#onReceive(java.lang.Object)
*/
@Override
public void handleMsg(Object message) {
if (message instanceof StatsPartRawDataMessage) {
StatsPartRawDataMessage partData = (StatsPartRawDataMessage) message;
Map<Integer, List<ValueObject>> columnVoListMap = buildColumnVoListMap(partData.getRawDataList().size());
DataPrepareStatsResult rt = convertRawDataIntoValueObject(partData.getRawDataList(), columnVoListMap);
int totalMsgCnt = partData.getTotalMsgCnt();
for (Map.Entry<Integer, List<ValueObject>> entry : columnVoListMap.entrySet()) {
Integer columnNum = entry.getKey();
log.info("send {} with {} value object", columnNum, entry.getValue().size());
columnNumToActorMap.get(columnNum).tell(new StatsValueObjectMessage(totalMsgCnt, columnNum, entry.getValue(), rt.getMissingMap().containsKey(columnNum) ? rt.getMissingMap().get(columnNum) : 0, rt.getTotal()), getSelf());
}
} else if (message instanceof RunModelResultMessage) {
RunModelResultMessage msg = (RunModelResultMessage) message;
Map<Integer, List<ColumnScoreObject>> columnScoreListMap = buildColumnScoreListMap();
convertModelResultIntoColScore(msg.getScoreResultList(), columnScoreListMap);
int totalMsgCnt = msg.getTotalStreamCnt();
for (Entry<Integer, List<ColumnScoreObject>> column : columnScoreListMap.entrySet()) {
columnNumToActorMap.get(column.getKey()).tell(new ColumnScoreMessage(totalMsgCnt, column.getKey(), column.getValue()), getSelf());
}
} else {
unhandled(message);
}
}
use of ml.shifu.shifu.message.StatsValueObjectMessage in project shifu by ShifuML.
the class StatsCalculateWorker method handleMsg.
@Override
public void handleMsg(Object message) {
if (message instanceof StatsValueObjectMessage) {
log.debug("Received value object list for stats");
StatsValueObjectMessage statsVoMessage = (StatsValueObjectMessage) message;
voList.addAll(statsVoMessage.getVoList());
this.missing += statsVoMessage.getMissing();
this.total += statsVoMessage.getTotal();
receivedMsgCnt++;
if (receivedMsgCnt == statsVoMessage.getTotalMsgCnt()) {
log.debug("received " + receivedMsgCnt + ", start to work");
ColumnConfig columnConfig = columnConfigList.get(statsVoMessage.getColumnNum());
calculateColumnStats(columnConfig, voList);
columnConfig.setMissingCnt(this.missing);
columnConfig.setTotalCount(this.total);
columnConfig.setMissingPercentage((double) missing / total);
parentActorRef.tell(new StatsResultMessage(columnConfig), this.getSelf());
}
} else {
unhandled(message);
}
}
Aggregations