kangpinghuang commented on a change in pull request #516: Modify compaction code to be adapted to Rowset interface URL: https://github.com/apache/incubator-doris/pull/516#discussion_r246374495
########## File path: be/src/olap/tablet.cpp ########## @@ -105,56 +105,101 @@ bool Tablet::can_do_compaction() { return true; } -OLAPStatus Tablet::capture_consistent_versions( - const Version& version, vector<Version>* span_versions) const { - OLAPStatus status = _rs_graph->capture_consistent_versions(version, span_versions); - if (status != OLAP_SUCCESS) { - LOG(WARNING) << "fail to generate shortest version path. tablet=" << full_name() - << ", version='" << version.first << "-" << version.second; +OLAPStatus Tablet::compute_all_versions_hash(const vector<Version>& versions, + VersionHash* version_hash) const { + DCHECK(version_hash != nullptr) << "invalid parameter, version_hash is nullptr"; + + int64_t v_hash = 0L; + for (auto version : versions) { + auto it = _rs_version_map.find(version); + if (it == _rs_version_map.end()) { + LOG(WARNING) << "fail to find Rowset. " + << "version=" << version.first << "-" << version.second; + return OLAP_ERR_TABLE_VERSION_INDEX_MISMATCH_ERROR; + } + v_hash ^= it->second->version_hash(); } - return status; + *version_hash = v_hash; + return OLAP_SUCCESS; } OLAPStatus Tablet::capture_consistent_rowsets(const Version& spec_version, - vector<std::shared_ptr<RowsetReader>>* rs_readers) { + vector<RowsetSharedPtr>* rowsets) const { vector<Version> version_path; _rs_graph->capture_consistent_versions(spec_version, &version_path); - acquire_rs_reader_by_version(version_path, rs_readers); + capture_consistent_rowsets(version_path, rowsets); return OLAP_SUCCESS; } -void Tablet::acquire_rs_reader_by_version(const vector<Version>& version_vec, - vector<std::shared_ptr<RowsetReader>>* rs_readers) const { - DCHECK(rs_readers != NULL && rs_readers->empty()); - for (auto version : version_vec) { - auto it2 = _rs_version_map.find(version); - if (it2 == _rs_version_map.end()) { +OLAPStatus Tablet::capture_consistent_rowsets(const vector<Version>& version_path, + vector<RowsetSharedPtr>* rowsets) const { + DCHECK(rowsets != nullptr && rowsets->empty()); + for (auto version : version_path) { + auto it = _rs_version_map.find(version); Review comment: auto -> auto&? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org