pitrou commented on code in PR #35794:
URL: https://github.com/apache/arrow/pull/35794#discussion_r1210618414
##########
cpp/src/arrow/datum.h:
##########
@@ -155,49 +194,74 @@ struct ARROW_EXPORT Datum {
/// \see arrow::util::TotalBufferSize for caveats
int64_t TotalBufferSize() const;
+ /// \brief Get the stored ArrayData in mutable form, primarily used in kernel
+ /// implementations
ArrayData* mutable_array() const { return this->array().get(); }
+ /// \brief Retrieve the stored array as Array
+ /// \throws std::bad_variant_access if the datum is not an array
std::shared_ptr<Array> make_array() const;
+ /// \brief Retrieve the chunked array stored
+ /// \throws std::bad_variant_access if the datum is not a chunked array
const std::shared_ptr<ChunkedArray>& chunked_array() const {
return std::get<std::shared_ptr<ChunkedArray>>(this->value);
}
+ /// \brief Retrieve the record batch stored
+ /// \throws std::bad_variant_access if the datum is not a record batch
const std::shared_ptr<RecordBatch>& record_batch() const {
return std::get<std::shared_ptr<RecordBatch>>(this->value);
}
+ /// \brief Retrieve the table stored
+ /// \throws std::bad_variant_access if the datum is not a table
const std::shared_ptr<Table>& table() const {
return std::get<std::shared_ptr<Table>>(this->value);
}
+ /// \brief Retrieve the scalar stored
+ /// \throws std::bad_variant_access if the datum is not a scalar
const std::shared_ptr<Scalar>& scalar() const {
return std::get<std::shared_ptr<Scalar>>(this->value);
}
+ /// \brief Retrieve the datum as its concrete array type
+ /// \throws std::bad_variant_access if the datum is not an array
+ /// \tparam ExactType the expected array type, may cause undefined behavior
if it is not
+ /// the type of the stored array
template <typename ExactType>
std::shared_ptr<ExactType> array_as() const {
return internal::checked_pointer_cast<ExactType>(this->make_array());
}
+ /// \brief Retrieve the datum as its concrete scalar type
+ /// \throws std::bad_variant_access if the datum is not a scalar
+ /// \tparam ExactType the expected scalar type, may cause undefined behavior
if it is
+ /// not the type of the stored scalar
template <typename ExactType>
const ExactType& scalar_as() const {
return internal::checked_cast<const ExactType&>(*this->scalar());
}
+ /// \brief True if Datum contains an array
bool is_array() const { return this->kind() == Datum::ARRAY; }
+ /// \brief True if Datum contains a chunked array
bool is_chunked_array() const { return this->kind() == Datum::CHUNKED_ARRAY;
}
+ /// \brief True if Datum contains an array or a chunked array
bool is_arraylike() const {
return this->kind() == Datum::ARRAY || this->kind() ==
Datum::CHUNKED_ARRAY;
}
+ /// \brief True if Datum contains a scalar
bool is_scalar() const { return this->kind() == Datum::SCALAR; }
/// \brief True if Datum contains a scalar or array-like data
bool is_value() const { return this->is_arraylike() || this->is_scalar(); }
+ /// \brief Returns the null count. Only valid for scalar and array-like data
Review Comment:
```suggestion
/// \brief Return the null count.
///
/// Only valid for scalar and array-like data.
```
--
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]