Skip to content

[C++] Add a VisitIntegerType helper #50595

Description

@pitrou

Describe the enhancement requested

In visit_type_inline.h we have a VisitType that dispatches all existing data types to a generic callable (presumably a lambda or template function).

It would be useful to have a similar VisitIntegerType helper that assumes its input is an integer type. This would help implementing helpers for dictionary indices, take indices, etc.

For example this snippet could be reimplemented more tersely using said helper:

const auto& dict_array_type = internal::checked_cast<const DictionaryType&>(*span.type);
switch (dict_array_type.index_type()->id()) {
case Type::UINT8:
return LogicalNullCount<UInt8Type>(span);
case Type::INT8:
return LogicalNullCount<Int8Type>(span);
case Type::UINT16:
return LogicalNullCount<UInt16Type>(span);
case Type::INT16:
return LogicalNullCount<Int16Type>(span);
case Type::UINT32:
return LogicalNullCount<UInt32Type>(span);
case Type::INT32:
return LogicalNullCount<Int32Type>(span);
case Type::UINT64:
return LogicalNullCount<UInt64Type>(span);
default:
return LogicalNullCount<Int64Type>(span);
}

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions