kangkaisen commented on a change in pull request #1818: Add frame_of_reference page URL: https://github.com/apache/incubator-doris/pull/1818#discussion_r328003626
########## File path: be/src/olap/rowset/segment_v2/frame_of_reference_page.h ########## @@ -0,0 +1,165 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "olap/rowset/segment_v2/page_builder.h" // for PageBuilder +#include "olap/rowset/segment_v2/page_decoder.h" // for PageDecoder +#include "olap/rowset/segment_v2/options.h" // for PageBuilderOptions/PageDecoderOptions +#include "olap/rowset/segment_v2/common.h" // for rowid_t +#include "util/frame_of_reference_coding.h" + +namespace doris { +namespace segment_v2 { + +// Encode page use frame-of-reference coding +template<FieldType Type> +class FrameOfReferencePageBuilder : public PageBuilder { +public: + explicit FrameOfReferencePageBuilder(const PageBuilderOptions& options) : + _options(options), + _count(0), + _finished(false) { + _encoder.reset(new ForEncoder<CppType>(&_buf)); + } + + bool is_page_full() override { + return _encoder->len() >= _options.data_page_size; + } + + Status add(const uint8_t* vals, size_t* count) override { + DCHECK(!_finished); + DCHECK_EQ(reinterpret_cast<uintptr_t>(vals) & (alignof(CppType) - 1), 0) + << "Pointer passed to Add() must be naturally-aligned"; Review comment: Refer to RlePageBuilder, should be ensure the following reinterpret_cast is legal ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
