Return the unsigned integer type of the same width when an unsigned dictionary index type was requested (GH-37476). The adaptive indices builder only ever produces signed integer types. Dictionary indices are non-negative, so the signed and unsigned integer types of a given width have identical memory layout and reporting one as the other is value-preserving. The width stays adaptive, as it is fo
| 51 | /// threshold: a uint8 index widens after 128 distinct values rather than the 256 a real |
| 52 | /// uint8 could hold, so the extra bit does not delay widening. |
| 53 | std::shared_ptr<DataType> MaybeUnsignedIndexType( |
| 54 | const std::shared_ptr<DataType>& index_type, bool use_unsigned_index) { |
| 55 | if (!use_unsigned_index) { |
| 56 | return index_type; |
| 57 | } |
| 58 | switch (index_type->id()) { |
| 59 | case Type::INT8: |
| 60 | return ::arrow::uint8(); |
| 61 | case Type::INT16: |
| 62 | return ::arrow::uint16(); |
| 63 | case Type::INT32: |
| 64 | return ::arrow::uint32(); |
| 65 | case Type::INT64: |
| 66 | return ::arrow::uint64(); |
| 67 | default: |
| 68 | // The adaptive index builder only ever produces signed int8/16/32/64, so no |
| 69 | // other type reaches this point when an unsigned index was requested. |
| 70 | Unreachable("MaybeUnsignedIndexType: adaptive dictionary index type is not signed"); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | } // namespace internal |
| 75 |
no test coverage detected