@@ -153,20 +153,6 @@ node_type_matches_value_type(SchemaTree::Node::Type type, Value const& value) ->
153
153
KeyValuePairLogEvent::NodeIdValuePairs const & node_id_value_pairs
154
154
) -> bool;
155
155
156
- /* *
157
- * @param node_id_value_pairs
158
- * @param schema_tree
159
- * @return A result containing a bitmap where every bit corresponds to the ID of a node in the
160
- * schema tree, and the set bits correspond to the nodes in the subtree defined by all paths from
161
- * the root node to the nodes in `node_id_value_pairs`; or an error code indicating a failure:
162
- * - std::errc::result_out_of_range if a node ID in `node_id_value_pairs` doesn't exist in the
163
- * schema tree.
164
- */
165
- [[nodiscard]] auto get_schema_subtree_bitmap (
166
- KeyValuePairLogEvent::NodeIdValuePairs const & node_id_value_pairs,
167
- SchemaTree const & schema_tree
168
- ) -> OUTCOME_V2_NAMESPACE::std_result<vector<bool>>;
169
-
170
156
/* *
171
157
* Inserts the given key-value pair into the JSON object (map).
172
158
* @param node The schema tree node of the key to insert.
@@ -283,38 +269,6 @@ auto is_leaf_node(
283
269
return true ;
284
270
}
285
271
286
- auto get_schema_subtree_bitmap (
287
- KeyValuePairLogEvent::NodeIdValuePairs const & node_id_value_pairs,
288
- SchemaTree const & schema_tree
289
- ) -> OUTCOME_V2_NAMESPACE::std_result<vector<bool>> {
290
- auto schema_subtree_bitmap{vector<bool >(schema_tree.get_size (), false )};
291
- for (auto const & [node_id, val] : node_id_value_pairs) {
292
- if (node_id >= schema_subtree_bitmap.size ()) {
293
- return std::errc::result_out_of_range;
294
- }
295
- schema_subtree_bitmap[node_id] = true ;
296
-
297
- // Iteratively mark the parents as true
298
- auto optional_parent_id{schema_tree.get_node (node_id).get_parent_id ()};
299
- while (true ) {
300
- // Ideally, we'd use this if statement as the loop condition, but clang-tidy will
301
- // complain about an unchecked `optional` access.
302
- if (false == optional_parent_id.has_value ()) {
303
- // Reached the root
304
- break ;
305
- }
306
- auto const parent_id{optional_parent_id.value ()};
307
- if (schema_subtree_bitmap[parent_id]) {
308
- // Parent already set by other child
309
- break ;
310
- }
311
- schema_subtree_bitmap[parent_id] = true ;
312
- optional_parent_id = schema_tree.get_node (parent_id).get_parent_id ();
313
- }
314
- }
315
- return schema_subtree_bitmap;
316
- }
317
-
318
272
auto insert_kv_pair_into_json_obj (
319
273
SchemaTree::Node const & node,
320
274
std::optional<Value> const & optional_val,
@@ -393,6 +347,36 @@ auto KeyValuePairLogEvent::create(
393
347
return KeyValuePairLogEvent{std::move (schema_tree), std::move (node_id_value_pairs), utc_offset};
394
348
}
395
349
350
+ auto KeyValuePairLogEvent::get_schema_subtree_bitmap (
351
+ ) const -> OUTCOME_V2_NAMESPACE::std_result<vector<bool>> {
352
+ auto schema_subtree_bitmap{vector<bool >(m_schema_tree->get_size (), false )};
353
+ for (auto const & [node_id, val] : m_node_id_value_pairs) {
354
+ if (node_id >= schema_subtree_bitmap.size ()) {
355
+ return std::errc::result_out_of_range;
356
+ }
357
+ schema_subtree_bitmap[node_id] = true ;
358
+
359
+ // Iteratively mark the parents as true
360
+ auto optional_parent_id{m_schema_tree->get_node (node_id).get_parent_id ()};
361
+ while (true ) {
362
+ // Ideally, we'd use this if statement as the loop condition, but clang-tidy will
363
+ // complain about an unchecked `optional` access.
364
+ if (false == optional_parent_id.has_value ()) {
365
+ // Reached the root
366
+ break ;
367
+ }
368
+ auto const parent_id{optional_parent_id.value ()};
369
+ if (schema_subtree_bitmap[parent_id]) {
370
+ // Parent already set by other child
371
+ break ;
372
+ }
373
+ schema_subtree_bitmap[parent_id] = true ;
374
+ optional_parent_id = m_schema_tree->get_node (parent_id).get_parent_id ();
375
+ }
376
+ }
377
+ return schema_subtree_bitmap;
378
+ }
379
+
396
380
auto KeyValuePairLogEvent::serialize_to_json (
397
381
) const -> OUTCOME_V2_NAMESPACE::std_result<nlohmann::json> {
398
382
if (m_node_id_value_pairs.empty ()) {
@@ -409,9 +393,7 @@ auto KeyValuePairLogEvent::serialize_to_json(
409
393
// vector grows).
410
394
std::stack<DfsIterator> dfs_stack;
411
395
412
- auto const schema_subtree_bitmap_ret{
413
- get_schema_subtree_bitmap (m_node_id_value_pairs, *m_schema_tree)
414
- };
396
+ auto const schema_subtree_bitmap_ret{get_schema_subtree_bitmap ()};
415
397
if (schema_subtree_bitmap_ret.has_error ()) {
416
398
return schema_subtree_bitmap_ret.error ();
417
399
}
0 commit comments