use of org.apache.apex.malhar.lib.testbench.EventClassifier in project apex-malhar by apache.
the class EventClassifierApp method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration conf) {
HashMap<String, Double> keymap = new HashMap<String, Double>();
keymap.put("a", 1.0);
keymap.put("b", 4.0);
keymap.put("c", 5.0);
HashMap<String, ArrayList<Integer>> wmap = new HashMap<String, ArrayList<Integer>>();
ArrayList<Integer> list = new ArrayList<Integer>(3);
list.add(60);
list.add(10);
list.add(35);
wmap.put("ia", list);
list = new ArrayList<Integer>(3);
list.add(10);
list.add(75);
list.add(15);
wmap.put("ib", list);
list = new ArrayList<Integer>(3);
list.add(20);
list.add(10);
list.add(70);
wmap.put("ic", list);
list = new ArrayList<Integer>(3);
list.add(50);
list.add(15);
list.add(35);
wmap.put("id", list);
HashMapOperator hmapOper = dag.addOperator("hmapOper", new HashMapOperator());
dag.getMeta(hmapOper).getMeta(hmapOper.hmap_data).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
EventClassifier eventClassifier = dag.addOperator("eventClassifier", new EventClassifier());
eventClassifier.setKeyMap(keymap);
eventClassifier.setOperationReplace();
eventClassifier.setKeyWeights(wmap);
dag.getMeta(eventClassifier).getMeta(eventClassifier.data).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.addStream("eventtest1", hmapOper.hmap_data, eventClassifier.event).setLocality(locality);
DevNull<HashMap<String, Double>> dev = dag.addOperator("dev", new DevNull());
dag.addStream("eventtest2", eventClassifier.data, dev.data).setLocality(locality);
}
Aggregations