MCPcopy Create free account
hub / github.com/ByConity/ByConity / readJSON

Method readJSON

src/DataTypes/Serializations/SerializationInfo.cpp:249–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void SerializationInfoByName::readJSON(ReadBuffer & in)
250{
251 String json_str;
252 readString(json_str, in);
253
254 Poco::JSON::Parser parser;
255 auto object = parser.parse(json_str).extract<Poco::JSON::Object::Ptr>();
256
257 if (!object->has(KEY_VERSION))
258 throw Exception(ErrorCodes::CORRUPTED_DATA, "Missed version of serialization infos");
259
260 if (object->getValue<size_t>(KEY_VERSION) > SERIALIZATION_INFO_VERSION)
261 throw Exception(ErrorCodes::CORRUPTED_DATA,
262 "Unknown version of serialization infos ({}). Should be less or equal than {}",
263 object->getValue<size_t>(KEY_VERSION), SERIALIZATION_INFO_VERSION);
264
265 if (object->has(KEY_COLUMNS))
266 {
267 auto array = object->getArray(KEY_COLUMNS);
268 for (const auto & elem : *array)
269 {
270 auto elem_object = elem.extract<Poco::JSON::Object::Ptr>();
271
272 if (!elem_object->has(KEY_NAME))
273 throw Exception(ErrorCodes::CORRUPTED_DATA,
274 "Missed field '{}' in SerializationInfo of columns", KEY_NAME);
275
276 auto name = elem_object->getValue<String>(KEY_NAME);
277 if (auto it = find(name); it != end())
278 it->second->fromJSON(*elem_object);
279 }
280 }
281}
282
283}

Callers 1

TESTFunction · 0.45

Calls 8

readStringFunction · 0.50
ExceptionClass · 0.50
findFunction · 0.50
endFunction · 0.50
parseMethod · 0.45
hasMethod · 0.45
getArrayMethod · 0.45
fromJSONMethod · 0.45

Tested by 1

TESTFunction · 0.36