kangpinghuang commented on a change in pull request #1572: Add new format short 
key index
URL: https://github.com/apache/incubator-doris/pull/1572#discussion_r310025240
 
 

 ##########
 File path: be/src/olap/short_key_index.h
 ##########
 @@ -0,0 +1,197 @@
+// 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 <cstdint>
+#include <iterator>
+#include <string>
+#include <vector>
+
+#include "common/status.h"
+#include "gen_cpp/segment_v2.pb.h"
+#include "util/faststring.h"
+#include "util/slice.h"
+
+namespace doris {
+
+// Used to encode a segment short key indices to binary format. This version
+// only accepts binary key, client should assure that input key is sorted,
+// otherwise error could happens. This builder would arrange data in following
+// format.
+//      index = encoded_keys + encoded_offsets + footer + footer_size + 
checksum
+//      encoded_keys = binary_key + [, ...]
+//      encoded_offsets = encoded_offset + [, ...]
+//      encoded_offset = variant32
+//      footer = ShortKeyFooterPB
+//      footer_size = fixed32
+//      checksum = fixed32
+// Usage:
+//      ShortKeyIndexBuilder builder(segment_id, num_rows_per_block);
+//      builder.add_item(key1);
+//      ...
+//      builder.add_item(keyN);
+//      builder.finalize(segment_size, num_rows, &slices);
+// TODO(zc):
+// 1. If this can leverage binary page to save key and offset data
+// 2. Extending this to save in a BTree like struct, which can index full key
+//    more than short key
+class ShortKeyIndexBuilder {
+public:
+    ShortKeyIndexBuilder(uint32_t segment_id,
+                         uint32_t num_rows_per_block) {
 
 Review comment:
   what are these two arguments for? 

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

Reply via email to