| 116 | } |
| 117 | |
| 118 | Result<std::shared_ptr<Array>> DictionaryArray::FromArrays( |
| 119 | const std::shared_ptr<DataType>& type, const std::shared_ptr<Array>& indices, |
| 120 | const std::shared_ptr<Array>& dictionary) { |
| 121 | if (type->id() != Type::DICTIONARY) { |
| 122 | return Status::TypeError("Expected a dictionary type"); |
| 123 | } |
| 124 | const auto& dict = checked_cast<const DictionaryType&>(*type); |
| 125 | if (indices->type_id() != dict.index_type()->id()) { |
| 126 | return Status::TypeError( |
| 127 | "Dictionary type's index type does not match " |
| 128 | "indices array's type"); |
| 129 | } |
| 130 | RETURN_NOT_OK(internal::CheckIndexBounds(*indices->data(), |
| 131 | static_cast<uint64_t>(dictionary->length()))); |
| 132 | return std::make_shared<DictionaryArray>(type, indices, dictionary); |
| 133 | } |
| 134 | |
| 135 | bool DictionaryArray::CanCompareIndices(const DictionaryArray& other) const { |
| 136 | DCHECK(dictionary()->type()->Equals(other.dictionary()->type())) |
nothing calls this directly
no test coverage detected