| 71 | } |
| 72 | |
| 73 | std::string FixedShapeTensorType::Serialize() const { |
| 74 | JsonWriter writer; |
| 75 | |
| 76 | writer.StartObject(); |
| 77 | |
| 78 | writer.Key("shape"); |
| 79 | writer.StartArray(); |
| 80 | for (auto v : shape_) { |
| 81 | writer.Int64(v); |
| 82 | } |
| 83 | writer.EndArray(); |
| 84 | |
| 85 | if (!permutation_.empty()) { |
| 86 | writer.Key("permutation"); |
| 87 | writer.StartArray(); |
| 88 | for (auto v : permutation_) { |
| 89 | writer.Int64(v); |
| 90 | } |
| 91 | writer.EndArray(); |
| 92 | } |
| 93 | |
| 94 | if (!dim_names_.empty()) { |
| 95 | writer.Key("dim_names"); |
| 96 | writer.StartArray(); |
| 97 | for (const auto& v : dim_names_) { |
| 98 | writer.String(v); |
| 99 | } |
| 100 | writer.EndArray(); |
| 101 | } |
| 102 | |
| 103 | writer.EndObject(); |
| 104 | |
| 105 | Result<std::string_view> json = writer.GetString(); |
| 106 | // can only fail in OutOfMemory scenarios |
| 107 | ARROW_CHECK_OK(json.status()); |
| 108 | return std::string(*json); |
| 109 | } |
| 110 | |
| 111 | Result<std::shared_ptr<DataType>> FixedShapeTensorType::Deserialize( |
| 112 | std::shared_ptr<DataType> storage_type, const std::string& serialized_data) const { |
nothing calls this directly
no test coverage detected