| 771 | .ValueOrDie()} {} |
| 772 | |
| 773 | Result<std::shared_ptr<Scalar>> DictionaryScalar::GetEncodedValue() const { |
| 774 | const auto& dict_type = checked_cast<DictionaryType&>(*type); |
| 775 | |
| 776 | if (!is_valid) { |
| 777 | return MakeNullScalar(dict_type.value_type()); |
| 778 | } |
| 779 | |
| 780 | int64_t index_value = 0; |
| 781 | switch (dict_type.index_type()->id()) { |
| 782 | case Type::UINT8: |
| 783 | index_value = |
| 784 | static_cast<int64_t>(checked_cast<const UInt8Scalar&>(*value.index).value); |
| 785 | break; |
| 786 | case Type::INT8: |
| 787 | index_value = |
| 788 | static_cast<int64_t>(checked_cast<const Int8Scalar&>(*value.index).value); |
| 789 | break; |
| 790 | case Type::UINT16: |
| 791 | index_value = |
| 792 | static_cast<int64_t>(checked_cast<const UInt16Scalar&>(*value.index).value); |
| 793 | break; |
| 794 | case Type::INT16: |
| 795 | index_value = |
| 796 | static_cast<int64_t>(checked_cast<const Int16Scalar&>(*value.index).value); |
| 797 | break; |
| 798 | case Type::UINT32: |
| 799 | index_value = |
| 800 | static_cast<int64_t>(checked_cast<const UInt32Scalar&>(*value.index).value); |
| 801 | break; |
| 802 | case Type::INT32: |
| 803 | index_value = |
| 804 | static_cast<int64_t>(checked_cast<const Int32Scalar&>(*value.index).value); |
| 805 | break; |
| 806 | case Type::UINT64: |
| 807 | index_value = |
| 808 | static_cast<int64_t>(checked_cast<const UInt64Scalar&>(*value.index).value); |
| 809 | break; |
| 810 | case Type::INT64: |
| 811 | index_value = |
| 812 | static_cast<int64_t>(checked_cast<const Int64Scalar&>(*value.index).value); |
| 813 | break; |
| 814 | default: |
| 815 | return Status::TypeError("Not implemented dictionary index type"); |
| 816 | break; |
| 817 | } |
| 818 | return value.dictionary->GetScalar(index_value); |
| 819 | } |
| 820 | |
| 821 | std::shared_ptr<DictionaryScalar> DictionaryScalar::Make(std::shared_ptr<Scalar> index, |
| 822 | std::shared_ptr<Array> dict) { |
no test coverage detected