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

Method GetNextInternal

be/src/exec/json/hdfs-json-scanner.cc:141–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141Status HdfsJsonScanner::GetNextInternal(RowBatch* row_batch) {
142 DCHECK(!eos_);
143 DCHECK_GE(scanner_state_, OPENED);
144 DCHECK_NE(scanner_state_, FINISHED);
145
146 current_pool_ = row_batch->tuple_data_pool();
147
148 if (scanner_state_ == OPENED) {
149 // Find the first tuple. If scanner_state_ is not SCANNING, it means we went through
150 // the entire scan range without finding a single tuple. The bytes will be picked up
151 // by the previous scan range in the same file.
152 RETURN_IF_ERROR(FindFirstTuple());
153 if (scanner_state_ != SCANNING) {
154 eos_ = true;
155 scanner_state_ = FINISHED;
156 return Status::OK();
157 }
158 }
159
160 int64_t tuple_buffer_size;
161 RETURN_IF_ERROR(
162 row_batch->ResizeAndAllocateTupleBuffer(state_, &tuple_buffer_size, &tuple_mem_));
163 tuple_ = reinterpret_cast<Tuple*>(tuple_mem_);
164 tuple_row_ = row_batch->GetRow(row_batch->AddRow());
165
166 while (scanner_state_ == SCANNING) {
167 num_tuples_materialized_ = 0;
168 int num_tuples = 0;
169 int max_tuples = row_batch->capacity() - row_batch->num_rows();
170
171 RETURN_IF_ERROR(ParseWrapper(max_tuples, &num_tuples));
172 COUNTER_ADD(scan_node_->rows_read_counter(), num_tuples);
173
174 // Because the processes of parsing JSON, materializing tuples, and even reading data
175 // are intertwined, it can be expensive to accurately time them individually.
176 // Therefore, we using this method to measure the time it takes to materialize tuples,
177 // please note that the value obtained will always be inflated because the time it
178 // takes to parse JSON is also included.
179 // TODO: find a better way.
180 COUNTER_SET(scan_node_->materialize_tuple_timer(),
181 parse_json_timer_->value() - get_buffer_timer_->value());
182
183 RETURN_IF_ERROR(CommitRows(num_tuples_materialized_, row_batch));
184
185 if (row_batch->AtCapacity() || scan_node_->ReachedLimitShared()) break;
186 }
187
188 if (scanner_state_ >= PAST_SCANNING || scan_node_->ReachedLimitShared()) {
189 eos_ = true;
190 scanner_state_ = FINISHED;
191 }
192 return Status::OK();
193}
194
195Status HdfsJsonScanner::FindFirstTuple() {
196 DCHECK_EQ(scanner_state_, OPENED);

Callers

nothing calls this directly

Calls 12

OKFunction · 0.85
tuple_data_poolMethod · 0.80
rows_read_counterMethod · 0.80
ReachedLimitSharedMethod · 0.80
GetRowMethod · 0.45
AddRowMethod · 0.45
capacityMethod · 0.45
num_rowsMethod · 0.45
valueMethod · 0.45
AtCapacityMethod · 0.45

Tested by

no test coverage detected