• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ICING_SCORING_SCORER_FACTORY_H_
16 #define ICING_SCORING_SCORER_FACTORY_H_
17 
18 #include "icing/text_classifier/lib3/utils/base/statusor.h"
19 #include "icing/join/join-children-fetcher.h"
20 #include "icing/scoring/scorer.h"
21 #include "icing/store/document-store.h"
22 
23 namespace icing {
24 namespace lib {
25 
26 namespace scorer_factory {
27 
28 // Factory function to create a Scorer which does not take ownership of any
29 // input components (DocumentStore), and all pointers must refer to valid
30 // objects that outlive the created Scorer instance. The default score will be
31 // returned only when the scorer fails to find or calculate a score for the
32 // document.
33 //
34 // Returns:
35 //   A Scorer on success
36 //   FAILED_PRECONDITION on any null pointer input
37 //   INVALID_ARGUMENT if fails to create an instance
38 libtextclassifier3::StatusOr<std::unique_ptr<Scorer>> Create(
39     const ScoringSpecProto& scoring_spec, double default_score,
40     const DocumentStore* document_store, const SchemaStore* schema_store,
41     int64_t current_time_ms,
42     const JoinChildrenFetcher* join_children_fetcher = nullptr);
43 
44 }  // namespace scorer_factory
45 
46 }  // namespace lib
47 }  // namespace icing
48 
49 #endif  // ICING_SCORING_SCORER_FACTORY_H_
50