MCPcopy Create free account
hub / github.com/BabitMF/bmf / process

Method process

bmf/engine/c_engine/src/split_module.cpp:30–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30int SplitModule::process(Task &task) {
31 if (task.get_inputs().size() != last_input_num_) {
32 BMFLOG_NODE(BMF_DEBUG, node_id_)
33 << "Input Queue size changed from " << last_input_num_ << " to "
34 << task.get_inputs().size();
35 last_input_num_ = task.get_inputs().size();
36 if (last_input_num_ > 1) {
37 BMFLOG_NODE(BMF_ERROR, node_id_)
38 << "Input Queue size > 1 may be meet error!";
39 close();
40 }
41 }
42 if (task.get_outputs().size() != last_output_num_) {
43 BMFLOG_NODE(BMF_DEBUG, node_id_)
44 << "Output Queue size changed from " << last_output_num_ << " to "
45 << task.get_outputs().size();
46 last_output_num_ = task.get_outputs().size();
47 }
48
49 auto input_queue = task.get_inputs()[0];
50
51 // Data Splitting
52 Packet pkt;
53
54 while (task.pop_packet_from_input_queue(0, pkt)) {
55
56 if (in_eof_ == true)
57 continue;
58 // fill splitted pkt into multi output stream
59 task.fill_output_packet(stream_index_, pkt);
60 if (pkt.timestamp() == BMF_EOF) {
61 // fill eof packet for extra distributed node
62 for (size_t i = 1; i < task.get_outputs().size(); i++) {
63 task.fill_output_packet(i, Packet::generate_eof_packet());
64 }
65 in_eof_ = true;
66 }
67 BMFLOG_NODE(BMF_DEBUG, node_id_)
68 << "get packet :" << pkt.timestamp()
69 << " data:" << pkt.type_info().name
70 << " in queue:" << 0;
71
72 stream_index_ = (stream_index_ + 1) % task.get_outputs().size();
73 }
74
75 if (in_eof_)
76 task.set_timestamp(DONE);
77
78 return 0;
79}
80
81int SplitModule::reset() {
82 in_eof_ = false;

Callers 2

TESTFunction · 0.45
process_nodeMethod · 0.45

Calls 6

closeFunction · 0.85
fill_output_packetMethod · 0.80
sizeMethod · 0.45
timestampMethod · 0.45
set_timestampMethod · 0.45

Tested by 1

TESTFunction · 0.36