| 366 | } |
| 367 | |
| 368 | Status HdfsTableSink::Send(RuntimeState* state, RowBatch* batch) { |
| 369 | SCOPED_TIMER(profile()->total_time_counter()); |
| 370 | expr_results_pool_->Clear(); |
| 371 | RETURN_IF_ERROR(state->CheckQueryState()); |
| 372 | // We don't do any work for an empty batch. |
| 373 | if (batch->num_rows() == 0) return Status::OK(); |
| 374 | |
| 375 | // If there are no partition keys then just pass the whole batch to one partition. |
| 376 | if (dynamic_partition_key_expr_evals_.empty()) { |
| 377 | // If there are no dynamic keys just use an empty key. |
| 378 | PartitionPair* partition_pair; |
| 379 | RETURN_IF_ERROR( |
| 380 | GetOutputPartition(state, nullptr, ROOT_PARTITION_KEY, &partition_pair, false)); |
| 381 | DCHECK(partition_pair->second.empty()); |
| 382 | RETURN_IF_ERROR(WriteRowsToPartition(state, batch, partition_pair->first.get())); |
| 383 | } else if (input_is_clustered_) { |
| 384 | RETURN_IF_ERROR(WriteClusteredRowBatch(state, batch)); |
| 385 | } else { |
| 386 | for (int i = 0; i < batch->num_rows(); ++i) { |
| 387 | const TupleRow* current_row = batch->GetRow(i); |
| 388 | |
| 389 | string key; |
| 390 | GetHashTblKey(current_row, dynamic_partition_key_expr_evals_, &key); |
| 391 | PartitionPair* partition_pair = nullptr; |
| 392 | RETURN_IF_ERROR( |
| 393 | GetOutputPartition(state, current_row, key, &partition_pair, false)); |
| 394 | partition_pair->second.push_back(i); |
| 395 | } |
| 396 | for (PartitionMap::value_type& partition : partition_keys_to_output_partitions_) { |
| 397 | PartitionPair& partition_pair = partition.second; |
| 398 | if (!partition_pair.second.empty()) { |
| 399 | RETURN_IF_ERROR(WriteRowsToPartition(state, batch, partition_pair.first.get(), |
| 400 | partition_pair.second)); |
| 401 | partition_pair.second.clear(); |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | return Status::OK(); |
| 407 | } |
| 408 | |
| 409 | Status HdfsTableSink::FlushFinal(RuntimeState* state) { |
| 410 | DCHECK(!closed_); |
no test coverage detected