use of ml.shifu.shifu.message.RunModelDataMessage in project shifu by ShifuML.
the class DataLoadWorker method splitDataIntoMultiMessages.
private long splitDataIntoMultiMessages(int streamId, int totalStreamCnt, Scanner scanner, int recordCntPerMsg) {
long recordCnt = 0;
int msgId = 0;
List<String> rawDataList = new LinkedList<String>();
while (scanner.hasNextLine()) {
String raw = scanner.nextLine();
recordCnt++;
rawDataList.add(raw);
if (recordCnt % recordCntPerMsg == 0) {
log.info("Read " + recordCnt + " Records.");
nextActorRef.tell(new RunModelDataMessage(streamId, totalStreamCnt, (++msgId), false, rawDataList), getSelf());
rawDataList = new LinkedList<String>();
}
}
log.info("Totally read " + recordCnt + " Records.");
// anyhow, sent the last message to let next actor know - it's done
nextActorRef.tell(new RunModelDataMessage(streamId, totalStreamCnt, (++msgId), true, rawDataList), getSelf());
return recordCnt;
}
use of ml.shifu.shifu.message.RunModelDataMessage in project shifu by ShifuML.
the class RunModelWorker method handleMsg.
/*
* (non-Javadoc)
*
* @see akka.actor.UntypedActor#onReceive(java.lang.Object)
*/
@Override
public void handleMsg(Object message) {
if (message instanceof RunModelDataMessage) {
RunModelDataMessage msg = (RunModelDataMessage) message;
List<String> evalDataList = msg.getEvalDataList();
List<CaseScoreResult> scoreDataList = new ArrayList<CaseScoreResult>(evalDataList.size());
for (String evalData : evalDataList) {
CaseScoreResult scoreData = calculateModelScore(evalData);
if (scoreData != null) {
scoreData.setInputData(evalData);
scoreDataList.add(scoreData);
}
}
nextActorRef.tell(new RunModelResultMessage(msg.getStreamId(), msg.getTotalStreamCnt(), msg.getMsgId(), msg.isLastMsg(), scoreDataList), getSelf());
} else {
unhandled(message);
}
}
use of ml.shifu.shifu.message.RunModelDataMessage in project shifu by ShifuML.
the class DataFilterWorker method handleMsg.
/* (non-Javadoc)
* @see ml.shifu.shifu.actor.worker.AbstractWorkerActor#handleMsg(java.lang.Object)
*/
@Override
public void handleMsg(Object message) throws Exception {
if (message instanceof StatsPartRawDataMessage) {
StatsPartRawDataMessage msg = (StatsPartRawDataMessage) message;
purifyData(msg.getRawDataList());
nextActorRef.tell(msg, getSelf());
} else if (message instanceof NormPartRawDataMessage) {
NormPartRawDataMessage msg = (NormPartRawDataMessage) message;
purifyData(msg.getRawDataList());
nextActorRef.tell(msg, getSelf());
} else if (message instanceof RunModelDataMessage) {
RunModelDataMessage msg = (RunModelDataMessage) message;
purifyData(msg.getEvalDataList());
nextActorRef.tell(msg, getSelf());
} else {
unhandled(message);
}
}
Aggregations