mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 09:05:47 +08:00
Add length() to Datum.
Convenience method for sub-type supporting the length method.
This commit is contained in:
1 parent
cdedd85f9c
commit
53703acdd1
1 file changed
+14
@@ -201,6 +201,20 @@ struct ARROW_EXPORT Datum {
|
||||
return NULLPTR;
|
||||
}
|
||||
|
||||
/// \brief The value length of the variant, if any
|
||||
///
|
||||
/// \return -1 if no type
|
||||
int64_t length() const {
|
||||
if (this->kind() == Datum::ARRAY) {
|
||||
return util::get<std::shared_ptr<ArrayData>>(this->value)->length;
|
||||
} else if (this->kind() == Datum::CHUNKED_ARRAY) {
|
||||
return util::get<std::shared_ptr<ChunkedArray>>(this->value)->length();
|
||||
} else if (this->kind() == Datum::SCALAR) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Equals(const Datum& other) const {
|
||||
if (this->kind() != other.kind()) return false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user