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

Method Init

be/src/exec/hdfs-scan-node-base.cc:162–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160const int UNEXPECTED_REMOTE_BYTES_WARN_THRESHOLD = 64 * 1024 * 1024;
161
162Status HdfsScanPlanNode::Init(const TPlanNode& tnode, FragmentState* state) {
163 RETURN_IF_ERROR(ScanPlanNode::Init(tnode, state));
164
165 tuple_id_ = tnode.hdfs_scan_node.tuple_id;
166 tuple_desc_ = state->desc_tbl().GetTupleDescriptor(tuple_id_);
167 DCHECK(tuple_desc_->table_desc() != NULL);
168 hdfs_table_ = static_cast<const HdfsTableDescriptor*>(tuple_desc_->table_desc());
169
170 // Parse Avro table schema if applicable
171 const string& avro_schema_str = hdfs_table_->avro_schema();
172 if (!avro_schema_str.empty()) {
173 avro_schema_t avro_schema;
174 int error = avro_schema_from_json_length(
175 avro_schema_str.c_str(), avro_schema_str.size(), &avro_schema);
176 if (error != 0) {
177 return Status(Substitute("Failed to parse table schema: $0", avro_strerror()));
178 }
179 RETURN_IF_ERROR(AvroSchemaElement::ConvertSchema(avro_schema, avro_schema_.get()));
180 }
181
182 // Gather materialized partition-key slots and non-partition slots.
183 const vector<SlotDescriptor*>& slots = tuple_desc_->slots();
184 for (size_t i = 0; i < slots.size(); ++i) {
185 if (UNLIKELY(slots[i]->IsVirtual())) {
186 virtual_column_slots_.push_back(slots[i]);
187 } else if (hdfs_table_->IsClusteringCol(slots[i])) {
188 partition_key_slots_.push_back(slots[i]);
189 } else {
190 materialized_slots_.push_back(slots[i]);
191 }
192 }
193
194 // Order the materialized slots such that for schemaless file formats (e.g. text) the
195 // order corresponds to the physical order in files. For formats where the file schema
196 // is independent of the table schema (e.g. Avro, Parquet), this step is not necessary.
197 sort(materialized_slots_.begin(), materialized_slots_.end(),
198 SlotDescriptor::ColPathLessThan);
199
200 // Populate mapping from slot path to index into materialized_slots_.
201 for (int i = 0; i < materialized_slots_.size(); ++i) {
202 path_to_materialized_slot_idx_[materialized_slots_[i]->col_path()] = i;
203 }
204
205 // Initialize is_materialized_col_
206 is_materialized_col_.resize(hdfs_table_->num_cols());
207 for (int i = 0; i < hdfs_table_->num_cols(); ++i) {
208 is_materialized_col_[i] =
209 GetMaterializedSlotIdx(vector<int>(1, i)) != HdfsScanNodeBase::SKIP_COLUMN;
210 }
211
212 // Add collection item conjuncts
213 for (const auto& entry : tnode.hdfs_scan_node.collection_conjuncts) {
214 TupleDescriptor* tuple_desc = state->desc_tbl().GetTupleDescriptor(entry.first);
215 RowDescriptor* collection_row_desc =
216 state->obj_pool()->Add(new RowDescriptor(tuple_desc, /* is_nullable */ false));
217 DCHECK(conjuncts_map_.find(entry.first) == conjuncts_map_.end());
218 RETURN_IF_ERROR(ScalarExpr::Create(
219 entry.second, *collection_row_desc, state, &conjuncts_map_[entry.first]));

Calls 15

SubstituteFunction · 0.85
sortFunction · 0.85
CreateClass · 0.85
OKFunction · 0.85
GetTupleDescriptorMethod · 0.80
IsVirtualMethod · 0.80
push_backMethod · 0.80
IsClusteringColMethod · 0.80
resizeMethod · 0.80
num_colsMethod · 0.80
StatusClass · 0.70

Tested by

no test coverage detected