kou commented on code in PR #38400:
URL: https://github.com/apache/arrow/pull/38400#discussion_r1369189417


##########
matlab/src/cpp/arrow/matlab/array/proxy/array.cc:
##########
@@ -44,7 +47,31 @@ namespace arrow::matlab::array::proxy {
 
     void Array::toString(libmexclass::proxy::method::Context& context) {
         ::matlab::data::ArrayFactory factory;
-        const auto str_utf8 = array->ToString();
+        
+        auto opts = arrow::PrettyPrintOptions::Defaults();
+        opts.window = 3;
+        opts.indent = 4;
+        opts.indent_size = 4;
+
+        const auto type_id = array->type()->id();
+        if (arrow::is_primitive(type_id) || arrow::is_string(type_id)) {
+            /* 
+             * Display primitive and string types horizontally without 
+             * opening and opening delimiters. Use " | " as the delimiter
+             * between elments. Below is an example Int32Array display:
+             *
+             *    1 | 2 | 3 | ... | 6 7 8

Review Comment:
   ```suggestion
                *    1 | 2 | 3 | ... | 6 | 7 | 8
   ```



##########
matlab/src/matlab/+arrow/+array/Array.m:
##########
@@ -62,8 +62,27 @@
     end
 
     methods (Access=protected)
+        function header = getHeader(obj)
+            name = matlab.mixin.CustomDisplay.getClassNameForHeader(obj);
+            numElements = obj.NumElements;
+            % TODO: Add NumValid and NumNull as properties to Array to

Review Comment:
   FYI: We can use `arrow::Array::null_count()` for them.



##########
matlab/src/matlab/+arrow/+array/Array.m:
##########
@@ -87,3 +106,22 @@ function displayScalarObject(obj)
     end
 end
 
+function str = pluralizeStringIfNeeded(num, str)
+    if num ~= 1
+        str = str + "s";
+    end
+end
+
+function formatSpec = getFormatSpec(numElems)
+    if usejava("desktop")
+        % Bold the number of elements and nulls if the desktop is enabled
+        numString = "<strong>%d</strong>";
+    else
+        numString = "%d";
+    end
+    if numElems > 0
+        formatSpec = "  %s with " + numString + " %s and " + numString + " 
%s:" + newline;
+    else
+        formatSpec = "  %s with "+ numString + " %s and " + numString + " %s" 
+ newline;

Review Comment:
   ```suggestion
           formatSpec = "  %s with " + numString + " %s and " + numString + " 
%s" + newline;
   ```



-- 
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]

Reply via email to