1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15
16 * \author Haichao.chc
17 * \date Jun 2021
18 * \brief IndexProvider provides column index information
19 */
20
21#pragma once
22
23#include "meta/meta.h"
24#include "../constants.h"
25#include "../typedef.h"
26
27namespace proxima {
28namespace be {
29namespace index {
30
31
32/*
33 * IndexProvider provides some detail info about the column or forward index.
34 */
35class IndexProvider {
36 public:
37 //! Destructor
38 virtual ~IndexProvider() = default;
39
40 public:
41 //! Return collection name
42 const std::string &collection_name() const {
43 return collection_name_;
44 }
45
46 //! Return collection path
47 const std::string &collection_path() const {
48 return collection_path_;
49 }
50
51 //! Return segment id
52 SegmentID segment_id() const {
53 return segment_id_;
54 }
55
56 //! Return column name
57 //! Forward will return ""
58 const std::string &column_name() const {
59 return column_name_;
60 }
61
62 //! Return document count
63 virtual size_t doc_count() const = 0;
64
65 //! Return index file path
66 virtual std::string index_file_path() const = 0;
67
68 protected:
69 void set_collection_name(const std::string &val) {
70 collection_name_ = val;
71 }
72
73 void set_collection_path(const std::string &val) {
74 collection_path_ = val;
75 }
76
77 void set_segment_id(SegmentID val) {
78 segment_id_ = val;
79 }
80
81 void set_column_name(const std::string &val) {
82 column_name_ = val;
83 }
84
85 private:
86 std::string collection_name_{};
87 std::string collection_path_{};
88 SegmentID segment_id_{INVALID_SEGMENT_ID};
89 std::string column_name_{};
90};
91
92
93} // end namespace index
94} // namespace be
95} // end namespace proxima
96