pitrou commented on code in PR #13783:
URL: https://github.com/apache/arrow/pull/13783#discussion_r939904517
##########
cpp/src/arrow/type_traits.h:
##########
@@ -942,6 +991,10 @@ static inline bool is_primitive(Type::type type_id) {
return false;
}
+/// \brief Check for a base-binary-like type
+///
Review Comment:
```suggestion
///
/// This predicate doesn't match fixed-size binary types.
```
##########
cpp/src/arrow/type_traits.h:
##########
@@ -901,6 +918,34 @@ static inline bool is_floating(Type::type type_id) {
return false;
}
+/// \brief Check for a numeric type
+///
Review Comment:
Since we are at it, let's make the docstrings even more explicit
```suggestion
///
/// This predicate doesn't match decimals (see `is_decimal`).
```
##########
cpp/src/arrow/type_traits.h:
##########
@@ -977,10 +1038,82 @@ static inline bool is_large_binary_like(Type::type
type_id) {
return false;
}
+/// \brief Check for a binary type
+///
+/// \param[in] type_id the type-id to check
+/// \return whether type-id is a binary type one
+static inline bool is_binary(Type::type type_id) {
+ switch (type_id) {
+ case Type::BINARY:
+ case Type::LARGE_BINARY:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+/// \brief Check for a string type
+///
+/// \param[in] type_id the type-id to check
+/// \return whether type-id is a string type one
+static inline bool is_string(Type::type type_id) {
+ switch (type_id) {
+ case Type::STRING:
+ case Type::LARGE_STRING:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+/// \brief Check for a temporal type
+///
+/// \param[in] type_id the type-id to check
+/// \return whether type-id is a temporal type one
+static inline bool is_temporal(Type::type type_id) {
+ switch (type_id) {
+ case Type::DATE32:
+ case Type::DATE64:
+ case Type::TIME32:
+ case Type::TIME64:
+ case Type::TIMESTAMP:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+/// \brief Check for an interval type
+///
+/// \param[in] type_id the type-id to check
+/// \return whether type-id is an interval type one
+static inline bool is_interval(Type::type type_id) {
+ switch (type_id) {
+ case Type::INTERVAL_MONTHS:
+ case Type::INTERVAL_DAY_TIME:
+ case Type::INTERVAL_MONTH_DAY_NANO:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+/// \brief Check for a dictionary type
+///
+/// \param[in] type_id the type-id to check
+/// \return whether type-id is a dictionary type one
static inline bool is_dictionary(Type::type type_id) {
return type_id == Type::DICTIONARY;
}
+/// \brief Check for a fixed-size-binary type
+///
Review Comment:
```suggestion
///
/// This predicate also matches decimals.
```
##########
cpp/src/arrow/type_traits.h:
##########
@@ -912,6 +957,10 @@ static inline bool is_decimal(Type::type type_id) {
return false;
}
+/// \brief Check for a primitive type
+///
Review Comment:
```suggestion
///
/// This predicate doesn't match null, decimals and binary-like types.
```
##########
cpp/src/arrow/type_traits.h:
##########
@@ -1103,6 +1252,182 @@ static inline int offset_bit_width(Type::type type_id) {
return 0;
}
+/// \brief Check for an integer type (signed or unsigned)
+///
+/// \param[in] type the type to check
+/// \return whether type is an integer type
+///
+/// Convenience for checking using the types' id
Review Comment:
Did you mean this?
```suggestion
/// Convenience for checking using the type's id
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]