| 91 | |
| 92 | template<typename V> |
| 93 | void StreamReader<V>::parseExample(const Example& ex, int num_read) { |
| 94 | if (examples_) examples_->push_back(ex); |
| 95 | if (!matrices_) return; |
| 96 | if (!info_parser_.add(ex)) return; |
| 97 | // store them in slots |
| 98 | for (int i = 0; i < ex.slot_size(); ++i) { |
| 99 | const auto& slot = ex.slot(i); |
| 100 | CHECK_LT(slot.id(), kSlotIDmax); |
| 101 | auto& vslot = vslots_[slot.id()]; |
| 102 | int key_size = slot.key_size(); |
| 103 | for (int j = 0; j < key_size; ++j) vslot.col_idx.pushBack(slot.key(j)); |
| 104 | int val_size = slot.val_size(); |
| 105 | for (int j = 0; j < val_size; ++j) { |
| 106 | vslot.val.pushBack(slot.val(j)); |
| 107 | } |
| 108 | while (vslot.row_siz.size() < num_read) vslot.row_siz.pushBack(0); |
| 109 | vslot.row_siz.pushBack(std::max(key_size, val_size)); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | template<typename V> |
| 114 | void StreamReader<V>::fillMatrices() { |