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

Method Serialize

cpp/src/arrow/extension/variable_shape_tensor.cc:83–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83std::string VariableShapeTensorType::Serialize() const {
84 JsonWriter writer;
85
86 writer.StartObject();
87
88 if (!permutation_.empty()) {
89 writer.Key("permutation");
90 writer.StartArray();
91 for (auto v : permutation_) {
92 writer.Int64(v);
93 }
94 writer.EndArray();
95 }
96
97 if (!dim_names_.empty()) {
98 writer.Key("dim_names");
99 writer.StartArray();
100 for (const auto& v : dim_names_) {
101 writer.String(v);
102 }
103 writer.EndArray();
104 }
105
106 if (!uniform_shape_.empty()) {
107 writer.Key("uniform_shape");
108 writer.StartArray();
109 for (const auto& v : uniform_shape_) {
110 if (v.has_value()) {
111 writer.Int64(*v);
112 } else {
113 writer.Null();
114 }
115 }
116 writer.EndArray();
117 }
118
119 writer.EndObject();
120
121 Result<std::string_view> json = writer.GetString();
122 // can only fail in OutOfMemory scenarios
123 ARROW_CHECK_OK(json.status());
124 return std::string(*json);
125}
126
127Result<std::shared_ptr<DataType>> VariableShapeTensorType::Deserialize(
128 std::shared_ptr<DataType> storage_type, const std::string& serialized_data) const {

Callers

nothing calls this directly

Calls 11

StartObjectMethod · 0.45
emptyMethod · 0.45
KeyMethod · 0.45
StartArrayMethod · 0.45
Int64Method · 0.45
EndArrayMethod · 0.45
StringMethod · 0.45
NullMethod · 0.45
EndObjectMethod · 0.45
GetStringMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected