Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 08:47:19

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
0017 
0018 #pragma once
0019 
0020 #include <iosfwd>
0021 #include <string>
0022 #include <utility>
0023 
0024 #include "arrow/util/visibility.h"
0025 
0026 namespace arrow {
0027 
0028 class Array;
0029 class ChunkedArray;
0030 class RecordBatch;
0031 class Schema;
0032 class Status;
0033 class Table;
0034 
0035 /// \class PrettyPrintDelimiters
0036 /// \brief Options for controlling which delimiters to use when printing
0037 /// an Array or ChunkedArray.
0038 struct ARROW_EXPORT PrettyPrintDelimiters {
0039   /// Delimiter to use when opening an Array or ChunkedArray (e.g. "[")
0040   std::string open = "[";
0041 
0042   /// Delimiter to use when closing an Array or ChunkedArray (e.g. "]")
0043   std::string close = "]";
0044 
0045   /// Delimiter for separating individual elements of an Array (e.g. ","),
0046   /// or individual chunks of a ChunkedArray
0047   std::string element = ",";
0048 
0049   /// Create a PrettyPrintDelimiters instance with default values
0050   static PrettyPrintDelimiters Defaults() { return PrettyPrintDelimiters(); }
0051 };
0052 
0053 /// \class PrettyPrintOptions
0054 /// \brief Options for controlling how various Arrow types should be printed.
0055 struct ARROW_EXPORT PrettyPrintOptions {
0056   PrettyPrintOptions() = default;
0057 
0058   PrettyPrintOptions(int indent,  // NOLINT runtime/explicit
0059                      int window = 10, int indent_size = 2, std::string null_rep = "null",
0060                      bool skip_new_lines = false, bool truncate_metadata = true,
0061                      int container_window = 2)
0062       : indent(indent),
0063         indent_size(indent_size),
0064         window(window),
0065         container_window(container_window),
0066         null_rep(std::move(null_rep)),
0067         skip_new_lines(skip_new_lines),
0068         truncate_metadata(truncate_metadata) {}
0069 
0070   /// Create a PrettyPrintOptions instance with default values
0071   static PrettyPrintOptions Defaults() { return PrettyPrintOptions(); }
0072 
0073   /// Number of spaces to shift entire formatted object to the right
0074   int indent = 0;
0075 
0076   /// Size of internal indents
0077   int indent_size = 2;
0078 
0079   /// Maximum number of elements to show at the beginning and at the end.
0080   int window = 10;
0081 
0082   /// Maximum number of elements to show at the beginning and at the end, for elements
0083   /// that are containers (that is, list in ListArray and chunks in ChunkedArray)
0084   int container_window = 2;
0085 
0086   /// String to use for representing a null value, defaults to "null"
0087   std::string null_rep = "null";
0088 
0089   /// Skip new lines between elements, defaults to false
0090   bool skip_new_lines = false;
0091 
0092   /// Limit display of each KeyValueMetadata key/value pair to a single line at
0093   /// 80 character width
0094   bool truncate_metadata = true;
0095 
0096   /// If true, display field metadata when pretty-printing a Schema
0097   bool show_field_metadata = true;
0098 
0099   /// If true, display schema metadata when pretty-printing a Schema
0100   bool show_schema_metadata = true;
0101 
0102   /// Delimiters to use when printing an Array
0103   PrettyPrintDelimiters array_delimiters = PrettyPrintDelimiters::Defaults();
0104 
0105   /// Delimiters to use when printing a ChunkedArray
0106   PrettyPrintDelimiters chunked_array_delimiters = PrettyPrintDelimiters::Defaults();
0107 };
0108 
0109 /// \brief Print human-readable representation of RecordBatch
0110 ARROW_EXPORT
0111 Status PrettyPrint(const RecordBatch& batch, int indent, std::ostream* sink);
0112 
0113 ARROW_EXPORT
0114 Status PrettyPrint(const RecordBatch& batch, const PrettyPrintOptions& options,
0115                    std::ostream* sink);
0116 
0117 /// \brief Print human-readable representation of Table
0118 ARROW_EXPORT
0119 Status PrettyPrint(const Table& table, const PrettyPrintOptions& options,
0120                    std::ostream* sink);
0121 
0122 /// \brief Print human-readable representation of Array
0123 ARROW_EXPORT
0124 Status PrettyPrint(const Array& arr, int indent, std::ostream* sink);
0125 
0126 /// \brief Print human-readable representation of Array
0127 ARROW_EXPORT
0128 Status PrettyPrint(const Array& arr, const PrettyPrintOptions& options,
0129                    std::ostream* sink);
0130 
0131 /// \brief Print human-readable representation of Array
0132 ARROW_EXPORT
0133 Status PrettyPrint(const Array& arr, const PrettyPrintOptions& options,
0134                    std::string* result);
0135 
0136 /// \brief Print human-readable representation of ChunkedArray
0137 ARROW_EXPORT
0138 Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& options,
0139                    std::ostream* sink);
0140 
0141 /// \brief Print human-readable representation of ChunkedArray
0142 ARROW_EXPORT
0143 Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& options,
0144                    std::string* result);
0145 
0146 ARROW_EXPORT
0147 Status PrettyPrint(const Schema& schema, const PrettyPrintOptions& options,
0148                    std::ostream* sink);
0149 
0150 ARROW_EXPORT
0151 Status PrettyPrint(const Schema& schema, const PrettyPrintOptions& options,
0152                    std::string* result);
0153 
0154 ARROW_EXPORT
0155 Status DebugPrint(const Array& arr, int indent);
0156 
0157 }  // namespace arrow