MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / ParseSchemaMergeMethods

Function ParseSchemaMergeMethods

src/common/stats_store.cpp:326–363  ·  view source on GitHub ↗

Parse merge strategy from schema (type_int + resolution_method).

Source from the content-addressed store, hash-verified

324
325// Parse merge strategy from schema (type_int + resolution_method).
326std::unordered_map<uint32_t, StatMerge>
327ParseSchemaMergeMethods(const std::vector<BkvNode>& schemaRoot) {
328 std::unordered_map<uint32_t, StatMerge> out;
329
330 const BkvNode* statsSec = nullptr;
331 for (const auto& top : schemaRoot) {
332 if (top.type != BKV_SECTION) continue;
333 if (auto* s = BkvFind(top.children, "stats")) { statsSec = s; break; }
334 if (top.name == "stats") { statsSec = &top; break; }
335 }
336 if (!statsSec) return out;
337
338 for (const auto& stat : statsSec->children) {
339 if (stat.type != BKV_SECTION) continue;
340 bool numeric = !stat.name.empty();
341 for (char c : stat.name) { if (c < '0' || c > '9') { numeric = false; break; } }
342 if (!numeric) continue;
343 uint32_t statId = (uint32_t)strtoul(stat.name.c_str(), nullptr, 10);
344
345 int typeInt = 0, resMeth = 0;
346 if (const BkvNode* ti = BkvFind(stat.children, "type_int"))
347 typeInt = (int)ti->intVal;
348 if (const BkvNode* rm = BkvFind(stat.children, "resolution_method"))
349 resMeth = (int)rm->intVal;
350
351 if (typeInt == 4) {
352 out[statId] = StatMerge::BitwiseOr;
353 } else if (resMeth == 1) {
354 out[statId] = StatMerge::BitwiseOr;
355 } else if (resMeth == 2) {
356 // type_int: 1=INT (signed), 2=FLOAT, 3=AVGRATE (float)
357 out[statId] = (typeInt >= 2) ? StatMerge::MaxFloat : StatMerge::MaxInt;
358 } else {
359 out[statId] = StatMerge::Overwrite;
360 }
361 }
362 return out;
363}
364
365} // namespace
366

Callers 1

ImportNativeStatsFunction · 0.85

Calls 1

BkvFindFunction · 0.85

Tested by

no test coverage detected