| 54 | const std::shared_ptr<Array>& DictionaryArray::indices() const { return indices_; } |
| 55 | |
| 56 | int64_t DictionaryArray::GetValueIndex(int64_t i) const { |
| 57 | const uint8_t* indices_data = data_->buffers[1]->data(); |
| 58 | // If the value is non-negative then we can use the unsigned path |
| 59 | switch (indices_->type_id()) { |
| 60 | case Type::UINT8: |
| 61 | case Type::INT8: |
| 62 | return static_cast<int64_t>(indices_data[data_->offset + i]); |
| 63 | case Type::UINT16: |
| 64 | case Type::INT16: |
| 65 | return static_cast<int64_t>( |
| 66 | reinterpret_cast<const uint16_t*>(indices_data)[data_->offset + i]); |
| 67 | case Type::UINT32: |
| 68 | case Type::INT32: |
| 69 | return static_cast<int64_t>( |
| 70 | reinterpret_cast<const uint32_t*>(indices_data)[data_->offset + i]); |
| 71 | case Type::UINT64: |
| 72 | case Type::INT64: |
| 73 | return static_cast<int64_t>( |
| 74 | reinterpret_cast<const uint64_t*>(indices_data)[data_->offset + i]); |
| 75 | default: |
| 76 | ARROW_CHECK(false) << "unreachable"; |
| 77 | return -1; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | DictionaryArray::DictionaryArray(const std::shared_ptr<ArrayData>& data) |
| 82 | : dict_type_(checked_cast<const DictionaryType*>(data->type.get())) { |