-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-1569: [C++] Kernel functions for determining monotonicity (ascending or descending) for well-ordered types #11937
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
23380f6
52ddd12
a0ae495
dd66eb3
347e102
841829c
275dfe8
6816819
4284fda
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 |
|---|---|---|
|
|
@@ -188,6 +188,35 @@ class ARROW_EXPORT PartitionNthOptions : public FunctionOptions { | |
| NullPlacement null_placement; | ||
| }; | ||
|
|
||
| /// \brief Options for IsMonotonic | ||
| class ARROW_EXPORT IsMonotonicOptions : public FunctionOptions { | ||
| public: | ||
| enum NullHandling { | ||
| /// Ignore nulls. | ||
| IGNORE_NULLS, | ||
| /// Use min value of element type as the value of nulls. | ||
| /// -Inf for floating point numbers. | ||
| USE_MIN_VALUE, | ||
| /// Use max value of element type as the value of nulls. | ||
| /// Inf for floating point numbers. | ||
| USE_MAX_VALUE | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ordering of nulls and NaNs were also discussed in the sorting function. I would expect that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that a sort before invoking this kernel should result in true for the corresponding check. However I feel the null handling variants are a bit confusing: I think if we want to allow users to define order of unordered values (both for sorting and this kernel) we need something like this: bool compare_nulls = false; // default: any null results in false outputs (or error in case of sort)
bool compare_nans = false; // default: any nan results in false outputs (or error in case of sort)
// these are not needed when sorting
bool nulls_equal = false; // when nulls are compared, are they considered equal?
bool nans_equal = false; // when nans are compared, are they considered equal?
// when both nulls and nans are compared
enum Ordering { Less, Equal, Greater }
Ordering nan_compared_with_null; // when comparing nulls and nans, what ordering should be used? |
||
|
|
||
| explicit IsMonotonicOptions(NullHandling null_handling = IGNORE_NULLS, | ||
| bool floating_approximate = false, | ||
| double epsilon = kDefaultAbsoluteTolerance); | ||
| constexpr static char const kTypeName[] = "IsMonotonicOptions"; | ||
| static IsMonotonicOptions Defaults() { return IsMonotonicOptions(); } | ||
|
|
||
| /// Define how nulls are handled. | ||
| NullHandling null_handling = IGNORE_NULLS; | ||
| /// Whether or not to use approximate floating point number comparisons. | ||
| bool floating_approximate = false; | ||
| /// Epsilon (error bound) value used when approximately comparing floating points | ||
| /// numbers. | ||
| double epsilon = kDefaultAbsoluteTolerance; | ||
| }; | ||
|
|
||
| /// @} | ||
|
|
||
| /// \brief Filter with a boolean selection filter | ||
|
|
@@ -494,6 +523,28 @@ Result<Datum> DictionaryEncode( | |
| const DictionaryEncodeOptions& options = DictionaryEncodeOptions::Defaults(), | ||
| ExecContext* ctx = NULLPTR); | ||
|
|
||
| /// \brief Returns information about the monotonicity of the elements in an | ||
| /// array with well-ordered elements. | ||
| /// | ||
| /// Returns a struct scalar with type | ||
| /// struct< | ||
| /// increasing: boolean, | ||
| /// strictly_increasing: boolean, | ||
| /// decreasing: boolean, | ||
| /// strictly_decreasing: boolean | ||
| /// > | ||
| /// | ||
| /// \param[in] data input data. | ||
| /// \param[in] options see IsMonotonicOptions for more information. | ||
| /// \param[in] ctx the function execution context, optional. | ||
| /// \return resulting datum as a struct scalar. | ||
| /// | ||
| /// \since x.0.0 \note API not yet finalized | ||
| ARROW_EXPORT | ||
| Result<Datum> IsMonotonic( | ||
| const Datum& data, const IsMonotonicOptions& options = IsMonotonicOptions::Defaults(), | ||
| ExecContext* ctx = NULLPTR); | ||
|
|
||
| // ---------------------------------------------------------------------- | ||
| // Deprecated functions | ||
|
|
||
|
|
||
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.
Based on the other enum names, use only
IGNORE, sinceenum NullHandlingalready specifies this is for nulls.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.
I had that initially, but IGNORE caused compilation issues on Windows.
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.
Well, nevermind.