imay commented on a change in pull request #1282: Add OrdinalPageIndex and 
EncodingInfo
URL: https://github.com/apache/incubator-doris/pull/1282#discussion_r292720367
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/encoding_info.cpp
 ##########
 @@ -0,0 +1,131 @@
+// 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.
+
+#include "olap/rowset/segment_v2/encoding_info.h"
+
+#include "olap/olap_common.h"
+
+namespace doris {
+namespace segment_v2 {
+
+struct EncodingMapHash {
+    size_t operator()(const std::pair<FieldType, EncodingTypePB>& pair) const {
+        return (pair.first << 5) ^ pair.second;
+    }
+};
+
+template<FieldType type, EncodingTypePB encoding>
+struct TypeEncodingTraits { };
+
+template<FieldType type>
+struct TypeEncodingTraits<type, PLAIN_ENCODING> {
+    static Status create_page_builder(PageBuilder** builder) {
+        return Status::OK;
+    }
+    static Status create_page_decoder(PageDecoder** decoder) {
+        return Status::OK;
+    }
+};
+
+class EncodingInfoResolver {
+public:
+    EncodingInfoResolver();
+    ~EncodingInfoResolver();
+
+    EncodingTypePB get_default_encoding_type(FieldType type) const {
+        auto it = _default_encoding_type_map.find(type);
+        if (it != std::end(_default_encoding_type_map)) {
+            return it->second;
+        }
+        return DEFAULT_ENCODING;
+    }
+
+    Status get(FieldType data_type, EncodingTypePB encoding_type, const 
EncodingInfo** out);
+
+private:
+    template<FieldType type, EncodingTypePB encoding_type>
+    void _add_map() {
+        TypeEncodingTraits<type, encoding_type> traits;
+        std::unique_ptr<EncodingInfo> encoding(new EncodingInfo(traits));
+        if (_default_encoding_type_map.find(type) == 
std::end(_default_encoding_type_map)) {
+            _default_encoding_type_map[type] = encoding_type;
+        }
+        auto key = std::make_pair(type, encoding_type);
+        _encoding_map.emplace(key, encoding.release());
+    }
+
+    std::unordered_map<FieldType, EncodingTypePB, std::hash<int>> 
_default_encoding_type_map;
+
+    std::unordered_map<std::pair<FieldType, EncodingTypePB>,
+        EncodingInfo*, EncodingMapHash> _encoding_map;
+};
+
+EncodingInfoResolver::EncodingInfoResolver() {
+    _add_map<OLAP_FIELD_TYPE_TINYINT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_SMALLINT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_INT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_BIGINT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_LARGEINT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_FLOAT, PLAIN_ENCODING>();
+    _add_map<OLAP_FIELD_TYPE_DOUBLE, PLAIN_ENCODING>();
 
 Review comment:
   Yes, this is temporary 

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

Reply via email to