| 108 | } |
| 109 | |
| 110 | Status GetSchemaMetadata(const ::arrow::Schema& schema, ::arrow::MemoryPool* pool, |
| 111 | const ArrowWriterProperties& properties, |
| 112 | std::shared_ptr<const KeyValueMetadata>* out) { |
| 113 | if (!properties.store_schema()) { |
| 114 | *out = nullptr; |
| 115 | return Status::OK(); |
| 116 | } |
| 117 | |
| 118 | static const std::string kArrowSchemaKey = "ARROW:schema"; |
| 119 | std::shared_ptr<KeyValueMetadata> result; |
| 120 | if (schema.metadata()) { |
| 121 | result = schema.metadata()->Copy(); |
| 122 | } else { |
| 123 | result = ::arrow::key_value_metadata({}, {}); |
| 124 | } |
| 125 | |
| 126 | ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Buffer> serialized, |
| 127 | ::arrow::ipc::SerializeSchema(schema, pool)); |
| 128 | |
| 129 | // The serialized schema is not UTF-8, which is required for Thrift |
| 130 | std::string schema_as_string = serialized->ToString(); |
| 131 | std::string schema_base64 = ::arrow::util::base64_encode(schema_as_string); |
| 132 | result->Append(kArrowSchemaKey, std::move(schema_base64)); |
| 133 | *out = std::move(result); |
| 134 | return Status::OK(); |
| 135 | } |
| 136 | |
| 137 | // Manages writing nested parquet columns with support for all nested types |
| 138 | // supported by parquet. |
no test coverage detected