TODO: consider computing size of batches as they are built up
| 442 | |
| 443 | // TODO: consider computing size of batches as they are built up |
| 444 | int64_t RowBatch::TotalByteSize(DedupMap* distinct_tuples) { |
| 445 | DCHECK(distinct_tuples == nullptr || distinct_tuples->size() == 0); |
| 446 | int64_t result = 0; |
| 447 | vector<int> tuple_count(row_desc_->tuple_descriptors().size(), 0); |
| 448 | |
| 449 | // Sum total variable length byte sizes. |
| 450 | for (int i = 0; i < num_rows_; ++i) { |
| 451 | for (int j = 0; j < num_tuples_per_row_; ++j) { |
| 452 | Tuple* tuple = GetRow(i)->GetTuple(j); |
| 453 | if (UNLIKELY(tuple == nullptr)) continue; |
| 454 | // Only count the data of unique tuples. |
| 455 | if (LIKELY(i > 0) && UNLIKELY(GetRow(i - 1)->GetTuple(j) == tuple)) { |
| 456 | // Fast tuple deduplication for adjacent rows. |
| 457 | continue; |
| 458 | } else if (UNLIKELY(distinct_tuples != nullptr)) { |
| 459 | if (row_desc_->tuple_descriptors()[j]->byte_size() == 0) continue; |
| 460 | bool inserted = distinct_tuples->InsertIfNotPresent(tuple, -1); |
| 461 | if (!inserted) continue; |
| 462 | } |
| 463 | result += tuple->VarlenByteSize( |
| 464 | *row_desc_->tuple_descriptors()[j], true /*assume_smallify*/); |
| 465 | ++tuple_count[j]; |
| 466 | } |
| 467 | } |
| 468 | // Compute sum of fixed component of tuple sizes. |
| 469 | for (int j = 0; j < num_tuples_per_row_; ++j) { |
| 470 | result += row_desc_->tuple_descriptors()[j]->byte_size() * tuple_count[j]; |
| 471 | } |
| 472 | return result; |
| 473 | } |
| 474 | |
| 475 | Status RowBatch::ResizeAndAllocateTupleBuffer( |
| 476 | RuntimeState* state, int64_t* buffer_size, uint8_t** buffer) { |
nothing calls this directly
no test coverage detected