| 720 | } |
| 721 | |
| 722 | void ConfigureDictionary(const DictionaryPage* page) { |
| 723 | int encoding = static_cast<int>(page->encoding()); |
| 724 | if (page->encoding() == Encoding::PLAIN_DICTIONARY || |
| 725 | page->encoding() == Encoding::PLAIN) { |
| 726 | encoding = static_cast<int>(Encoding::RLE_DICTIONARY); |
| 727 | } |
| 728 | |
| 729 | auto it = decoders_.find(encoding); |
| 730 | if (it != decoders_.end()) { |
| 731 | throw ParquetException("Column cannot have more than one dictionary."); |
| 732 | } |
| 733 | |
| 734 | if (page->encoding() == Encoding::PLAIN_DICTIONARY || |
| 735 | page->encoding() == Encoding::PLAIN) { |
| 736 | auto dictionary = MakeTypedDecoder<DType>(Encoding::PLAIN, descr_, pool_); |
| 737 | dictionary->SetData(page->num_values(), page->data(), page->size()); |
| 738 | |
| 739 | // The dictionary is fully decoded during DictionaryDecoder::Init, so the |
| 740 | // DictionaryPage buffer is no longer required after this step |
| 741 | // |
| 742 | // TODO(wesm): investigate whether this all-or-nothing decoding of the |
| 743 | // dictionary makes sense and whether performance can be improved |
| 744 | |
| 745 | std::unique_ptr<DictDecoder<DType>> decoder = MakeDictDecoder<DType>(descr_, pool_); |
| 746 | decoder->SetDict(dictionary.get()); |
| 747 | decoders_[encoding] = |
| 748 | std::unique_ptr<DecoderType>(dynamic_cast<DecoderType*>(decoder.release())); |
| 749 | } else { |
| 750 | ParquetException::NYI("only plain dictionary encoding has been implemented"); |
| 751 | } |
| 752 | |
| 753 | new_dictionary_ = true; |
| 754 | current_decoder_ = decoders_[encoding].get(); |
| 755 | ARROW_DCHECK(current_decoder_); |
| 756 | } |
| 757 | |
| 758 | // Initialize repetition and definition level decoders on the next data page. |
| 759 |
nothing calls this directly
no test coverage detected