Skip to content

Commit

Permalink
feat(ffi): Add support for serializing/deserializing auto-generated k…
Browse files Browse the repository at this point in the history
…ey-value pairs in the new IR format (resolves #556). (#653)

Co-authored-by: kirkrodrigues <[email protected]>
  • Loading branch information
LinZhihao-723 and kirkrodrigues authored Jan 17, 2025
1 parent 5c96bdc commit 774ba19
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 296 deletions.
15 changes: 11 additions & 4 deletions components/core/src/clp/ffi/ir_stream/Deserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,25 @@ auto Deserializer<IrUnitHandler>::deserialize_next_ir_unit(ReaderInterface& read
return result.error();
}

auto const node_locator{result.value()};
if (m_user_gen_keys_schema_tree->has_node(node_locator)) {
auto const& [is_auto_generated, node_locator]{result.value()};
auto& schema_tree_to_insert{
is_auto_generated ? m_auto_gen_keys_schema_tree : m_user_gen_keys_schema_tree
};

if (schema_tree_to_insert->has_node(node_locator)) {
return std::errc::protocol_error;
}

if (auto const err{m_ir_unit_handler.handle_schema_tree_node_insertion(node_locator)};
if (auto const err{m_ir_unit_handler.handle_schema_tree_node_insertion(
is_auto_generated,
node_locator
)};
IRErrorCode::IRErrorCode_Success != err)
{
return ir_error_code_to_errc(err);
}

std::ignore = m_user_gen_keys_schema_tree->insert_node(node_locator);
std::ignore = schema_tree_to_insert->insert_node(node_locator);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ template <typename Handler>
concept IrUnitHandlerInterface = requires(
Handler handler,
KeyValuePairLogEvent&& log_event,
bool is_auto_generated,
UtcOffset utc_offset_old,
UtcOffset utc_offset_new,
SchemaTree::NodeLocator schema_tree_node_locator
Expand All @@ -42,11 +43,12 @@ concept IrUnitHandlerInterface = requires(

/**
* Handles a schema tree node insertion IR unit.
* @param is_auto_generated Whether the node is from the auto-gen keys schema tree.
* @param schema_tree_node_locator The locator of the node to insert.
* @return IRErrorCode::Success on success, user-defined error code on failures.
*/
{
handler.handle_schema_tree_node_insertion(schema_tree_node_locator)
handler.handle_schema_tree_node_insertion(is_auto_generated, schema_tree_node_locator)
} -> std::same_as<IRErrorCode>;

/**
Expand Down
Loading

0 comments on commit 774ba19

Please sign in to comment.