MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / tryGenerate

Method tryGenerate

src/Processors/Sources/RemoteSource.cpp:157–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157std::optional<Chunk> RemoteSource::tryGenerate()
158{
159 /// onCancel() will do the cancel if the query was sent.
160 if (isCancelled())
161 return {};
162
163 if (!was_query_sent)
164 {
165 if (async_query_sending)
166 {
167 int fd_ = query_executor->sendQueryAsync();
168 if (fd_ >= 0)
169 {
170 fd = fd_;
171 is_async_state = true;
172 return Chunk();
173 }
174
175 is_async_state = false;
176 }
177 else
178 {
179 query_executor->sendQuery();
180 }
181
182 was_query_sent = true;
183 }
184
185 Block block;
186
187 if (async_read)
188 {
189 auto res = query_executor->readAsync();
190
191 if (res.getType() == RemoteQueryExecutor::ReadResult::Type::Nothing)
192 throw Exception(ErrorCodes::LOGICAL_ERROR, "Got an empty packet from the RemoteQueryExecutor. This is a bug");
193
194 if (res.getType() == RemoteQueryExecutor::ReadResult::Type::FileDescriptor)
195 {
196 fd = res.getFileDescriptor();
197 is_async_state = true;
198 return Chunk();
199 }
200
201 if (res.getType() == RemoteQueryExecutor::ReadResult::Type::ParallelReplicasToken)
202 {
203 is_async_state = false;
204 return Chunk();
205 }
206
207 is_async_state = false;
208
209 block = res.getBlock();
210 }
211 else
212 block = query_executor->readBlock();
213
214 if (block.empty())

Callers

nothing calls this directly

Calls 15

isCancelledFunction · 0.85
sendQueryAsyncMethod · 0.80
getBlockMethod · 0.80
ChunkClass · 0.50
ExceptionClass · 0.50
sendQueryMethod · 0.45
readAsyncMethod · 0.45
getTypeMethod · 0.45
getFileDescriptorMethod · 0.45
readBlockMethod · 0.45
emptyMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected