| 603 | |
| 604 | template <typename T> |
| 605 | bool DictDecoder<T>::DecodeNextValue(T* value) { |
| 606 | // IMPALA-959: Use memcpy() instead of '=' to set *value: addresses are not always 16 |
| 607 | // byte aligned for Decimal16Values. |
| 608 | int32_t num_repeats = data_decoder_.NextNumRepeats(); |
| 609 | DCHECK_GE(num_repeats, 0); |
| 610 | if (num_repeats > 0) { |
| 611 | const IndexType idx = data_decoder_.GetRepeatedValue(num_repeats); |
| 612 | if (UNLIKELY(idx >= dict_.size())) return false; |
| 613 | memcpy(&decoded_values_[0], &dict_[idx], sizeof(T)); |
| 614 | memcpy(value, &decoded_values_[0], sizeof(T)); |
| 615 | num_repeats_ = num_repeats - 1; |
| 616 | return true; |
| 617 | } else { |
| 618 | int32_t num_literals = data_decoder_.NextNumLiterals(); |
| 619 | if (UNLIKELY(num_literals == 0)) return false; |
| 620 | |
| 621 | DCHECK_GT(num_literals, 0); |
| 622 | int32_t num_to_decode = std::min(num_literals, DICT_DECODER_BUFFER_SIZE); |
| 623 | StrideWriter<T> dst(&decoded_values_[0], sizeof(T)); |
| 624 | if (UNLIKELY(!data_decoder_.DecodeLiteralValues(num_to_decode, dict_.data(), |
| 625 | dict_.size(), &dst))) { |
| 626 | return false; |
| 627 | } |
| 628 | num_literal_values_ = num_to_decode; |
| 629 | memcpy(value, &decoded_values_[0], sizeof(T)); |
| 630 | next_literal_idx_ = 1; |
| 631 | return true; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | template<typename T> |
| 636 | inline void DictEncoder<T>::WriteDict(uint8_t* buffer) { |
nothing calls this directly
no test coverage detected