/root/doris/be/src/exec/rowid_fetcher.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <brpc/controller.h> |
21 | | #include <gen_cpp/DataSinks_types.h> |
22 | | #include <gen_cpp/internal_service.pb.h> |
23 | | |
24 | | #include <memory> |
25 | | #include <utility> |
26 | | #include <vector> |
27 | | |
28 | | #include "common/status.h" |
29 | | #include "exec/tablet_info.h" // DorisNodesInfo |
30 | | #include "olap/id_manager.h" |
31 | | #include "vec/core/block.h" |
32 | | #include "vec/data_types/data_type.h" |
33 | | |
34 | | namespace doris { |
35 | | |
36 | | class DorisNodesInfo; |
37 | | class RuntimeState; |
38 | | class TupleDescriptor; |
39 | | |
40 | | struct FileMapping; |
41 | | struct IteratorKey; |
42 | | struct IteratorItem; |
43 | | struct HashOfIteratorKey; |
44 | | |
45 | | namespace vectorized { |
46 | | template <typename T> |
47 | | class ColumnStr; |
48 | | using ColumnString = ColumnStr<UInt32>; |
49 | | class MutableBlock; |
50 | | } // namespace vectorized |
51 | | |
52 | | // fetch rows by global rowid |
53 | | // tablet_id/rowset_name/segment_id/ordinal_id |
54 | | |
55 | | struct FetchOption { |
56 | | TupleDescriptor* desc = nullptr; |
57 | | RuntimeState* runtime_state = nullptr; |
58 | | TFetchOption t_fetch_opt; |
59 | | }; |
60 | | |
61 | | class RowIDFetcher { |
62 | | public: |
63 | 0 | RowIDFetcher(FetchOption fetch_opt) : _fetch_option(std::move(fetch_opt)) {} |
64 | | Status init(); |
65 | | Status fetch(const vectorized::ColumnPtr& row_ids, vectorized::Block* block); |
66 | | |
67 | | private: |
68 | | PMultiGetRequest _init_fetch_request(const vectorized::ColumnString& row_ids) const; |
69 | | Status _merge_rpc_results(const PMultiGetRequest& request, |
70 | | const std::vector<PMultiGetResponse>& rsps, |
71 | | const std::vector<brpc::Controller>& cntls, |
72 | | vectorized::Block* output_block, |
73 | | std::vector<PRowLocation>* rows_id) const; |
74 | | |
75 | | std::vector<std::shared_ptr<PBackendService_Stub>> _stubs; |
76 | | FetchOption _fetch_option; |
77 | | }; |
78 | | |
79 | | struct RowStoreReadStruct { |
80 | 0 | RowStoreReadStruct(std::string& buffer) : row_store_buffer(buffer) {}; |
81 | | std::string& row_store_buffer; |
82 | | vectorized::DataTypeSerDeSPtrs serdes; |
83 | | std::unordered_map<uint32_t, uint32_t> col_uid_to_idx; |
84 | | std::vector<std::string> default_values; |
85 | | }; |
86 | | |
87 | | class RowIdStorageReader { |
88 | | public: |
89 | | static Status read_by_rowids(const PMultiGetRequest& request, PMultiGetResponse* response); |
90 | | static Status read_by_rowids(const PMultiGetRequestV2& request, PMultiGetResponseV2* response); |
91 | | |
92 | | private: |
93 | | static Status read_doris_format_row( |
94 | | const std::shared_ptr<IdFileMap>& id_file_map, |
95 | | const std::shared_ptr<FileMapping>& file_mapping, int64_t row_id, |
96 | | std::vector<SlotDescriptor>& slots, const TabletSchema& full_read_schema, |
97 | | RowStoreReadStruct& row_store_read_struct, OlapReaderStatistics& stats, |
98 | | int64_t* acquire_tablet_ms, int64_t* acquire_rowsets_ms, int64_t* acquire_segments_ms, |
99 | | int64_t* lookup_row_data_ms, |
100 | | std::unordered_map<IteratorKey, IteratorItem, HashOfIteratorKey>& iterator_map, |
101 | | vectorized::Block& result_block); |
102 | | |
103 | | static Status read_batch_doris_format_row( |
104 | | const PRequestBlockDesc& request_block_desc, std::shared_ptr<IdFileMap> id_file_map, |
105 | | std::vector<SlotDescriptor>& slots, const TUniqueId& query_id, |
106 | | vectorized::Block& result_block, OlapReaderStatistics& stats, |
107 | | int64_t* acquire_tablet_ms, int64_t* acquire_rowsets_ms, int64_t* acquire_segments_ms, |
108 | | int64_t* lookup_row_data_ms); |
109 | | |
110 | | static Status read_batch_external_row(const PRequestBlockDesc& request_block_desc, |
111 | | std::shared_ptr<IdFileMap> id_file_map, |
112 | | std::vector<SlotDescriptor>& slots, |
113 | | std::shared_ptr<FileMapping> first_file_mapping, |
114 | | const TUniqueId& query_id, |
115 | | vectorized::Block& result_block, int64_t* init_reader_ms, |
116 | | int64_t* get_block_ms); |
117 | | }; |
118 | | |
119 | | template <typename Func> |
120 | 48 | auto scope_timer_run(Func fn, int64_t* cost) -> decltype(fn()) { |
121 | 48 | MonotonicStopWatch watch; |
122 | 48 | watch.start(); |
123 | 48 | auto res = fn(); |
124 | 48 | *cost += watch.elapsed_time() / 1000 / 1000; |
125 | 48 | return res; |
126 | 48 | } Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader14read_by_rowidsERKNS_16PMultiGetRequestEPNS_17PMultiGetResponseEE3$_1EEDTclfp_EET_Pl Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader14read_by_rowidsERKNS_16PMultiGetRequestEPNS_17PMultiGetResponseEE3$_2EEDTclfp_EET_Pl Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader14read_by_rowidsERKNS_16PMultiGetRequestEPNS_17PMultiGetResponseEE3$_4EEDTclfp_EET_Pl Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader14read_by_rowidsERKNS_16PMultiGetRequestEPNS_17PMultiGetResponseEE3$_5EEDTclfp_EET_Pl Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader21read_doris_format_rowERKSt10shared_ptrINS_9IdFileMapEERKS2_INS_11FileMappingEElRSt6vectorINS_14SlotDescriptorESaISC_EERKNS_12TabletSchemaERNS_18RowStoreReadStructERNS_20OlapReaderStatisticsEPlSN_SN_SN_RSt13unordered_mapINS_11IteratorKeyENS_12IteratorItemENS_17HashOfIteratorKeyESt8equal_toISP_ESaISt4pairIKSP_SQ_EEERNS_10vectorized5BlockEE3$_1EEDTclfp_EET_SN_ Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader21read_doris_format_rowERKSt10shared_ptrINS_9IdFileMapEERKS2_INS_11FileMappingEElRSt6vectorINS_14SlotDescriptorESaISC_EERKNS_12TabletSchemaERNS_18RowStoreReadStructERNS_20OlapReaderStatisticsEPlSN_SN_SN_RSt13unordered_mapINS_11IteratorKeyENS_12IteratorItemENS_17HashOfIteratorKeyESt8equal_toISP_ESaISt4pairIKSP_SQ_EEERNS_10vectorized5BlockEE3$_2EEDTclfp_EET_SN_ Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader21read_doris_format_rowERKSt10shared_ptrINS_9IdFileMapEERKS2_INS_11FileMappingEElRSt6vectorINS_14SlotDescriptorESaISC_EERKNS_12TabletSchemaERNS_18RowStoreReadStructERNS_20OlapReaderStatisticsEPlSN_SN_SN_RSt13unordered_mapINS_11IteratorKeyENS_12IteratorItemENS_17HashOfIteratorKeyESt8equal_toISP_ESaISt4pairIKSP_SQ_EEERNS_10vectorized5BlockEE3$_3EEDTclfp_EET_SN_ Unexecuted instantiation: rowid_fetcher.cpp:_ZN5doris15scope_timer_runIZNS_18RowIdStorageReader21read_doris_format_rowERKSt10shared_ptrINS_9IdFileMapEERKS2_INS_11FileMappingEElRSt6vectorINS_14SlotDescriptorESaISC_EERKNS_12TabletSchemaERNS_18RowStoreReadStructERNS_20OlapReaderStatisticsEPlSN_SN_SN_RSt13unordered_mapINS_11IteratorKeyENS_12IteratorItemENS_17HashOfIteratorKeyESt8equal_toISP_ESaISt4pairIKSP_SQ_EEERNS_10vectorized5BlockEE3$_4EEDTclfp_EET_SN_ file_scanner.cpp:_ZN5doris15scope_timer_runIZNS_10vectorized11FileScanner24read_one_line_from_rangeERKNS_14TFileRangeDescEjPNS1_5BlockERKNS_23ExternalFileMappingInfoEPlSB_E3$_0EEDTclfp_EET_SB_ Line | Count | Source | 120 | 24 | auto scope_timer_run(Func fn, int64_t* cost) -> decltype(fn()) { | 121 | 24 | MonotonicStopWatch watch; | 122 | 24 | watch.start(); | 123 | 24 | auto res = fn(); | 124 | 24 | *cost += watch.elapsed_time() / 1000 / 1000; | 125 | 24 | return res; | 126 | 24 | } |
file_scanner.cpp:_ZN5doris15scope_timer_runIZNS_10vectorized11FileScanner24read_one_line_from_rangeERKNS_14TFileRangeDescEjPNS1_5BlockERKNS_23ExternalFileMappingInfoEPlSB_E3$_1EEDTclfp_EET_SB_ Line | Count | Source | 120 | 24 | auto scope_timer_run(Func fn, int64_t* cost) -> decltype(fn()) { | 121 | 24 | MonotonicStopWatch watch; | 122 | 24 | watch.start(); | 123 | 24 | auto res = fn(); | 124 | 24 | *cost += watch.elapsed_time() / 1000 / 1000; | 125 | 24 | return res; | 126 | 24 | } |
|
127 | | } // namespace doris |