| 49 | std::shared_ptr<arrow::Array> Array::unwrap() { return array; } |
| 50 | |
| 51 | void Array::toString(libmexclass::proxy::method::Context& context) { |
| 52 | ::matlab::data::ArrayFactory factory; |
| 53 | |
| 54 | auto opts = arrow::PrettyPrintOptions::Defaults(); |
| 55 | opts.window = 3; |
| 56 | opts.indent = 4; |
| 57 | opts.indent_size = 4; |
| 58 | |
| 59 | const auto type_id = array->type()->id(); |
| 60 | if (arrow::is_primitive(type_id) || arrow::is_string(type_id)) { |
| 61 | /* |
| 62 | * Display primitive and string types horizontally without |
| 63 | * opening and closing delimiters. Use " | " as the delimiter |
| 64 | * between elements. Below is an example Int32Array display: |
| 65 | * |
| 66 | * 1 | 2 | 3 | ... | 6 | 7 | 8 |
| 67 | */ |
| 68 | opts.skip_new_lines = true; |
| 69 | opts.array_delimiters.open = ""; |
| 70 | opts.array_delimiters.close = ""; |
| 71 | opts.array_delimiters.element = " | "; |
| 72 | } |
| 73 | |
| 74 | std::stringstream ss; |
| 75 | MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(arrow::PrettyPrint(*array, opts, &ss), context, |
| 76 | error::ARRAY_PRETTY_PRINT_FAILED); |
| 77 | |
| 78 | const auto str_utf8 = opts.skip_new_lines ? " " + ss.str() : ss.str(); |
| 79 | |
| 80 | MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(const auto str_utf16, |
| 81 | arrow::util::UTF8StringToUTF16(str_utf8), context, |
| 82 | error::UNICODE_CONVERSION_ERROR_ID); |
| 83 | auto str_mda = factory.createScalar(str_utf16); |
| 84 | context.outputs[0] = str_mda; |
| 85 | } |
| 86 | |
| 87 | void Array::getNumElements(libmexclass::proxy::method::Context& context) { |
| 88 | ::matlab::data::ArrayFactory factory; |
no test coverage detected