imay commented on a change in pull request #2953: [segment_v2] Switch to Unified and Extensible Page Format URL: https://github.com/apache/incubator-doris/pull/2953#discussion_r383675174
########## File path: be/src/olap/rowset/segment_v2/parsed_page.h ########## @@ -17,47 +17,88 @@ #pragma once -#include "olap/rowset/segment_v2/page_decoder.h" // for PagePointer -#include "util/rle_encoding.h" // for RleDecoder +#include <memory> + +#include "common/status.h" +#include "gen_cpp/segment_v2.pb.h" +#include "olap/rowset/segment_v2/common.h" +#include "olap/rowset/segment_v2/encoding_info.h" +#include "olap/rowset/segment_v2/options.h" +#include "olap/rowset/segment_v2/page_decoder.h" +#include "olap/rowset/segment_v2/page_handle.h" +#include "util/rle_encoding.h" namespace doris { namespace segment_v2 { -class PageHandle; -struct PagePointer; - // This contains information when one page is loaded, and ready for read // This struct can be reused, client should call reset first before reusing // this object struct ParsedPage { - ParsedPage() { } + + static Status create(PageHandle handle, + const Slice& body, + const DataPageFooterPB& footer, + const EncodingInfo* encoding, + const PagePointer& page_pointer, + uint32_t page_index, + std::unique_ptr<ParsedPage>* result) { + std::unique_ptr<ParsedPage> page(new ParsedPage); + page->page_handle = std::move(handle); + + auto null_size = footer.nullmap_size(); + page->has_null = null_size > 0; + page->null_bitmap = Slice(body.data + body.size - null_size, null_size); + + if (page->has_null) { + page->null_decoder = RleDecoder<bool>( + (const uint8_t*) page->null_bitmap.data, null_size, 1); + } + + Slice data_slice(body.data, body.size - null_size); + PageDecoderOptions opts; + RETURN_IF_ERROR(encoding->create_page_decoder(data_slice, opts, &page->data_decoder)); + RETURN_IF_ERROR(page->data_decoder->init()); + + page->first_rowid = footer.first_ordinal(); + page->num_rows = footer.num_values(); + page->page_pointer = page_pointer; + page->page_index = page_index; + + *result = std::move(page); + return Status::OK(); + } + ~ParsedPage() { delete data_decoder; } - PagePointer page_pointer; PageHandle page_handle; + bool has_null; Slice null_bitmap; RleDecoder<bool> null_decoder; PageDecoder* data_decoder = nullptr; // first rowid for this page - rowid_t first_rowid = 0; - + ordinal_t first_rowid = 0; Review comment: If this type is changed to ordinal_t, is it better to change name to `first_oid`? ---------------------------------------------------------------- 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: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org