MCPcopy Create free account
hub / github.com/apache/arrow / MaybeUnsignedIndexType

Function MaybeUnsignedIndexType

cpp/src/arrow/builder.cc:53–72  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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.
53std::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

Callers 4

FinishDeltaMethod · 0.85
typeMethod · 0.85
FinishInternalMethod · 0.85
typeMethod · 0.85

Calls 2

UnreachableFunction · 0.85
idMethod · 0.45

Tested by

no test coverage detected