| 827 | } |
| 828 | |
| 829 | void ConfigureDictionary(const DictionaryPage* page) { |
| 830 | int encoding = static_cast<int>(page->encoding()); |
| 831 | if (page->encoding() == Encoding::PLAIN_DICTIONARY || |
| 832 | page->encoding() == Encoding::PLAIN) { |
| 833 | encoding = static_cast<int>(Encoding::RLE_DICTIONARY); |
| 834 | } |
| 835 | |
| 836 | auto it = decoders_.find(encoding); |
| 837 | if (it != decoders_.end()) { |
| 838 | throw ParquetException("Column cannot have more than one dictionary."); |
| 839 | } |
| 840 | |
| 841 | if (page->encoding() == Encoding::PLAIN_DICTIONARY || |
| 842 | page->encoding() == Encoding::PLAIN) { |
| 843 | auto dictionary = MakeTypedDecoder<DType>(Encoding::PLAIN, descr_, pool_); |
| 844 | dictionary->SetData(page->num_values(), page->data(), page->size()); |
| 845 | |
| 846 | // The dictionary is fully decoded during DictionaryDecoder::Init, so the |
| 847 | // DictionaryPage buffer is no longer required after this step |
| 848 | // |
| 849 | // TODO(wesm): investigate whether this all-or-nothing decoding of the |
| 850 | // dictionary makes sense and whether performance can be improved |
| 851 | |
| 852 | std::unique_ptr<DictDecoder<DType>> decoder = MakeDictDecoder<DType>(descr_, pool_); |
| 853 | decoder->SetDict(dictionary.get()); |
| 854 | decoders_[encoding] = |
| 855 | std::unique_ptr<DecoderType>(dynamic_cast<DecoderType*>(decoder.release())); |
| 856 | } else { |
| 857 | ParquetException::NYI("only plain dictionary encoding has been implemented"); |
| 858 | } |
| 859 | |
| 860 | new_dictionary_ = true; |
| 861 | current_decoder_.SetDecoder(decoders_[encoding].get()); |
| 862 | ARROW_DCHECK(current_decoder_); |
| 863 | } |
| 864 | |
| 865 | // Initialize repetition and definition level decoders on the next data page. |
| 866 |
nothing calls this directly
no test coverage detected