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

Method Serialize

cpp/src/arrow/extension/fixed_shape_tensor.cc:74–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74std::string FixedShapeTensorType::Serialize() const {
75 rj::Document document;
76 document.SetObject();
77 rj::Document::AllocatorType& allocator = document.GetAllocator();
78
79 rj::Value shape(rj::kArrayType);
80 for (auto v : shape_) {
81 shape.PushBack(v, allocator);
82 }
83 document.AddMember(rj::Value("shape", allocator), shape, allocator);
84
85 if (!permutation_.empty()) {
86 rj::Value permutation(rj::kArrayType);
87 for (auto v : permutation_) {
88 permutation.PushBack(v, allocator);
89 }
90 document.AddMember(rj::Value("permutation", allocator), permutation, allocator);
91 }
92
93 if (!dim_names_.empty()) {
94 rj::Value dim_names(rj::kArrayType);
95 for (const std::string& v : dim_names_) {
96 dim_names.PushBack(rj::Value{}.SetString(v.c_str(), allocator), allocator);
97 }
98 document.AddMember(rj::Value("dim_names", allocator), dim_names, allocator);
99 }
100
101 rj::StringBuffer buffer;
102 rj::Writer<rj::StringBuffer> writer(buffer);
103 document.Accept(writer);
104 return buffer.GetString();
105}
106
107Result<std::shared_ptr<DataType>> FixedShapeTensorType::Deserialize(
108 std::shared_ptr<DataType> storage_type, const std::string& serialized_data) const {

Callers

nothing calls this directly

Calls 6

ValueFunction · 0.50
GetAllocatorMethod · 0.45
emptyMethod · 0.45
SetStringMethod · 0.45
AcceptMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected