MCPcopy Create free account
hub / github.com/apache/arrow / GetSchemaMetadata

Function GetSchemaMetadata

cpp/src/parquet/arrow/writer.cc:111–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

OpenMethod · 0.85

Calls 9

key_value_metadataFunction · 0.85
store_schemaMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
SerializeSchemaFunction · 0.50
metadataMethod · 0.45
CopyMethod · 0.45
ToStringMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected