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

Method Prepare

be/src/exec/hbase/hbase-scan-node.cc:65–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65Status HBaseScanNode::Prepare(RuntimeState* state) {
66 RETURN_IF_ERROR(ScanNode::Prepare(state));
67 hbase_read_timer_ = PROFILE_TotalRawHBaseReadTime.Instantiate(runtime_profile());
68 AddBytesReadCounters();
69
70 hbase_scanner_.reset(
71 new HBaseTableScanner(this, ExecEnv::GetInstance()->htable_factory(), state));
72
73 tuple_desc_ = state->desc_tbl().GetTupleDescriptor(tuple_id_);
74 if (tuple_desc_ == NULL) {
75 // TODO: make sure we print all available diagnostic output to our error log
76 return Status("Failed to get tuple descriptor.");
77 }
78 // The data retrieved from HBase via result_.raw() is sorted by family/qualifier.
79 // Here, we re-order the slots from the query by family/qualifier, exploiting the
80 // known sort order of the columns retrieved from HBase, to avoid family/qualifier
81 // comparisons.
82 hbase_table_ = static_cast<const HBaseTableDescriptor*>(tuple_desc_->table_desc());
83 const vector<HBaseTableDescriptor::HBaseColumnDescriptor>& cols = hbase_table_->cols();
84 const vector<SlotDescriptor*>& slots = tuple_desc_->slots();
85 sorted_non_key_slots_.reserve(slots.size());
86 for (int i = 0; i < slots.size(); ++i) {
87 const HBaseTableDescriptor::HBaseColumnDescriptor& col = cols[slots[i]->col_pos()];
88 if (col.family == ":key") {
89 row_key_slot_ = slots[i];
90 row_key_binary_encoded_ = col.binary_encoded;
91 } else {
92 sorted_non_key_slots_.push_back(slots[i]);
93 }
94 }
95 // This is not needed if flag use_hms_column_order_for_hbase_tables=false as the columns
96 // will be already ordered in the FE, but sort it anyway to avoid relying on this.
97 sort(sorted_non_key_slots_.begin(), sorted_non_key_slots_.end(),
98 [&](const SlotDescriptor* a, const SlotDescriptor* b) -> bool {
99 const HBaseTableDescriptor::HBaseColumnDescriptor& cola = cols[a->col_pos()];
100 const HBaseTableDescriptor::HBaseColumnDescriptor& colb = cols[b->col_pos()];
101 return cola.family == colb.family
102 ? cola.qualifier < colb.qualifier : cola.family < colb.family;
103 });
104
105 // Create list of family/qualifier pointers in same sort order as sorted_non_key_slots_.
106 sorted_cols_.reserve(sorted_non_key_slots_.size());
107 for (int i = 0; i < sorted_non_key_slots_.size(); ++i) {
108 sorted_cols_.push_back(&cols[sorted_non_key_slots_[i]->col_pos()]);
109 }
110
111 // TODO(marcel): add int tuple_idx_[] indexed by TupleId somewhere in runtime-state.h
112 tuple_idx_ = 0;
113
114 // Convert ScanRangeParamsPB to ScanRanges
115 DCHECK(scan_range_params_ != NULL)
116 << "Must call SetScanRanges() before calling Prepare()";
117 for (const ScanRangeParamsPB& params : *scan_range_params_) {
118 DCHECK(params.scan_range().has_hbase_key_range());
119 const HBaseKeyRangePB& key_range = params.scan_range().hbase_key_range();
120 scan_range_vector_.push_back(HBaseTableScanner::ScanRange());
121 HBaseTableScanner::ScanRange& sr = scan_range_vector_.back();
122 if (key_range.has_startkey()) {

Callers

nothing calls this directly

Calls 15

sortFunction · 0.85
OKFunction · 0.85
htable_factoryMethod · 0.80
GetTupleDescriptorMethod · 0.80
reserveMethod · 0.80
col_posMethod · 0.80
push_backMethod · 0.80
set_start_keyMethod · 0.80
set_stop_keyMethod · 0.80
AddInfoStringMethod · 0.80
fully_qualified_nameMethod · 0.80
StatusClass · 0.70

Tested by

no test coverage detected