Open LinZhihao-723 opened 1 month ago
The pull request introduces significant changes to the KeyValuePairLogEvent
class and related components to enhance the serialization of key-value pairs into JSON format and improve the validation of node-ID value pairs within a schema tree. Key updates include the addition of new methods for serialization and key uniqueness checks, modifications to existing methods to accommodate new parameters, and updates to the test files to ensure proper functionality and validation of these changes.
File | Change Summary |
---|---|
components/core/src/clp/ffi/KeyValuePairLogEvent.cpp | - Added serialize_node_id_value_pairs_to_json and check_key_uniqueness_among_sibling_nodes methods. - Updated validate_node_id_value_pairs to use a bitmap for key duplication checks. - Modified create and serialize_to_json methods for new parameters and return types. |
components/core/src/clp/ffi/KeyValuePairLogEvent.hpp | - Updated constructor and create method to accept two schema trees and two collections of node-ID value pairs. - Changed method names to distinguish between auto-generated and user-generated pairs. - Updated documentation comments. |
components/core/tests/test-ffi_KeyValuePairLogEvent.cpp | - Added assert_kv_pair_log_event_creation_failure method. - Updated test cases for JSON serialization and key duplication checks. |
KeyValuePairLogEvent.cpp
file to transition from SchemaTreeNode
to SchemaTree::Node
, which is directly related to the changes made in the main PR regarding the serialization and validation of node-ID value pairs.Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Can you resolve the conflicts?
Description
As planned in #556, we want to differentiate key-value pairs into two categories: auto-generated key-value pairs and user-generated key-value pairs. This PR adds support for auto/user-generated key-value pairs in
KeyValuePairLogEvent,
where each set of key-value pairs is stored as a set of node-ID-value pairs with a reference to the associated schema tree. However, this PR does not yet support auto/user-generated kv pairs serialization/deserialization. The deserializer will output newKeyValuePairLogEvent
instances, but with all kv-pairs as user-generated ones, leaving auto-generated pairs empty.This PR also fixes a bug where duplicated keys are not correctly detected. Consider the following schema tree:
Before this PR, if we have node-ID-value pairs
[<2:"Value0">, <3:"Value1">]
, it will be considered valid with the schema tree above. However, it is actually invalid since there is an implicit duplicated key under the root node: both node 1 and node 2 have the key `"a". The previous implementation doesn't check key duplications among non-leaf nodes' siblings. This PR fixes this bug by checking key duplications among siblings for all the nodes from the leaf up to the root.Validation performed
KeyValuePairLogEvent
that supports auto/user-generated kv pairs.KeyValuePairLogEvent
Summary by CodeRabbit
New Features
Bug Fixes
Tests