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 Oct 2020 |
18 | * \brief Format of collection statistics |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "segment/segment.h" |
24 | |
25 | namespace proxima { |
26 | namespace be { |
27 | namespace index { |
28 | |
29 | /* SegmentStats looks like SegmentMeta, but it will expand |
30 | * many fields for statistics, so we just split it out. |
31 | * And SegmentStats is allowed to store many not-POD type data, |
32 | * and provide debug string interface. |
33 | */ |
34 | struct SegmentStats { |
35 | uint32_t segment_id{0U}; |
36 | uint32_t state{0U}; |
37 | uint64_t doc_count{0U}; |
38 | uint64_t index_file_count{0U}; |
39 | uint64_t index_file_size{0U}; |
40 | uint64_t min_doc_id{0U}; |
41 | uint64_t max_doc_id{0U}; |
42 | uint64_t min_primary_key{0U}; |
43 | uint64_t max_primary_key{0U}; |
44 | uint64_t min_timestamp{0U}; |
45 | uint64_t max_timestamp{0U}; |
46 | uint64_t min_lsn{0U}; |
47 | uint64_t max_lsn{0U}; |
48 | |
49 | SegmentStats(const SegmentMeta &segment_meta) { |
50 | segment_id = segment_meta.segment_id; |
51 | state = segment_meta.state; |
52 | doc_count = segment_meta.doc_count; |
53 | index_file_count = segment_meta.index_file_count; |
54 | index_file_size = segment_meta.index_file_size; |
55 | min_doc_id = segment_meta.min_doc_id; |
56 | max_doc_id = segment_meta.max_doc_id; |
57 | min_primary_key = segment_meta.min_primary_key; |
58 | max_primary_key = segment_meta.max_primary_key; |
59 | min_timestamp = segment_meta.min_timestamp; |
60 | max_timestamp = segment_meta.max_timestamp; |
61 | min_lsn = segment_meta.min_lsn; |
62 | max_lsn = segment_meta.max_lsn; |
63 | } |
64 | }; |
65 | |
66 | /* |
67 | * CollectionStats contains some important metrics of collection. |
68 | * It contains serveral segments, at least one. |
69 | */ |
70 | struct CollectionStats { |
71 | std::string collection_name{}; |
72 | std::string collection_path{}; |
73 | uint64_t total_doc_count{0U}; |
74 | uint64_t delete_doc_count{0U}; |
75 | uint64_t total_segment_count{0U}; |
76 | uint64_t total_index_file_count{0U}; |
77 | uint64_t total_index_file_size{0U}; |
78 | std::vector<SegmentStats> segment_stats{}; |
79 | }; |
80 | |
81 | } // end namespace index |
82 | } // namespace be |
83 | } // end namespace proxima |
84 |