Search in sources :

Example 1 with StatsValueObjectMessage

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);
    }
}
Also used : ColumnScoreObject(ml.shifu.shifu.container.ColumnScoreObject) StatsPartRawDataMessage(ml.shifu.shifu.message.StatsPartRawDataMessage) StatsValueObjectMessage(ml.shifu.shifu.message.StatsValueObjectMessage) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) RunModelResultMessage(ml.shifu.shifu.message.RunModelResultMessage) ColumnScoreMessage(ml.shifu.shifu.message.ColumnScoreMessage) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with StatsValueObjectMessage

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);
    }
}
Also used : ColumnConfig(ml.shifu.shifu.container.obj.ColumnConfig) StatsValueObjectMessage(ml.shifu.shifu.message.StatsValueObjectMessage) StatsResultMessage(ml.shifu.shifu.message.StatsResultMessage)

Aggregations

StatsValueObjectMessage (ml.shifu.shifu.message.StatsValueObjectMessage)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ColumnScoreObject (ml.shifu.shifu.container.ColumnScoreObject)1 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)1 ColumnScoreMessage (ml.shifu.shifu.message.ColumnScoreMessage)1 RunModelResultMessage (ml.shifu.shifu.message.RunModelResultMessage)1 StatsPartRawDataMessage (ml.shifu.shifu.message.StatsPartRawDataMessage)1 StatsResultMessage (ml.shifu.shifu.message.StatsResultMessage)1