kangkaisen commented on a change in pull request #1818: Add frame_of_reference 
page
URL: https://github.com/apache/incubator-doris/pull/1818#discussion_r325462838
 
 

 ##########
 File path: be/src/util/frame_of_reference_coding.h
 ##########
 @@ -0,0 +1,154 @@
+// 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.
+
+#ifndef DORIS_FRAME_OF_REFERENCE_CODING_H
+#define DORIS_FRAME_OF_REFERENCE_CODING_H
+
+
+#include <cstdlib>
+#include <iostream>
+
+#include "util/bit_stream_utils.h"
+#include "util/bit_stream_utils.inline.h"
+#include "util/faststring.h"
+
+namespace doris {
+
+enum {
+    BYTE_SIZE = 8,
+    INT32_SIZE = 8 * 4,
+    FOR_CODING_FRAME_VALUE_NUM = 128
+};
+
+// The implementation for frame-of-reference coding
+// The detail of frame-of-reference coding, please refer to
+// 
https://lemire.me/blog/2012/02/08/effective-compression-using-frame-of-reference-and-delta-coding/
+// and https://www.elastic.co/cn/blog/frame-of-reference-and-roaring-bitmaps
+
+// The encoded data format is as follows:
+
+// 1. Body:
+// BitPackingFrame * FrameCount
+// 2. Footer:
+// FrameOffset(4) * (FrameCount + 1)
+// LastFrameNumValues(1) (optional)
+// FrameCount(4)
+// NumValues(4)
+
+// The BitPackingFrame format is as follows:
+// MinValue, (Value - MinVale) * FRAME_VALUE_NUM
+
+// The last frame value num maybe less than 128
+template<typename T>
+class ForEncoder {
+public:
+    explicit ForEncoder(faststring *buffer): _bit_writer(buffer) {
+    }
+
+    void put(T value);
 
 Review comment:
   OK

----------------------------------------------------------------
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

Reply via email to