or_scorer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 "or_iterator.h"
  20. #include "or_weight.h"
  21. #include "scorer.h"
  22. namespace wwsearch {
  23. class OrScorer : public Scorer {
  24. private:
  25. std::vector<Scorer *> sub_scorer_;
  26. OrIterator iterator_;
  27. public:
  28. OrScorer(OrWeight *weight) : Scorer(weight, "OrScorer") {}
  29. virtual ~OrScorer() {
  30. // our response to delete scorer
  31. for (auto s : sub_scorer_) delete s;
  32. }
  33. virtual DocumentID DocID() override;
  34. virtual double Score() override;
  35. virtual DocIdSetIterator &Iterator() override;
  36. void AddScorer(Scorer *s) {
  37. this->sub_scorer_.push_back(s);
  38. this->iterator_.AddSubIterator(&(s->Iterator()));
  39. }
  40. private:
  41. };
  42. } // namespace wwsearch