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