| 162 | } |
| 163 | |
| 164 | Status HBaseScanNode::GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos) { |
| 165 | SCOPED_TIMER(runtime_profile_->total_time_counter()); |
| 166 | ScopedGetNextEventAdder ea(this, eos); |
| 167 | RETURN_IF_ERROR(ExecDebugAction(TExecNodePhase::GETNEXT, state)); |
| 168 | RETURN_IF_CANCELLED(state); |
| 169 | RETURN_IF_ERROR(QueryMaintenance(state)); |
| 170 | |
| 171 | if (scan_range_vector_.empty() || ReachedLimit()) { |
| 172 | *eos = true; |
| 173 | return Status::OK(); |
| 174 | } |
| 175 | *eos = false; |
| 176 | |
| 177 | // Create new tuple buffer for row_batch. |
| 178 | int64_t tuple_buffer_size; |
| 179 | uint8_t* tuple_buffer; |
| 180 | RETURN_IF_ERROR( |
| 181 | row_batch->ResizeAndAllocateTupleBuffer(state, &tuple_buffer_size, &tuple_buffer)); |
| 182 | Tuple* tuple = reinterpret_cast<Tuple*>(tuple_buffer); |
| 183 | tuple->Init(tuple_buffer_size); |
| 184 | |
| 185 | // Indicates whether the current row has conversion errors. Used for error reporting. |
| 186 | bool error_in_row = false; |
| 187 | |
| 188 | // Indicates whether there are more rows to process. Set in hbase_scanner_.Next(). |
| 189 | JNIEnv* env = JniUtil::GetJNIEnv(); |
| 190 | bool has_next = false; |
| 191 | while (true) { |
| 192 | RETURN_IF_CANCELLED(state); |
| 193 | RETURN_IF_ERROR(QueryMaintenance(state)); |
| 194 | if (row_batch->AtCapacity() || ReachedLimit()) { |
| 195 | // hang on to last allocated chunk in pool, we'll keep writing into it in the |
| 196 | // next GetNext() call |
| 197 | *eos = ReachedLimit(); |
| 198 | return Status::OK(); |
| 199 | } |
| 200 | RETURN_IF_ERROR(hbase_scanner_->Next(env, &has_next)); |
| 201 | if (!has_next) { |
| 202 | *eos = true; |
| 203 | return Status::OK(); |
| 204 | } |
| 205 | |
| 206 | int row_idx = row_batch->AddRow(); |
| 207 | TupleRow* row = row_batch->GetRow(row_idx); |
| 208 | row->SetTuple(tuple_idx_, tuple); |
| 209 | |
| 210 | { |
| 211 | // Measure row key and column value materialization time |
| 212 | SCOPED_TIMER(materialize_tuple_timer()); |
| 213 | |
| 214 | // Write row key slot. |
| 215 | if (row_key_slot_ != NULL) { |
| 216 | if (row_key_binary_encoded_) { |
| 217 | RETURN_IF_ERROR(hbase_scanner_->GetRowKey(env, row_key_slot_, tuple)); |
| 218 | } else { |
| 219 | void* key; |
| 220 | int key_length; |
| 221 | RETURN_IF_ERROR(hbase_scanner_->GetRowKey(env, &key, &key_length)); |
nothing calls this directly
no test coverage detected