-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-4124: [C++] Draft Aggregate and Sum kernels #3407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3e9451e
92a4e03
f1044be
c4b5b21
440ed3d
d5ea4c8
0ff3bae
cadc709
f062737
9bd1f25
27d32b5
985e9ce
c272059
568ba09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,25 +57,66 @@ class ARROW_EXPORT OpKernel { | |
|
|
||
| /// \brief Placeholder for Scalar values until we implement these | ||
| struct ARROW_EXPORT Scalar { | ||
| ~Scalar() {} | ||
| util::variant<bool, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, | ||
| int64_t, float, double> | ||
| value; | ||
|
|
||
| ARROW_DISALLOW_COPY_AND_ASSIGN(Scalar); | ||
| explicit Scalar(bool value) : value(value) {} | ||
| explicit Scalar(uint8_t value) : value(value) {} | ||
| explicit Scalar(int8_t value) : value(value) {} | ||
| explicit Scalar(uint16_t value) : value(value) {} | ||
| explicit Scalar(int16_t value) : value(value) {} | ||
| explicit Scalar(uint32_t value) : value(value) {} | ||
| explicit Scalar(int32_t value) : value(value) {} | ||
| explicit Scalar(uint64_t value) : value(value) {} | ||
| explicit Scalar(int64_t value) : value(value) {} | ||
| explicit Scalar(float value) : value(value) {} | ||
| explicit Scalar(double value) : value(value) {} | ||
|
|
||
| Type::type kind() const { | ||
| switch (this->value.which()) { | ||
| case 0: | ||
|
||
| return Type::BOOL; | ||
| case 1: | ||
| return Type::UINT8; | ||
| case 2: | ||
| return Type::INT8; | ||
| case 3: | ||
| return Type::UINT16; | ||
| case 4: | ||
| return Type::INT16; | ||
| case 5: | ||
| return Type::UINT32; | ||
| case 6: | ||
| return Type::INT32; | ||
| case 7: | ||
| return Type::UINT64; | ||
| case 8: | ||
| return Type::INT64; | ||
| case 9: | ||
| return Type::FLOAT; | ||
| case 10: | ||
| return Type::DOUBLE; | ||
| default: | ||
| return Type::NA; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| /// \class Datum | ||
| /// \brief Variant type for various Arrow C++ data structures | ||
| struct ARROW_EXPORT Datum { | ||
| enum type { NONE, SCALAR, ARRAY, CHUNKED_ARRAY, RECORD_BATCH, TABLE, COLLECTION }; | ||
|
|
||
| util::variant<decltype(NULLPTR), std::shared_ptr<Scalar>, std::shared_ptr<ArrayData>, | ||
| util::variant<decltype(NULLPTR), Scalar, std::shared_ptr<ArrayData>, | ||
| std::shared_ptr<ChunkedArray>, std::shared_ptr<RecordBatch>, | ||
| std::shared_ptr<Table>, std::vector<Datum>> | ||
| value; | ||
|
|
||
| /// \brief Empty datum, to be populated elsewhere | ||
| Datum() : value(NULLPTR) {} | ||
|
|
||
| Datum(const std::shared_ptr<Scalar>& value) // NOLINT implicit conversion | ||
| Datum(const Scalar& value) // NOLINT implicit conversion | ||
| : value(value) {} | ||
| Datum(const std::shared_ptr<ArrayData>& value) // NOLINT implicit conversion | ||
| : value(value) {} | ||
|
|
@@ -147,6 +188,10 @@ struct ARROW_EXPORT Datum { | |
| return util::get<std::vector<Datum>>(this->value); | ||
| } | ||
|
|
||
| Scalar scalar() const { return util::get<Scalar>(this->value); } | ||
|
|
||
| bool is_array() const { return this->kind() == Datum::ARRAY; } | ||
|
|
||
| bool is_arraylike() const { | ||
| return this->kind() == Datum::ARRAY || this->kind() == Datum::CHUNKED_ARRAY; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. I'm not sure about this. See https://issues.apache.org/jira/browse/ARROW-47. It's OK to leave this as is but marked experimental
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file feel like a kludge to me. Let's not do anything else involving scalar outputs until resolving ARROW-47. I'll put up a patch for that tomorrow with any luck