@@ -130,62 +130,10 @@ void KafkaSource::parseMessage(void * kmessage, size_t total_count, void * data)
130
130
131
131
void KafkaSource::doParseMessage (const rd_kafka_message_t * kmessage, size_t /* total_count*/ )
132
132
{
133
- if (format_executor)
134
- parseFormat (kmessage);
135
- else
136
- parseRaw (kmessage);
137
-
133
+ parseFormat (kmessage);
138
134
ckpt_data.last_sn = kmessage->offset ;
139
135
}
140
136
141
- void KafkaSource::parseRaw (const rd_kafka_message_t * kmessage)
142
- {
143
- if (!request_virtual_columns)
144
- {
145
- // / fast path
146
- assert (physical_header.columns () == 1 );
147
-
148
- if (current_batch.empty ())
149
- current_batch.push_back (physical_header.getByPosition (0 ).type ->createColumn ());
150
-
151
- current_batch.back ()->insertData (static_cast <const char *>(kmessage->payload ), kmessage->len );
152
- external_stream_counter->addToReadBytes (kmessage->len );
153
- external_stream_counter->addToReadCounts (1 );
154
- }
155
- else
156
- {
157
- // / slower path, request virtual columns
158
- if (!current_batch.empty ())
159
- {
160
- assert (current_batch.size () == virtual_col_value_functions.size ());
161
- for (size_t i = 0 , n = virtual_col_value_functions.size (); i < n; ++i)
162
- {
163
- if (!virtual_col_value_functions[i])
164
- current_batch[i]->insertData (static_cast <const char *>(kmessage->payload ), kmessage->len );
165
- else
166
- current_batch[i]->insertMany (virtual_col_value_functions[i](kmessage), 1 );
167
- }
168
- }
169
- else
170
- {
171
- for (size_t i = 0 , n = virtual_col_value_functions.size (); i < n; ++i)
172
- {
173
- if (!virtual_col_value_functions[i])
174
- {
175
- current_batch.push_back (physical_header.getByPosition (0 ).type ->createColumn ());
176
- current_batch.back ()->insertData (static_cast <const char *>(kmessage->payload ), kmessage->len );
177
- }
178
- else
179
- {
180
- auto column = virtual_col_types[i]->createColumn ();
181
- column->insertMany (virtual_col_value_functions[i](kmessage), 1 );
182
- current_batch.push_back (std::move (column));
183
- }
184
- }
185
- }
186
- }
187
- }
188
-
189
137
void KafkaSource::parseFormat (const rd_kafka_message_t * kmessage)
190
138
{
191
139
assert (format_executor);
@@ -285,21 +233,19 @@ void KafkaSource::initConsumer(const Kafka * kafka)
285
233
void KafkaSource::initFormatExecutor (const Kafka * kafka)
286
234
{
287
235
const auto & data_format = kafka->dataFormat ();
288
- if (!data_format.empty ())
289
- {
290
- auto input_format
291
- = FormatFactory::instance ().getInputFormat (data_format, read_buffer, non_virtual_header, query_context, max_block_size, kafka->getFormatSettings (query_context));
292
236
293
- format_executor = std::make_unique<StreamingFormatExecutor>(
294
- non_virtual_header, std::move (input_format), []( const MutableColumns &, Exception &) -> size_t { return 0 ; } );
237
+ auto input_format
238
+ = FormatFactory::instance (). getInputFormat (data_format, read_buffer, non_virtual_header, query_context, max_block_size );
295
239
296
- auto converting_dag = ActionsDAG::makeConvertingActions (
297
- non_virtual_header.cloneEmpty ().getColumnsWithTypeAndName (),
298
- physical_header.cloneEmpty ().getColumnsWithTypeAndName (),
299
- ActionsDAG::MatchColumnsMode::Name);
240
+ format_executor = std::make_unique<StreamingFormatExecutor>(
241
+ non_virtual_header, std::move (input_format), [](const MutableColumns &, Exception &) -> size_t { return 0 ; });
300
242
301
- convert_non_virtual_to_physical_action = std::make_shared<ExpressionActions>(std::move (converting_dag));
302
- }
243
+ auto converting_dag = ActionsDAG::makeConvertingActions (
244
+ non_virtual_header.cloneEmpty ().getColumnsWithTypeAndName (),
245
+ physical_header.cloneEmpty ().getColumnsWithTypeAndName (),
246
+ ActionsDAG::MatchColumnsMode::Name);
247
+
248
+ convert_non_virtual_to_physical_action = std::make_shared<ExpressionActions>(std::move (converting_dag));
303
249
}
304
250
305
251
void KafkaSource::calculateColumnPositions ()
0 commit comments