Hii all,

There is a mysql table with the following content.


The format of the in stream

       state:HTS
       state:HFS
       state:HTM
       state:HTS
       state:HTL
       state:HFS
       state:MTS
       state:HTS
       state:HTL
       state:MFM
       state:HTS
       state:HFS​


The following siddhi query is used to populate the above table.

----------------------------------------------------------------------------------------------------------------------

define table MarkovModel (State_Transition string, Initial_state string,
countP double) from ('datasource.name'='FD_ToolBox_DB',
'database.name'='FDtoolbox',
'table.name'='MarkovModel');

from every a = inStream -> b = inStream
select a.Event as initialState, b.Event as transState,
concat(a.Event,b.Event) as StateTransition
insert into forCalculation;

from forCalculation[((StateTransition!=MarkovModel.State_Transition)
in MarkovModel)]
select StateTransition, initialState, 1.0 as stateTrans_count
insert into insertIntoModel;


from forCalculation[((StateTransition==MarkovModel.State_Transition) in
MarkovModel)]#window.length(1) join MarkovModel
on forCalculation.StateTransition == MarkovModel.State_Transition
select StateTransition, initialState, (MarkovModel.countP+1) as
updatedState_count
insert into updateModel;

----------------------------------------------------------------------------------------------------------------------

Want to know how get the total count of *Initial_state*'s from the above
table as a continuation to the above query.

Ex: HFS - 2
      HTL - 2
      HTM - 1
      HTS - 4
      MFM - 1
      MTS - 1

Would appreciate any suggestions.

Thank you
Regards

*Supun Rasitha Muthutantrige*
Software Engineer | Intern
WSO2 Inc: http://wso2.com
lean.enterprise.middleware
Mobile: 0758374608
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to