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