-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-37979: [C++] Add support for specifying custom Array opening and closing delimiters to arrow::PrettyPrintDelimiters
#38187
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
Conversation
2. Fix typo (`open` should use `"[]"` and `close` should use `"]"`.
…elimiter` tests.
kou
left a comment
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.
+1
jorisvandenbossche
left a comment
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.
Looks good to me, thanks!
|
After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit cc1dc6a. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
… and closing delimiters to `arrow::PrettyPrintDelimiters` (apache#38187) ### Rationale for this change This is a follow up to apache#37981. in order to make the [`arrow::PrettyPrint`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L101) functionality for `arrow::Array` more flexible, it would be useful to be able to specify a custom `Array` opening and closing delimiter other than `"["` and `"]"`. For example, the MATLAB interface wraps the Arrow C++ libraries and being able to specify a custom opening and closing delimiter for `Array` would make it possible to make the display of MATLAB `arrow.array.Array` objects more MATLAB-like. In order to support custom `Array` opening and closing delimiters, this pull request adds two new properties, `open` and `close`, to the [`arrow::PrettyPrintDelimiters`](https://github.com/apache/arrow/blob/c37059ad7b87f0cbb681f6388aca0e3f02860351/cpp/src/arrow/pretty_print.h#L38) struct. This enable use cases like the ability to display an `arrow::Array` as `<1,2,3>` instead of `[1,2,3]`, by setting `options.array_delimiters.open = "<"` and `options.array_delimiters.close = ">"`. ### What changes are included in this PR? This pull request adds two new properties to the [`arrow::PrettyPrintDelimiters`](https://github.com/apache/arrow/blob/c37059ad7b87f0cbb681f6388aca0e3f02860351/cpp/src/arrow/pretty_print.h#L38) struct: 1. `open` - the opening delimiter to use for an `Array` or `ChunkedArray` (default = `[`). 1. `close` - the closing delimiter to use for an `Array` or `ChunkedArray` (default = `]`). ### Are these changes tested? Yes. 1. Added two new tests: (1) `ArrayCustomOpenCloseDelimiter` and (2) `ChunkedArrayCustomOpenCloseDelimiter`. 2. All existing tests related to `arrow::PrettyPrint` pass. ### Are there any user-facing changes? Yes. This pull request adds two new public, user-facing properties, (1) `open` (of type `std::string`) and (2) `close` (also of type `std::string`) to the `PrettyPrintDelimiters` struct. This enables client code to specify custom opening and closing delimiters to use when printing an `arrow::Array` or `arrow::ChunkedArray` by changing the values of the nested `open` and `close` properties of the `array_delimiters`/`chunked_array_delimiters` properties of `PrettyPrintOptions`. ### Notes 1. This pull request was motivated by our desire to improve the display of Arrow related classes in the MATLAB interface, but it is hopefully a generic enough change that it may benefit other use cases too. ### Future Directions 1. Now that client code can easily specify custom opening, closing, and element delimiters, it may make sense to address apache#30951. * Closes: apache#37979 Authored-by: Kevin Gurney <kgurney@mathworks.com> Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
… and closing delimiters to `arrow::PrettyPrintDelimiters` (apache#38187) ### Rationale for this change This is a follow up to apache#37981. in order to make the [`arrow::PrettyPrint`](https://github.com/apache/arrow/blob/7667b81bffcb5b361fab6d61c42ce396d98cc6e1/cpp/src/arrow/pretty_print.h#L101) functionality for `arrow::Array` more flexible, it would be useful to be able to specify a custom `Array` opening and closing delimiter other than `"["` and `"]"`. For example, the MATLAB interface wraps the Arrow C++ libraries and being able to specify a custom opening and closing delimiter for `Array` would make it possible to make the display of MATLAB `arrow.array.Array` objects more MATLAB-like. In order to support custom `Array` opening and closing delimiters, this pull request adds two new properties, `open` and `close`, to the [`arrow::PrettyPrintDelimiters`](https://github.com/apache/arrow/blob/c37059ad7b87f0cbb681f6388aca0e3f02860351/cpp/src/arrow/pretty_print.h#L38) struct. This enable use cases like the ability to display an `arrow::Array` as `<1,2,3>` instead of `[1,2,3]`, by setting `options.array_delimiters.open = "<"` and `options.array_delimiters.close = ">"`. ### What changes are included in this PR? This pull request adds two new properties to the [`arrow::PrettyPrintDelimiters`](https://github.com/apache/arrow/blob/c37059ad7b87f0cbb681f6388aca0e3f02860351/cpp/src/arrow/pretty_print.h#L38) struct: 1. `open` - the opening delimiter to use for an `Array` or `ChunkedArray` (default = `[`). 1. `close` - the closing delimiter to use for an `Array` or `ChunkedArray` (default = `]`). ### Are these changes tested? Yes. 1. Added two new tests: (1) `ArrayCustomOpenCloseDelimiter` and (2) `ChunkedArrayCustomOpenCloseDelimiter`. 2. All existing tests related to `arrow::PrettyPrint` pass. ### Are there any user-facing changes? Yes. This pull request adds two new public, user-facing properties, (1) `open` (of type `std::string`) and (2) `close` (also of type `std::string`) to the `PrettyPrintDelimiters` struct. This enables client code to specify custom opening and closing delimiters to use when printing an `arrow::Array` or `arrow::ChunkedArray` by changing the values of the nested `open` and `close` properties of the `array_delimiters`/`chunked_array_delimiters` properties of `PrettyPrintOptions`. ### Notes 1. This pull request was motivated by our desire to improve the display of Arrow related classes in the MATLAB interface, but it is hopefully a generic enough change that it may benefit other use cases too. ### Future Directions 1. Now that client code can easily specify custom opening, closing, and element delimiters, it may make sense to address apache#30951. * Closes: apache#37979 Authored-by: Kevin Gurney <kgurney@mathworks.com> Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Rationale for this change
This is a follow up to #37981.
in order to make the
arrow::PrettyPrintfunctionality forarrow::Arraymore flexible, it would be useful to be able to specify a customArrayopening and closing delimiter other than"["and"]".For example, the MATLAB interface wraps the Arrow C++ libraries and being able to specify a custom opening and closing delimiter for
Arraywould make it possible to make the display of MATLABarrow.array.Arrayobjects more MATLAB-like.In order to support custom
Arrayopening and closing delimiters, this pull request adds two new properties,openandclose, to thearrow::PrettyPrintDelimitersstruct.This enable use cases like the ability to display an
arrow::Arrayas<1,2,3>instead of[1,2,3], by settingoptions.array_delimiters.open = "<"andoptions.array_delimiters.close = ">".What changes are included in this PR?
This pull request adds two new properties to the
arrow::PrettyPrintDelimitersstruct:open- the opening delimiter to use for anArrayorChunkedArray(default =[).close- the closing delimiter to use for anArrayorChunkedArray(default =]).Are these changes tested?
Yes.
ArrayCustomOpenCloseDelimiterand (2)ChunkedArrayCustomOpenCloseDelimiter.arrow::PrettyPrintpass.Are there any user-facing changes?
Yes.
This pull request adds two new public, user-facing properties, (1)
open(of typestd::string) and (2)close(also of typestd::string) to thePrettyPrintDelimitersstruct. This enables client code to specify custom opening and closing delimiters to use when printing anarrow::Arrayorarrow::ChunkedArrayby changing the values of the nestedopenandcloseproperties of thearray_delimiters/chunked_array_delimitersproperties ofPrettyPrintOptions.Notes
Future Directions
arrow::PrettyPrintDelimiters#37979