imay commented on a change in pull request #2471: add block split bloom filter
URL: https://github.com/apache/incubator-doris/pull/2471#discussion_r358236660
 
 

 ##########
 File path: be/src/olap/rowset/segment_v2/bloom_filter.h
 ##########
 @@ -0,0 +1,173 @@
+// 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 <functional>
+#include <memory>
+
+#include "olap/utils.h"
+#include "gen_cpp/segment_v2.pb.h"
+#include "util/murmur_hash3.h"
+#include "common/status.h"
+
+namespace doris {
+namespace segment_v2 {
+
+struct BloomFilterOptions {
+    // false positive probablity
+    double fpp = 0.05;
+    HashStrategyPB strategy = HASH_MURMUR3_X64_64;
+};
+
+// Base class for bloom filter
+// To support null value, the size of bloom filter is optimize bytes + 1.
+// The last byte is for null value flag.
+class BloomFilter {
+public:
+    // Default seed for the hash function. It comes from date +%s.
+    static const uint32_t DEFAULT_SEED = 1575457558;
+
+    // Minimum Bloom filter size, set to the size of a tiny Bloom filter block
+    static const uint32_t MINIMUM_BYTES = 32;
+
+    // Maximum Bloom filter size, set it to half of max segment file size
+    static const uint32_t MAXIMUM_BYTES = 128 * 1024 * 1024;
+
+    // Factory function for BloomFilter
+    static Status create(BloomFilterAlgorithmPB algorithm, 
std::unique_ptr<BloomFilter>* bf);
+
+    // Compute the optimal bit number according to the following rule:
+    //     m = -n * ln(fpp) / (ln(2) ^ 2)
+    // n: expected distinct record number
+    // fpp: false positive probablity
+    // the result will be power of 2
+    static uint32_t optimal_bit_num(uint64_t n, double fpp);
 
 Review comment:
   why not encapasulate this function in this class. user just pass n to this 
class.

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