pitrou commented on code in PR #46536:
URL: https://github.com/apache/arrow/pull/46536#discussion_r2102065585
##########
cpp/src/arrow/pretty_print.cc:
##########
@@ -232,9 +242,9 @@ class ArrayPrinter : public PrettyPrinter {
enable_if_has_string_view<T, Status> WriteDataValues(const ArrayType& array)
{
return WriteValues(array, [&](int64_t i) {
if constexpr (T::is_utf8) {
- (*sink_) << "\"" << array.GetView(i) << "\"";
+ this->Write("\"" + std::string{array.GetView(i)} + "\"");
Review Comment:
We could perhaps avoid the string copy by turning:
```c++
void PrettyPrinter::Write(std::string_view data);
```
into
```c++
void PrettyPrinter::Write(std::string_view data, int max_chars);
```
and then changing this snippet into:
```suggestion
(*sink_) << "\"";
this->Write(array.GetView(i), options_.element_size_limit - 2);
(*sink_) << "\"";
```
Another possibility is to let `Write` take an arbitrary number of arguments
and then:
```suggestion
this->Write("\"", array.GetView(i), "\"");
```
```
##########
cpp/src/arrow/pretty_print_test.cc:
##########
@@ -772,6 +772,11 @@ TEST_F(TestPrettyPrint, BinaryNoNewlines) {
options.window = 2;
expected = "[666F6F,626172,...,,FF]";
CheckPrimitive<BinaryType, std::string>(options, is_valid, values, expected,
false);
+
+ // With truncated element size
+ options.element_size_limit = 1;
+ expected = "[6+5,6+5,...,,F+1]";
Review Comment:
The output is a bit confusing. How about something like `6 (...)` or `6 (...
5 chars omitted)` instead of `6+5`?
(of course, with such a small element size it seems a bit ridiculous to
append that much, but I suspect that will not be a common case)
##########
cpp/src/arrow/pretty_print_test.cc:
##########
@@ -772,6 +772,11 @@ TEST_F(TestPrettyPrint, BinaryNoNewlines) {
options.window = 2;
expected = "[666F6F,626172,...,,FF]";
CheckPrimitive<BinaryType, std::string>(options, is_valid, values, expected,
false);
+
+ // With truncated element size
+ options.element_size_limit = 1;
+ expected = "[6+5,6+5,...,,F+1]";
+ CheckPrimitive<BinaryType, std::string>(options, is_valid, values, expected,
false);
Review Comment:
Can you add similar tests for StringType and FixedSizeBinaryType?
--
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]