You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/08/15 13:49:35 UTC

[GitHub] [incubator-doris] gaodayue commented on a change in pull request #1646: Support page compression in BetaRowset

gaodayue commented on a change in pull request #1646: Support page compression in BetaRowset
URL: https://github.com/apache/incubator-doris/pull/1646#discussion_r314262395
 
 

 ##########
 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
+// Header | CompressedData
+// Header : uncompressed data length(fixed32)
+// CompressedData: binary
+// Usage: 
+//      Slice compressed_data;
+//      PageDecompressor decompressor(compressed_data, uncomrcodec);
+//      RETURN_IF_ERROR(decompressor.init());
+//      std::string buf;
+//      buf.resize(decompressor.uncompressed_bytes());
+//      RETURN_IF_ERROR(decompress_to(buf.data()));
+class PageDecompressor {
+public:
+    PageDecompressor(const Slice& data, const BlockCompressionCodec* codec)
+        : _data(data), _codec(codec) {
+    }
+
+    // Parse and validate compressed page's header.
+    // Only this funciton is executed successfully, uncompressed_bytes
+    // and decompress_to can be called.
+    // Return error if this page is corrupt.
+    Status init();
+
+    // Get uncompressed size in bytes of this page
+    size_t uncompressed_bytes() const { return _uncompressed_bytes; }
+    
+    // Decmopress compressed data into buf whose capacity must be greater than
+    // uncompressed_bytes()
+    Status decompress_to(void* buf);
+private:
+    Slice _data;
+    const BlockCompressionCodec* _codec;
+    size_t _uncompressed_bytes;
+};
+
+// Helper to build a compress page.
+// Usage:
+//      std::<Slice> raw_data;
 
 Review comment:
   ```suggestion
   //      std::vector<Slice> raw_data;
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org