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 Jiliang.ljl |
17 | * \date Mar 2021 |
18 | * \brief |
19 | * \detail |
20 | */ |
21 | |
22 | #pragma once |
23 | |
24 | #include "index/collection_stats.h" |
25 | #include "meta/meta.h" |
26 | #include "proto/proxima_be.pb.h" |
27 | |
28 | namespace proxima { |
29 | namespace be { |
30 | namespace admin { |
31 | |
32 | class AdminProtoConverter { |
33 | public: |
34 | //! Helper function for serialize PB to CollectionMeta |
35 | static int PBToCollectionBase(const proto::CollectionConfig &request, |
36 | meta::CollectionBase *param); |
37 | |
38 | //! Convert CollectionMeta to PB |
39 | static void CollectionMetaToPB(const meta::CollectionMeta &collection, |
40 | proto::CollectionInfo *info); |
41 | |
42 | //! Convert CollectionStats to PB |
43 | static void CollectionStatsToPB(const index::CollectionStats &stats, |
44 | proto::CollectionStats *pb_stats); |
45 | |
46 | private: |
47 | //! Convert SegmentStats to PB |
48 | static void SegmentStatsToPB(const index::SegmentStats &stats, |
49 | proto::CollectionStats::SegmentStats *pb_stats); |
50 | |
51 | //! Convert Repository to PB |
52 | static void RepositoryToPB(std::shared_ptr<meta::RepositoryBase> repo, |
53 | proto::CollectionConfig *config); |
54 | |
55 | //! Convert ColumnMeta to PB |
56 | static void ColumnMetaToPB(const meta::ColumnMetaPtr &column, |
57 | proto::CollectionConfig::IndexColumnParam *param); |
58 | |
59 | //! Helper function for serializing PB to IndexColumnParam |
60 | static void PBToColumnMeta( |
61 | const proto::CollectionConfig::IndexColumnParam *request, |
62 | meta::ColumnMeta *column); |
63 | }; |
64 | |
65 | } // namespace admin |
66 | } // namespace be |
67 | } // namespace proxima |
68 | |