index_config.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Tencent is pleased to support the open source community by making wwsearch
  3. * available.
  4. *
  5. * Copyright (C) 2018-present Tencent. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  8. * use this file except in compliance with the License. You may obtain a copy of
  9. * the License at
  10. *
  11. * https://opensource.org/licenses/Apache-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "codec.h"
  20. #include "header.h"
  21. #include "tokenizer.h"
  22. #include "virtual_db.h"
  23. namespace wwsearch {
  24. class IndexConfig {
  25. private:
  26. Codec* codec_;
  27. VirtualDB* vdb_;
  28. Tokenizer* tokenizer_;
  29. uint32_t min_suffix_build_len_{5}; // min suffix build len.Default:5
  30. uint32_t max_suffix_term_size_{64}; // max suffix term size
  31. uint32_t max_write_batch_size_{19922944}; // max write batch size limit: 19MB
  32. uint32_t max_inner_purge_batch_docs_count_{
  33. 10000}; // max batch docs in InnerPurge
  34. uint32_t max_inner_purge_docs_total_limit_{50000};
  35. SearchLogLevel log_level_;
  36. public:
  37. IndexConfig();
  38. ~IndexConfig();
  39. bool SetCodec(Codec* codec);
  40. Codec* GetCodec();
  41. bool SetVirtualDB(VirtualDB* vdb);
  42. VirtualDB* VDB();
  43. bool SetTokenizer(Tokenizer* tokenizer);
  44. Tokenizer* GetTokenizer();
  45. bool SetMinSuffixBuildLen(uint32_t min_len) {
  46. this->min_suffix_build_len_ = min_len;
  47. }
  48. uint32_t GetMinSuffixBuildLen() { return this->min_suffix_build_len_; }
  49. bool SetMaxSuffixTermSize(uint32_t max_suffix_term_size) {
  50. this->max_suffix_term_size_ = max_suffix_term_size;
  51. }
  52. uint32_t GetMaxSuffixTermSize() { return this->max_suffix_term_size_; }
  53. bool SetMaxWriteBatchSize(uint32_t max_write_batch_size) {
  54. this->max_write_batch_size_ = max_write_batch_size;
  55. }
  56. uint32_t GetMaxWriteBatchSize() { return this->max_write_batch_size_; }
  57. bool SetMaxInnerPurgeBatchDocsCount(
  58. uint32_t max_inner_purge_batch_docs_count) {
  59. this->max_inner_purge_batch_docs_count_ = max_inner_purge_batch_docs_count;
  60. }
  61. uint32_t GetMaxInnerPurgeBatchDocsCount() {
  62. return this->max_inner_purge_batch_docs_count_;
  63. }
  64. bool SetMaxInnerPurgeDocsTotalLimit(
  65. uint32_t max_inner_purge_docs_total_limit) {
  66. this->max_inner_purge_docs_total_limit_ = max_inner_purge_docs_total_limit;
  67. }
  68. uint32_t GetMaxInnerPurgeDocsTotalLimit() {
  69. return this->max_inner_purge_docs_total_limit_;
  70. }
  71. bool SetLogLevel(SearchLogLevel log_level) {
  72. this->log_level_ = log_level;
  73. return true;
  74. }
  75. SearchLogLevel GetLogLevel() { return this->log_level_; }
  76. private:
  77. };
  78. } // namespace wwsearch