gaodayue commented on a change in pull request #1718: Basic implementation for BetaRowsetReader URL: https://github.com/apache/incubator-doris/pull/1718#discussion_r318894791
########## File path: be/src/olap/rowset/beta_rowset.cpp ########## @@ -40,19 +41,51 @@ OLAPStatus BetaRowset::init() { if (is_inited()) { return OLAP_SUCCESS; } - // TODO init segment readers + for (int seg_id = 0; seg_id < num_segments(); ++seg_id) { + std::string seg_path = segment_file_path(_rowset_path, rowset_id(), seg_id); + _segments.emplace_back(new segment_v2::Segment(seg_path, seg_id, _schema)); + } set_inited(true); return OLAP_SUCCESS; } +// `use_cache` is ignored because beta rowset doesn't support fd cache now OLAPStatus BetaRowset::load(bool use_cache) { - // TODO load segment footers + // DCHECK(is_inited()) << "should init() rowset " << unique_id() << " before load()"; + // TODO remove the following if block when rowset is guaranteed to be initialized + if (!is_inited()) { + OLAPStatus res = init(); + if (res != OLAP_SUCCESS) { + LOG(WARNING) << "failed to init rowset before load" + << " rowset id " << rowset_id(); + return res; + } + } + if (is_loaded()) { + return OLAP_SUCCESS; + } + for (auto& seg : _segments) { + auto s = seg->open(); + if (!s.ok()) { + LOG(WARNING) << "failed to open segment " << seg->id() << " under rowset " << unique_id() + << " : " << s.to_string(); + return OLAP_ERR_ROWSET_LOAD_FAILED; + } + } + set_loaded(true); return OLAP_SUCCESS; } -std::shared_ptr<RowsetReader> BetaRowset::create_reader() { - // TODO return BetaRowsetReader or RowwiseIterator? - return nullptr; +RowsetReaderSharedPtr BetaRowset::create_reader() { Review comment: OK, I'll return OLAPStatus since rowset level classes are still use OLAPStatus instead of Status. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to 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