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 ForwardIndexer can streamly process multiple column |
19 | * data, building forward index and dump to persist index. |
20 | */ |
21 | |
22 | #pragma once |
23 | |
24 | #include "forward_reader.h" |
25 | |
26 | namespace proxima { |
27 | namespace be { |
28 | namespace index { |
29 | |
30 | class ForwardIndexer; |
31 | using ForwardIndexerPtr = std::shared_ptr<ForwardIndexer>; |
32 | |
33 | /* |
34 | * ForwardIndexer process forward data streamly. After |
35 | * accumulating to a certain amount, it will dump to |
36 | * full index, which is persist on disk. |
37 | * |
38 | */ |
39 | class ForwardIndexer : public ForwardReader { |
40 | public: |
41 | //! Destructor |
42 | virtual ~ForwardIndexer() = default; |
43 | |
44 | //! Create an instance and return a shared ptr |
45 | static ForwardIndexerPtr Create(const std::string &collection_name, |
46 | const std::string &collection_path, |
47 | SegmentID segment_id); |
48 | |
49 | public: |
50 | //! Flush to persist storage |
51 | virtual int flush() = 0; |
52 | |
53 | //! Dump to full index type |
54 | virtual int dump(IndexDumperPtr dumper) = 0; |
55 | |
56 | //! Insert a forward data, and return its local index. |
57 | virtual int insert(const ForwardData &forward_data, idx_t *doc_id) = 0; |
58 | |
59 | #if 0 |
60 | //! Update forward data by doc_id |
61 | virtual int update(idx_t doc_id, const ForwardData &forward_data) = 0; |
62 | #endif |
63 | |
64 | //! Remove forward data by doc_id |
65 | virtual int remove(idx_t doc_id) = 0; |
66 | }; |
67 | |
68 | |
69 | } // end namespace index |
70 | } // namespace be |
71 | } // end namespace proxima |
72 | |