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 guonix
17 * \date Nov 2020
18 * \brief
19 */
20
21#pragma once
22
23#include <list>
24#include "meta.h"
25
26namespace proxima {
27namespace be {
28namespace meta {
29
30//! Predefine class
31class ColumnObject;
32class CollectionObject;
33class DatabaseRepositoryObject;
34
35//! Alias pointer
36using ColumnObjectPtr = std::shared_ptr<ColumnObject>;
37using CollectionObjectPtr = std::shared_ptr<CollectionObject>;
38using CollectionObjectList = std::list<CollectionObject>;
39using CollectionListConstIter = CollectionObjectList::const_iterator;
40using DatabaseRepositoryObjectPtr = std::shared_ptr<DatabaseRepositoryObject>;
41
42
43/*!
44 * Column interface, transform meta between meta_store and meta_service
45 */
46class ColumnObject {
47 public:
48 //! Destructor
49 virtual ~ColumnObject() = default;
50
51 public:
52 //! Retrieve id
53 virtual uint64_t id() const = 0;
54
55 //! Set id
56 virtual void set_id(uint64_t) = 0;
57
58 //! Retrieve collection uid
59 virtual const std::string &collection_uid() const = 0;
60
61 //! Retrieve mutable collection uid
62 virtual std::string *mutable_collection_uid() = 0;
63
64 //! Set collection uid
65 virtual void set_collection_uid(const std::string &) = 0;
66
67 //! Retrieve collection uuid
68 virtual const std::string &collection_uuid() const = 0;
69
70 //! Retrieve mutable collection uuid
71 virtual std::string *mutable_collection_uuid() = 0;
72
73 //! Set collection uuid
74 virtual void set_collection_uuid(const std::string &) = 0;
75
76 //! Retrieve column name
77 virtual const std::string &name() const = 0;
78
79 //! Retrieve mutable column name
80 virtual std::string *mutable_name() = 0;
81
82 //! Set column name
83 virtual void set_name(const std::string &) = 0;
84
85 //! Retrieve column uid
86 virtual const std::string &uid() const = 0;
87
88 //! Retrieve mutable column uid
89 virtual std::string *mutable_uid() = 0;
90
91 //! Set column uid
92 virtual void set_uid(const std::string &) = 0;
93
94 //! Retrieve dimension of column
95 virtual uint32_t dimension() const = 0;
96
97 //! Set dimension of column
98 virtual void set_dimension(uint32_t) = 0;
99
100 //! Retrieve column index type
101 virtual uint32_t index_type() const = 0;
102
103 //! Set column index type
104 virtual void set_index_type(uint32_t) = 0;
105
106 //! Retrieve column data type
107 virtual uint32_t data_type() const = 0;
108
109 //! Set column index type
110 virtual void set_data_type(uint32_t) = 0;
111
112 //! Retrieve column parameters
113 virtual const std::string &parameters() const = 0;
114
115 //! Retrieve mutable column parameters
116 virtual std::string *mutable_parameters() = 0;
117
118 //! Set column parameters
119 virtual void set_parameters(const std::string &) = 0;
120};
121
122
123/*!
124 * Collection interface, transform meta between meta_store and
125 * meta_service
126 */
127class CollectionObject {
128 public:
129 //! Destructor
130 virtual ~CollectionObject() = default;
131
132 public:
133 //! Retrieve id
134 virtual uint64_t id() const = 0;
135
136 //! Set collection id
137 virtual void set_id(uint64_t) = 0;
138
139 //! Retrieve collection name
140 virtual const std::string &name() const = 0;
141
142 //! Retrieve mutable collection name
143 virtual std::string *mutable_name() = 0;
144
145 //! Set collection name
146 virtual void set_name(const std::string &) = 0;
147
148 //! Retrieve collection uid, indicate a group of collections
149 virtual const std::string &uid() const = 0;
150
151 //! Retrieve mutable collection uid, indicate a group of collections
152 virtual std::string *mutable_uid() = 0;
153
154 //! Set collection uid
155 virtual void set_uid(const std::string &) = 0;
156
157 //! Retrieve collection uuid, unique field
158 virtual const std::string &uuid() const = 0;
159
160 //! Retrieve mutable collection uuid, unique field
161 virtual std::string *mutable_uuid() = 0;
162
163 //! Set collection uuid
164 virtual void set_uuid(const std::string &) = 0;
165
166 //! Retrieve forward columns, separated by character ','
167 virtual const std::string &forward_columns() const = 0;
168
169 //! Retrieve mutable forward columns, separated by character ','
170 virtual std::string *mutable_forward_columns() = 0;
171
172 //! Set forward columns
173 virtual void set_forward_columns(const std::string &) = 0;
174
175 //! Retrieve split document count
176 virtual uint64_t max_docs_per_segment() const = 0;
177
178 //! Set split document count
179 virtual void set_max_docs_per_segment(uint64_t) = 0;
180
181 //! Retrieve collection revision
182 virtual uint32_t revision() const = 0;
183
184 //! Set collection revision
185 virtual void set_revision(uint32_t) = 0;
186
187 //! Retrieve collection status
188 virtual uint32_t status() const = 0;
189
190 //! Set collection status
191 virtual void set_status(uint32_t) = 0;
192
193 //! Retrieve collection current flag
194 virtual uint32_t current() const = 0;
195
196 //! Set collection current flag
197 virtual void set_current(uint32_t) = 0;
198
199 //! Retrieve io_mode of collection
200 virtual uint32_t io_mode() const = 0;
201
202 //! Set io_mode of collection
203 virtual void set_io_mode(uint32_t mode) = 0;
204};
205
206
207/*!
208 * Repository Object
209 */
210class DatabaseRepositoryObject {
211 public:
212 //! Destructor
213 virtual ~DatabaseRepositoryObject() = default;
214
215 public:
216 //! Retrieve id
217 virtual uint64_t id() const = 0;
218
219 //! Set repository id
220 virtual void set_id(uint64_t) = 0;
221
222 //! Retrieve repository name
223 virtual const std::string &name() const = 0;
224
225 //! Retrieve mutable repository name
226 virtual std::string *mutable_name() = 0;
227
228 //! Set repository name
229 virtual void set_name(const std::string &) = 0;
230
231 //! Retrieve collection uid
232 virtual const std::string &collection_uid() const = 0;
233
234 //! Retrieve mutable collection uid
235 virtual std::string *mutable_collection_uid() = 0;
236
237 //! Set collection uid
238 virtual void set_collection_uid(const std::string &) = 0;
239
240 //! Retrieve collection uuid
241 virtual const std::string &collection_uuid() const = 0;
242
243 //! Retrieve mutable collection uuid
244 virtual std::string *mutable_collection_uuid() = 0;
245
246 //! Set collection uuid
247 virtual void set_collection_uuid(const std::string &) = 0;
248
249 //! Retrieve connection uri
250 virtual const std::string &connection() const = 0;
251
252 //! Retrieve mutable connection uri
253 virtual std::string *mutable_connection() = 0;
254
255 //! Set connection uri
256 virtual void set_connection(const std::string &) = 0;
257
258 //! Retrieve user name of connection
259 virtual const std::string &user() const = 0;
260
261 //! Retrieve mutable user name of connection
262 virtual std::string *mutable_user() = 0;
263
264 //! Set user name of connection
265 virtual void set_user(const std::string &) = 0;
266
267 //! Retrieve password of user
268 virtual const std::string &password() const = 0;
269
270 //! Retrieve mutable password of user
271 virtual std::string *mutable_password() = 0;
272
273 //! Set password of user
274 virtual void set_password(const std::string &) = 0;
275
276 //! Retrieve repository table name
277 virtual const std::string &table() const = 0;
278
279 //! Retrieve mutable repository table name
280 virtual std::string *mutable_table() = 0;
281
282 //! Set repository table name
283 virtual void set_table(const std::string &) = 0;
284};
285
286
287} // namespace meta
288} // namespace be
289} // namespace proxima
290