unittest_util.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 "include/codec_impl.h"
  20. #include "include/document.h"
  21. #include "include/index_wrapper.h"
  22. #include "include/index_writer.h"
  23. #include "include/logger.h"
  24. #include "include/virtual_db_rocks.h"
  25. #include "include/and_query.h"
  26. #include "include/bool_query.h"
  27. #include "include/index_wrapper.h"
  28. #include "include/or_query.h"
  29. #include "include/query.h"
  30. #include "include/searcher.h"
  31. #include "include/storage_type.h"
  32. #include "include/tokenizer_impl.h"
  33. #include "include/weight.h"
  34. #include <utility>
  35. #include <vector>
  36. #include "include/logger.h"
  37. extern bool g_debug;
  38. extern bool g_use_rocksdb;
  39. extern bool g_use_compression;
  40. namespace wwsearch {
  41. void InitStringField(IndexField* field, uint16_t field_id,
  42. const std::string& word);
  43. void InitUint32Field(IndexField* field, uint16_t field_id, uint32_t value);
  44. void InitUint64Field(IndexField* field, uint16_t field_id, uint64_t value);
  45. class TestUtil {
  46. public:
  47. using FieldIdStrPair = std::pair<uint16_t, std::string>;
  48. static DefaultIndexWrapper* NewIndex(const char* path) {}
  49. static void DeleteIndex(DefaultIndexWrapper* index) {}
  50. static DocumentUpdater* NewDocument(DocumentID documentid,
  51. std::string str_field,
  52. uint32_t numeric_32, uint64_t numeric_64,
  53. uint32_t sort_value,
  54. uint8_t field_offset = 0);
  55. static DocumentUpdater* NewStringFieldDocument(
  56. DocumentID documentid,
  57. const std::vector<FieldIdStrPair>& field_id_str_list);
  58. };
  59. } // namespace wwsearch