MCPcopy Create free account
hub / github.com/dmlc/parameter_server / add

Method add

src/data/info_parser.cc:10–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10bool InfoParser::add(const Example& ex) {
11 for (int i = 0; i < ex.slot_size(); ++i) {
12 const auto& slot = ex.slot(i);
13 if (slot.id() >= kSlotIDmax) return false;
14 auto& sinfo = slot_info_[slot.id()];
15 for (int j = 0; j < slot.key_size(); ++j) {
16 uint64 key = slot.key(j);
17 sinfo.set_min_key(std::min((uint64)sinfo.min_key(), key));
18 sinfo.set_max_key(std::max((uint64)sinfo.max_key(), key + 1));
19 }
20 if (slot.key_size() > 0) {
21 if (slot.val_size() == slot.key_size()) {
22 sinfo.set_format(SlotInfo::SPARSE);
23 } else {
24 sinfo.set_format(SlotInfo::SPARSE_BINARY);
25 }
26 } else if (slot.val_size() > 0) {
27 sinfo.set_format(SlotInfo::DENSE);
28 }
29 sinfo.set_nnz_ex(sinfo.nnz_ex() + 1);
30 sinfo.set_nnz_ele(sinfo.nnz_ele() + std::max(slot.key_size(), slot.val_size()));
31 }
32 ++ num_ex_;
33 return true;
34}
35
36ExampleInfo InfoParser::info() {
37 info_.set_num_ex(num_ex_);

Callers 3

parseExampleMethod · 0.45
readMethod · 0.45
readOneFileMethod · 0.45

Calls 14

slot_sizeMethod · 0.80
key_sizeMethod · 0.80
keyMethod · 0.80
set_min_keyMethod · 0.80
min_keyMethod · 0.80
set_max_keyMethod · 0.80
max_keyMethod · 0.80
val_sizeMethod · 0.80
set_nnz_exMethod · 0.80
nnz_exMethod · 0.80
set_nnz_eleMethod · 0.80
nnz_eleMethod · 0.80

Tested by

no test coverage detected