bool bit_index_storage::put_diff(
    const bit_table_t& mixed_diff) {
  for (bit_table_t::const_iterator it = mixed_diff.begin();
      it != mixed_diff.end(); ++it) {
    if (it->second.bit_num() == 0) {
      bitvals_.erase(it->first);
    } else {
      bitvals_[it->first] = it->second;
    }
  }
  bitvals_diff_.clear();
  return true;
}
示例#2
0
bool bit_index_storage::put_diff(
    const bit_table_t& mixed_diff) {
  for (bit_table_t::const_iterator it = mixed_diff.begin();
      it != mixed_diff.end(); ++it) {
    if (it->second.bit_num() == 0) {
      // 0-bit bit_vector was propagated from other nodes.  This indicates
      // that the row should be removed globally from the master table.
      if (unlearner_) {
        unlearner_->remove(it->first);
      }
      bitvals_.erase(it->first);
    } else {
      if (unlearner_) {
        if (unlearner_->can_touch(it->first)) {
          unlearner_->touch(it->first);
        } else {
          continue;  // drop untouchable value
        }
      }
      bitvals_[it->first] = it->second;
    }
  }

  // New empty rows were created by unlearner and remove_row
  // between get_diff and put_diff
  std::vector<std::string> removed_ids;
  for (bit_table_t::const_iterator it = bitvals_diff_.begin();
      it != bitvals_diff_.end(); ++it) {
    if (it->second.bit_num() == 0) {
      bit_table_t::const_iterator pos;
      pos = mixed_diff.find(it->first);
      if (pos == mixed_diff.end() || pos->second.bit_num() != 0) {
        removed_ids.push_back(it->first);
      }
    }
  }

  bitvals_diff_.clear();

  // Keep empty rows in the diff area until next MIX to
  // propagate the removal of this data to other nodes.
  for (size_t i = 0; i < removed_ids.size(); ++i) {
    bitvals_diff_[removed_ids[i]] = bit_vector();
  }

  return true;
}
void bit_index_storage::mix(const bit_table_t& lhs, bit_table_t& rhs) const {
  for (bit_table_t::const_iterator it = lhs.begin(); it != lhs.end(); ++it) {
    rhs[it->first] = it->second;
  }
}