| 218 | } |
| 219 | |
| 220 | Status 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 | |
| 264 | Status HdfsTextScanner::ResetScanner() { |
| 265 | // Assumes that N partition keys occupy entries 0 through N-1 in materialized_slots_. |
nothing calls this directly
no test coverage detected