37#define TYPE_VISIT_INLINE(TYPE_CLASS) \
38 case TYPE_CLASS##Type::kTypeId: \
39 return visitor->Visit( \
40 iceberg::internal::checked_cast<const TYPE_CLASS##Type&>(type), \
41 std::forward<ARGS>(args)...);
63template <
typename VISITOR,
typename... ARGS>
66 ICEBERG_GENERATE_FOR_ALL_TYPES(TYPE_VISIT_INLINE);
70 return NotImplemented(
"Type not implemented");
73#undef TYPE_VISIT_INLINE
75#define TYPE_VISIT_INLINE(TYPE_CLASS) \
76 case TYPE_CLASS##Type::kTypeId: \
77 return std::forward<VISITOR>(visitor)( \
78 internal::checked_cast<const TYPE_CLASS##Type&>(type), \
79 std::forward<ARGS>(args)...);
92template <
typename VISITOR,
typename... ARGS>
93inline auto VisitType(
const Type& type, VISITOR&& visitor, ARGS&&... args)
94 ->
decltype(std::forward<VISITOR>(visitor)(type, args...)) {
95 switch (type.type_id()) {
96 ICEBERG_GENERATE_FOR_ALL_TYPES(TYPE_VISIT_INLINE);
102#undef TYPE_VISIT_INLINE
104#define TYPE_ID_VISIT_INLINE(TYPE_CLASS) \
105 case TYPE_CLASS##Type::kTypeId: { \
106 const TYPE_CLASS##Type* concrete_ptr = nullptr; \
107 return visitor->Visit(concrete_ptr, std::forward<ARGS>(args)...); \
116template <
typename VISITOR,
typename... ARGS>
119 ICEBERG_GENERATE_FOR_ALL_TYPES(TYPE_ID_VISIT_INLINE);
123 return NotImplemented(
"Type not implemented");
126#undef TYPE_ID_VISIT_INLINE
155template <
typename VISITOR,
typename... ARGS>
157#define SCHEMA_VISIT_ACTION(TYPE_CLASS) \
158 return visitor->Visit##TYPE_CLASS( \
159 internal::checked_cast<const TYPE_CLASS##Type&>(type), \
160 std::forward<ARGS>(args)...);
166#undef SCHEMA_VISIT_ACTION
Checked cast functions for dynamic_cast and static_cast. Adapted from Apache Arrow https://github....
Interface for a data type for a field.
Definition type.h:44
virtual TypeId type_id() const =0
Get the type ID.
Definition expected.h:1199
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
auto VisitTypeCategory(const Type &type, VISITOR *visitor, ARGS &&... args)
Visit a type using a categorical visitor pattern.
Definition visit_type.h:156
void unreachable() noexcept
Marks a branch the program can never take.
Definition unreachable.h:35
Status VisitTypeIdInline(TypeId id, VISITOR *visitor, ARGS &&... args)
Calls visitor with a nullptr of the corresponding concrete type class.
Definition visit_type.h:117
auto VisitType(const Type &type, VISITOR &&visitor, ARGS &&... args) -> decltype(std::forward< VISITOR >(visitor)(type, args...))
Call visitor with the corresponding concrete type class.
Definition visit_type.h:93
Status VisitTypeInline(const Type &type, VISITOR *visitor, ARGS &&... args)
Calls visitor with the corresponding concrete type class.
Definition visit_type.h:64
TypeId
A data type.
Definition type_fwd.h:37
Define Result, Status, and error helpers.
Portable stand-in for std::unreachable.
Define macros for generating type visitors.
#define ICEBERG_TYPE_SWITCH_WITH_PRIMITIVE_DEFAULT(ACTION)
Generate switch-case for schema visitor pattern.
Definition visitor_generate.h:64