gaodayue commented on a change in pull request #1646: Support page compression in BetaRowset URL: https://github.com/apache/incubator-doris/pull/1646#discussion_r314794911
########## File path: be/src/olap/rowset/segment_v2/page_compression.h ########## @@ -0,0 +1,98 @@ +// 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 <cstddef> +#include <vector> + +#include "common/status.h" +#include "util/slice.h" +#include "util/faststring.h" + +namespace doris { + +class BlockCompressionCodec; + +namespace segment_v2 { + +// Helper to decompress a compressed page. +// Compressed page is composed of +// CompressedData | Footer +// CompressedData: binary +// Footer : uncompressed data length(fixed32) +// Usage: +// Slice compressed_data; +// PageDecompressor decompressor(compressed_data, codec); +// RETURN_IF_ERROR(decompressor.init()); +// Slice uncompressed_slice; +// RETURN_IF_ERROR(decompressor.decompress_to(&uncompressed_slice)); +// // usage +// if (uncompressed_slice.data != compressed_slice.data) { +// delete[] uncompressed_slice.data; +// } Review comment: My suggestion for the comment ``` // Utility class for parsing and decompressing compressed page. // Format of compressed page := Data, UncompressedSize(fixed32) // When sizeof(Data) == UncompressedSize, it means Data is stored in uncompressed form, thus decompression is not needed. // Otherwise Data is in compressed form and should be decompressed. // The type of compression codec for Data is stored elsewhere and should be passed into the constructor. // Usage example: // PageDecompressor decompressor(page_slice, codec); // page_size refers to page read from storage // Slice uncompressed_slice; // points to decompressed Data of the page (without footer) // RETURN_IF_ERROR(decompressor.decompress_to(&uncompressed_slice)); // if (uncompressed_slice.data != page_slice.data) { // we have a new buffer for decompressed page // delete[] page_slice.data; // we no longer need compressed page // } // // use uncompressed_slice ``` ---------------------------------------------------------------- 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