| 96 | |
| 97 | template <typename K> |
| 98 | void SharedParameter<K>::process(const MessagePtr& msg) { |
| 99 | bool req = msg->task.request(); |
| 100 | int chl = msg->task.key_channel(); |
| 101 | auto call = get(msg); |
| 102 | bool push = call.cmd() == CallSharedPara::PUSH; |
| 103 | bool pull = call.cmd() == CallSharedPara::PULL; |
| 104 | MessagePtr reply; |
| 105 | if (pull && req) { |
| 106 | reply = MessagePtr(new Message(*msg)); |
| 107 | reply->task.set_request(false); |
| 108 | std::swap(reply->sender, reply->recver); |
| 109 | } |
| 110 | |
| 111 | // this->sys_.hb().startTimer(HeartbeatInfo::TimerType::BUSY); |
| 112 | // process |
| 113 | if (call.replica()) { |
| 114 | if (pull && !req && Range<K>(msg->task.key_range()) == myKeyRange()) { |
| 115 | recoverFrom(msg); |
| 116 | } else if ((push && req) || (pull && !req)) { |
| 117 | setReplica(msg); |
| 118 | } else if (pull && req) { |
| 119 | getReplica(reply); |
| 120 | } |
| 121 | } else if (call.has_tail_filter()) { |
| 122 | if (key_filter_ignore_chl_) chl = 0; |
| 123 | auto cmd = call.tail_filter(); |
| 124 | // push the key count |
| 125 | if (cmd.insert_count() && req && !msg->key.empty()) { |
| 126 | CHECK(!msg->value.empty()); |
| 127 | auto& filter = key_filter_[chl]; |
| 128 | if (filter.empty()) { |
| 129 | double w = (double)FLAGS_num_workers; |
| 130 | filter.resize(w*cmd.countmin_n()/log(w+1), cmd.countmin_k()); |
| 131 | } |
| 132 | filter.insertKeys(SArray<K>(msg->key), SArray<uint8>(msg->value[0])); |
| 133 | } |
| 134 | // pull the filtered keys |
| 135 | if (cmd.has_query_key() && pull) { |
| 136 | if (req) { |
| 137 | reply->clearData(); |
| 138 | reply->setKey(key_filter_[chl].queryKeys( |
| 139 | SArray<K>(msg->key), cmd.query_key())); |
| 140 | if (cmd.has_query_value()) { |
| 141 | getValue(reply); |
| 142 | } |
| 143 | } else { |
| 144 | setValue(msg); |
| 145 | } |
| 146 | } |
| 147 | } else { |
| 148 | if ((push && req) || (pull && !req)) { |
| 149 | setValue(msg); |
| 150 | } else if (pull && req) { |
| 151 | getValue(reply); |
| 152 | } |
| 153 | } |
| 154 | // this->sys_.hb().stopTimer(HeartbeatInfo::TimerType::BUSY); |
| 155 |
nothing calls this directly
no test coverage detected