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 "meta/meta_service.h" |
24 | |
25 | namespace proxima { |
26 | namespace be { |
27 | namespace query { |
28 | |
29 | //! Predefine class |
30 | class MetaWrapper; |
31 | |
32 | //! Alias for ColumnNameList |
33 | using ColumnNameList = std::vector<std::string>; |
34 | using MetaWrapperPtr = std::shared_ptr<MetaWrapper>; |
35 | |
36 | |
37 | /*! |
38 | * MetaWrapper |
39 | */ |
40 | class MetaWrapper { |
41 | public: |
42 | //! Constructor |
43 | explicit MetaWrapper(meta::MetaServicePtr meta_service); |
44 | |
45 | public: |
46 | //! validate collection and columns |
47 | int validate(const std::string &collection, |
48 | const ColumnNameList &columns) const; |
49 | |
50 | //! validate collection |
51 | int validate_collection(const std::string &collection) const; |
52 | |
53 | //! validate collection and column |
54 | int validate_column(const std::string &collection, |
55 | const std::string &column) const; |
56 | |
57 | //! list all the columns |
58 | int list_columns(const std::string &collection, uint64_t revision, |
59 | ColumnNameList *columns) const; |
60 | |
61 | //! get data type by column |
62 | DataTypes get_data_type(const std::string &collection, |
63 | const std::string &column); |
64 | |
65 | private: |
66 | //! Meta service handler |
67 | meta::MetaServicePtr meta_service_{nullptr}; |
68 | }; |
69 | |
70 | |
71 | } // namespace query |
72 | } // namespace be |
73 | } // namespace proxima |
74 | |