| 156 | private: |
| 157 | template <typename FormatFunction> |
| 158 | Status WriteValues(const Array& array, FormatFunction&& func, |
| 159 | bool indent_non_null_values = true, bool is_container = false) { |
| 160 | // `indent_non_null_values` should be false if `FormatFunction` applies |
| 161 | // indentation itself. |
| 162 | int window = is_container ? options_.container_window : options_.window; |
| 163 | for (int64_t i = 0; i < array.length(); ++i) { |
| 164 | const bool is_last = (i == array.length() - 1); |
| 165 | // check if `length == 2 * window + 1` to eliminate ellipsis for only one element |
| 166 | if ((array.length() != 2 * window + 1) && (i >= window) && |
| 167 | (i < (array.length() - window))) { |
| 168 | IndentAfterNewline(); |
| 169 | (*sink_) << "..."; |
| 170 | if (!is_last && options_.skip_new_lines) { |
| 171 | (*sink_) << options_.array_delimiters.element; |
| 172 | } |
| 173 | i = array.length() - window - 1; |
| 174 | } else if (array.IsNull(i)) { |
| 175 | IndentAfterNewline(); |
| 176 | (*sink_) << options_.null_rep; |
| 177 | if (!is_last) { |
| 178 | (*sink_) << options_.array_delimiters.element; |
| 179 | } |
| 180 | } else { |
| 181 | if (indent_non_null_values) { |
| 182 | IndentAfterNewline(); |
| 183 | } |
| 184 | RETURN_NOT_OK(func(i)); |
| 185 | if (!is_last) { |
| 186 | (*sink_) << options_.array_delimiters.element; |
| 187 | } |
| 188 | } |
| 189 | Newline(); |
| 190 | } |
| 191 | return Status::OK(); |
| 192 | } |
| 193 | |
| 194 | template <typename ArrayType, typename Formatter> |
| 195 | Status WritePrimitiveValues(const ArrayType& array, Formatter* formatter) { |