PragmaTwice commented on code in PR #1699: URL: https://github.com/apache/kvrocks/pull/1699#discussion_r1304971321
########## src/types/redis_sb_chain.h: ########## @@ -0,0 +1,59 @@ +/* + * 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 "bloom_filter.h" +#include "storage/redis_db.h" +#include "storage/redis_metadata.h" + +namespace redis { + +const char kBloomFilterSeparator[] = ":"; +const uint32_t kBFDefaultInitCapacity = 100; +const double kBFDefaultErrorRate = 0.01; +const uint16_t kBFDefaultExpansion = 2; +const double kErrorTighteningRatio = 0.5; + +enum class ReadWriteMode { + MODE_READ = 0, + MODE_WRITE = 1, +}; + +class SBChain : public Database { + public: + SBChain(engine::Storage *storage, const std::string &ns) : Database(storage, ns) {} + rocksdb::Status Reserve(const Slice &user_key, uint32_t capacity, double error_rate, uint16_t expansion, + uint16_t scaling); + rocksdb::Status Add(const Slice &user_key, const Slice &item, int &ret); + rocksdb::Status Exist(const Slice &user_key, const Slice &item, int &ret); + + private: + rocksdb::Status getSBChainMetadata(const Slice &ns_key, SBChainMetadata *metadata); + rocksdb::Status getBFMetadata(const Slice &bf_meta_key, BFMetadata *metadata); + rocksdb::Status createSBChain(const Slice &ns_key, double error_rate, uint32_t capacity, uint16_t expansion, + uint16_t scaling, SBChainMetadata &sb_chain_metadata); + rocksdb::Status bloomCheckAdd(const Slice &bf_key, const std::string &item, ReadWriteMode mode, int &ret); + + static void appendBFSuffix(const Slice &ns_key, uint16_t filters_index, std::string *output); + static void appendBFMetaSuffix(const Slice &bf_key, std::string *output); Review Comment: ```suggestion static std::string appendBFSuffix(const Slice &ns_key, uint16_t filters_index); static std::string appendBFMetaSuffix(const Slice &bf_key); ``` It is better to have the function signature like this. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
