MCPcopy Create free account
hub / github.com/apache/impala / InitNewRange

Method InitNewRange

be/src/exec/text/hdfs-text-scanner.cc:220–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220Status HdfsTextScanner::InitNewRange() {
221 DCHECK_EQ(scan_state_, CONSTRUCTED);
222
223 auto compression_type = stream_ ->file_desc()->file_compression;
224 // Update the decompressor based on the compression type of the file in the context.
225 DCHECK(compression_type != THdfsCompression::SNAPPY)
226 << "FE should have generated SNAPPY_BLOCKED instead.";
227 // In Hadoop, text files compressed into .DEFLATE files contain
228 // deflate with zlib wrappings as opposed to raw deflate, which
229 // is what THdfsCompression::DEFLATE implies. Since deflate is
230 // the default compression algorithm used in Hadoop, it makes
231 // sense to map it to type DEFAULT in Impala instead
232 if (compression_type == THdfsCompression::DEFLATE) {
233 compression_type = THdfsCompression::DEFAULT;
234 }
235 RETURN_IF_ERROR(UpdateDecompressor(compression_type));
236
237 HdfsPartitionDescriptor* hdfs_partition = context_->partition_descriptor();
238 char field_delim = hdfs_partition->field_delim();
239 char collection_delim = hdfs_partition->collection_delim();
240 if (scan_node_->materialized_slots().size() == 0) {
241 field_delim = '\0';
242 collection_delim = '\0';
243 }
244
245 delimited_text_parser_.reset(new TupleDelimitedTextParser(
246 scan_node_->hdfs_table()->num_cols(), scan_node_->num_partition_keys(),
247 scan_node_->is_materialized_col(), hdfs_partition->line_delim(),
248 field_delim, collection_delim, hdfs_partition->escape_char()));
249 text_converter_.reset(new TextConverter(hdfs_partition->escape_char(),
250 scan_node_->hdfs_table()->null_column_value(), true,
251 state_->strict_mode()));
252
253 const auto& encoding = hdfs_partition->encoding_value();
254 if (!encoding.empty() && encoding != "UTF-8") {
255 decoder_.reset(new CharCodec(data_buffer_pool_.get(), encoding,
256 hdfs_partition->line_delim(), scan_node_->tuple_desc()->string_slots().empty()));
257 }
258
259 RETURN_IF_ERROR(ResetScanner());
260 scan_state_ = SCAN_RANGE_INITIALIZED;
261 return Status::OK();
262}
263
264Status HdfsTextScanner::ResetScanner() {
265 // Assumes that N partition keys occupy entries 0 through N-1 in materialized_slots_.

Callers

nothing calls this directly

Calls 15

OKFunction · 0.85
file_descMethod · 0.80
partition_descriptorMethod · 0.80
field_delimMethod · 0.80
collection_delimMethod · 0.80
num_colsMethod · 0.80
hdfs_tableMethod · 0.80
num_partition_keysMethod · 0.80
is_materialized_colMethod · 0.80
line_delimMethod · 0.80
strict_modeMethod · 0.80
resetMethod · 0.65

Tested by

no test coverage detected