Skip to content

Commit

Permalink
Fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Dec 9, 2024
1 parent b10ad4b commit 733c896
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 133 deletions.
44 changes: 19 additions & 25 deletions components/core/src/clp/ffi/KeyValuePairLogEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,57 +523,51 @@ auto check_key_uniqueness_among_sibling_nodes(
} // namespace

auto KeyValuePairLogEvent::create(
std::shared_ptr<SchemaTree const> auto_generated_schema_tree,
std::shared_ptr<SchemaTree const> user_generated_schema_tree,
NodeIdValuePairs auto_generated_node_id_value_pairs,
NodeIdValuePairs user_generated_node_id_value_pairs,
std::shared_ptr<SchemaTree const> auto_gen_keys_schema_tree,
std::shared_ptr<SchemaTree const> user_gen_keys_schema_tree,
NodeIdValuePairs auto_gen_node_id_value_pairs,
NodeIdValuePairs user_gen_node_id_value_pairs,
UtcOffset utc_offset
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent> {
if (nullptr == auto_generated_schema_tree || nullptr == user_generated_schema_tree) {
if (nullptr == auto_gen_keys_schema_tree || nullptr == user_gen_keys_schema_tree) {
return std::errc::invalid_argument;
}

if (auto const ret_val{validate_node_id_value_pairs(
*auto_generated_schema_tree,
auto_generated_node_id_value_pairs
*auto_gen_keys_schema_tree,
auto_gen_node_id_value_pairs
)};
std::errc{} != ret_val)
{
return ret_val;
}

if (auto const ret_val{validate_node_id_value_pairs(
*user_generated_schema_tree,
user_generated_node_id_value_pairs
*user_gen_keys_schema_tree,
user_gen_node_id_value_pairs
)};
std::errc{} != ret_val)
{
return ret_val;
}

return KeyValuePairLogEvent{
std::move(auto_generated_schema_tree),
std::move(user_generated_schema_tree),
std::move(auto_generated_node_id_value_pairs),
std::move(user_generated_node_id_value_pairs),
std::move(auto_gen_keys_schema_tree),
std::move(user_gen_keys_schema_tree),
std::move(auto_gen_node_id_value_pairs),
std::move(user_gen_node_id_value_pairs),
utc_offset
};
}

auto KeyValuePairLogEvent::get_auto_generated_schema_subtree_bitmap(
) const -> OUTCOME_V2_NAMESPACE::std_result<std::vector<bool>> {
return get_schema_subtree_bitmap(
m_auto_generated_node_id_value_pairs,
*m_auto_generated_schema_tree
);
return get_schema_subtree_bitmap(m_auto_gen_node_id_value_pairs, *m_auto_gen_keys_schema_tree);
}

auto KeyValuePairLogEvent::get_user_generated_schema_subtree_bitmap(
) const -> outcome_v2::std_result<std::vector<bool>> {
return get_schema_subtree_bitmap(
m_user_generated_node_id_value_pairs,
*m_user_generated_schema_tree
);
return get_schema_subtree_bitmap(m_user_gen_node_id_value_pairs, *m_user_gen_keys_schema_tree);
}

auto KeyValuePairLogEvent::serialize_to_json(
Expand All @@ -584,8 +578,8 @@ auto KeyValuePairLogEvent::serialize_to_json(
return auto_generated_schema_subtree_bitmap_result.error();
}
auto serialized_auto_generated_kv_pairs_result{serialize_node_id_value_pairs_to_json(
*m_auto_generated_schema_tree,
m_auto_generated_node_id_value_pairs,
*m_auto_gen_keys_schema_tree,
m_auto_gen_node_id_value_pairs,
auto_generated_schema_subtree_bitmap_result.value()
)};
if (serialized_auto_generated_kv_pairs_result.has_error()) {
Expand All @@ -598,8 +592,8 @@ auto KeyValuePairLogEvent::serialize_to_json(
return user_generated_schema_subtree_bitmap_result.error();
}
auto serialized_user_generated_kv_pairs_result{serialize_node_id_value_pairs_to_json(
*m_user_generated_schema_tree,
m_user_generated_node_id_value_pairs,
*m_user_gen_keys_schema_tree,
m_user_gen_node_id_value_pairs,
user_generated_schema_subtree_bitmap_result.value()
)};
if (serialized_user_generated_kv_pairs_result.has_error()) {
Expand Down
64 changes: 32 additions & 32 deletions components/core/src/clp/ffi/KeyValuePairLogEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ class KeyValuePairLogEvent {

// Factory functions
/**
* @param auto_generated_schema_tree
* @param user_generated_schema_tree
* @param auto_generated_node_id_value_pairs
* @param user_generated_node_id_value_pairs
* @param auto_gen_keys_schema_tree
* @param user_gen_keys_schema_tree
* @param auto_gen_node_id_value_pairs
* @param user_gen_node_id_value_pairs
* @param utc_offset
* @return A result containing the key-value pair log event or an error code indicating the
* failure:
* - std::errc::invalid_argument if any of the given schema tree pointers are null.
* - Forwards `validate_node_id_value_pairs`'s return values.
*/
[[nodiscard]] static auto create(
std::shared_ptr<SchemaTree const> auto_generated_schema_tree,
std::shared_ptr<SchemaTree const> user_generated_schema_tree,
NodeIdValuePairs auto_generated_node_id_value_pairs,
NodeIdValuePairs user_generated_node_id_value_pairs,
std::shared_ptr<SchemaTree const> auto_gen_keys_schema_tree,
std::shared_ptr<SchemaTree const> user_gen_keys_schema_tree,
NodeIdValuePairs auto_gen_node_id_value_pairs,
NodeIdValuePairs user_gen_node_id_value_pairs,
UtcOffset utc_offset
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent>;

Expand All @@ -62,28 +62,28 @@ class KeyValuePairLogEvent {
~KeyValuePairLogEvent() = default;

// Methods
[[nodiscard]] auto get_auto_generated_schema_tree() const -> SchemaTree const& {
return *m_auto_generated_schema_tree;
[[nodiscard]] auto get_auto_gen_keys_schema_tree() const -> SchemaTree const& {
return *m_auto_gen_keys_schema_tree;
}

[[nodiscard]] auto get_user_generated_schema_tree() const -> SchemaTree const& {
return *m_user_generated_schema_tree;
[[nodiscard]] auto get_user_gen_keys_schema_tree() const -> SchemaTree const& {
return *m_user_gen_keys_schema_tree;
}

[[nodiscard]] auto get_auto_generated_node_id_value_pairs() const -> NodeIdValuePairs const& {
return m_auto_generated_node_id_value_pairs;
[[nodiscard]] auto get_auto_gen_node_id_value_pairs() const -> NodeIdValuePairs const& {
return m_auto_gen_node_id_value_pairs;
}

[[nodiscard]] auto get_user_generated_node_id_value_pairs() const -> NodeIdValuePairs const& {
return m_user_generated_node_id_value_pairs;
[[nodiscard]] auto get_user_gen_node_id_value_pairs() const -> NodeIdValuePairs const& {
return m_user_gen_node_id_value_pairs;
}

/**
* @return A result containing a bitmap where every bit corresponds to the ID of a node in the
* schema tree for auto-generated keys, and the set bits correspond to the nodes in the subtree
* defined by all paths from the root node to the nodes in
* `m_auto_generated_node_id_value_pairs`; or an error code indicating a failure:
* - std::errc::result_out_of_range if a node ID in `m_auto_generated_node_id_value_pairs`
* `m_auto_gen_node_id_value_pairs`; or an error code indicating a failure:
* - std::errc::result_out_of_range if a node ID in `m_auto_gen_node_id_value_pairs`
* doesn't exist in the schema tree.
*/
[[nodiscard]] auto get_auto_generated_schema_subtree_bitmap(
Expand All @@ -93,8 +93,8 @@ class KeyValuePairLogEvent {
* @return A result containing a bitmap where every bit corresponds to the ID of a node in the
* schema tree for user-generated keys, and the set bits correspond to the nodes in the subtree
* defined by all paths from the root node to the nodes in
* `m_user_generated_node_id_value_pairs`; or an error code indicating a failure:
* - std::errc::result_out_of_range if a node ID in `m_user_generated_node_id_value_pairs`
* `m_user_gen_node_id_value_pairs`; or an error code indicating a failure:
* - std::errc::result_out_of_range if a node ID in `m_user_gen_node_id_value_pairs`
* doesn't exist in the schema tree.
*/
[[nodiscard]] auto get_user_generated_schema_subtree_bitmap(
Expand All @@ -118,23 +118,23 @@ class KeyValuePairLogEvent {
private:
// Constructor
KeyValuePairLogEvent(
std::shared_ptr<SchemaTree const> auto_generated_schema_tree,
std::shared_ptr<SchemaTree const> user_generated_schema_tree,
NodeIdValuePairs auto_generated_node_id_value_pairs,
NodeIdValuePairs user_generated_node_id_value_pairs,
std::shared_ptr<SchemaTree const> auto_gen_keys_schema_tree,
std::shared_ptr<SchemaTree const> user_gen_keys_schema_tree,
NodeIdValuePairs auto_gen_node_id_value_pairs,
NodeIdValuePairs user_gen_node_id_value_pairs,
UtcOffset utc_offset
)
: m_auto_generated_schema_tree{std::move(auto_generated_schema_tree)},
m_user_generated_schema_tree{std::move(user_generated_schema_tree)},
m_auto_generated_node_id_value_pairs{std::move(auto_generated_node_id_value_pairs)},
m_user_generated_node_id_value_pairs{std::move(user_generated_node_id_value_pairs)},
: m_auto_gen_keys_schema_tree{std::move(auto_gen_keys_schema_tree)},
m_user_gen_keys_schema_tree{std::move(user_gen_keys_schema_tree)},
m_auto_gen_node_id_value_pairs{std::move(auto_gen_node_id_value_pairs)},
m_user_gen_node_id_value_pairs{std::move(user_gen_node_id_value_pairs)},
m_utc_offset{utc_offset} {}

// Variables
std::shared_ptr<SchemaTree const> m_auto_generated_schema_tree;
std::shared_ptr<SchemaTree const> m_user_generated_schema_tree;
NodeIdValuePairs m_auto_generated_node_id_value_pairs;
NodeIdValuePairs m_user_generated_node_id_value_pairs;
std::shared_ptr<SchemaTree const> m_auto_gen_keys_schema_tree;
std::shared_ptr<SchemaTree const> m_user_gen_keys_schema_tree;
NodeIdValuePairs m_auto_gen_node_id_value_pairs;
NodeIdValuePairs m_user_gen_node_id_value_pairs;
UtcOffset m_utc_offset{0};
};
} // namespace clp::ffi
Expand Down
12 changes: 6 additions & 6 deletions components/core/src/clp/ffi/ir_stream/Deserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class Deserializer {
Deserializer(IrUnitHandler ir_unit_handler) : m_ir_unit_handler{std::move(ir_unit_handler)} {}

// Variables
std::shared_ptr<SchemaTree> m_auto_generated_schema_tree{std::make_shared<SchemaTree>()};
std::shared_ptr<SchemaTree> m_user_generated_schema_tree{std::make_shared<SchemaTree>()};
std::shared_ptr<SchemaTree> m_auto_gen_keys_schema_tree{std::make_shared<SchemaTree>()};
std::shared_ptr<SchemaTree> m_user_gen_keys_schema_tree{std::make_shared<SchemaTree>()};
UtcOffset m_utc_offset{0};
IrUnitHandler m_ir_unit_handler;
bool m_is_complete{false};
Expand Down Expand Up @@ -187,8 +187,8 @@ auto Deserializer<IrUnitHandler>::deserialize_next_ir_unit(ReaderInterface& read
auto result{deserialize_ir_unit_kv_pair_log_event(
reader,
tag,
m_auto_generated_schema_tree,
m_user_generated_schema_tree,
m_auto_gen_keys_schema_tree,
m_user_gen_keys_schema_tree,
m_utc_offset
)};
if (result.has_error()) {
Expand All @@ -212,7 +212,7 @@ auto Deserializer<IrUnitHandler>::deserialize_next_ir_unit(ReaderInterface& read
}

auto const node_locator{result.value()};
if (m_user_generated_schema_tree->has_node(node_locator)) {
if (m_user_gen_keys_schema_tree->has_node(node_locator)) {
return std::errc::protocol_error;
}

Expand All @@ -222,7 +222,7 @@ auto Deserializer<IrUnitHandler>::deserialize_next_ir_unit(ReaderInterface& read
return ir_error_code_to_errc(err);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ auto deserialize_ir_unit_utc_offset_change(ReaderInterface& reader
auto deserialize_ir_unit_kv_pair_log_event(
ReaderInterface& reader,
encoded_tag_t tag,
std::shared_ptr<SchemaTree> auto_generated_schema_tree,
std::shared_ptr<SchemaTree> user_generated_schema_tree,
std::shared_ptr<SchemaTree> auto_gen_keys_schema_tree,
std::shared_ptr<SchemaTree> user_gen_keys_schema_tree,
UtcOffset utc_offset
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent> {
auto const schema_result{deserialize_schema(reader, tag)};
Expand Down Expand Up @@ -580,8 +580,8 @@ auto deserialize_ir_unit_kv_pair_log_event(
}

return KeyValuePairLogEvent::create(
std::move(auto_generated_schema_tree),
std::move(user_generated_schema_tree),
std::move(auto_gen_keys_schema_tree),
std::move(user_gen_keys_schema_tree),
{},
std::move(node_id_value_pairs),
utc_offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ namespace clp::ffi::ir_stream {
* Deserializes a key-value pair log event IR unit.
* @param reader
* @param tag
* @param auto_generated_schema_tree Schema tree for auto-generated keys, used to construct the
* @param auto_gen_keys_schema_tree Schema tree for auto-generated keys, used to construct the
* KV-pair log event.
* @param user_generated_schema_tree Schema tree for user-generated keys, used to construct the
* @param user_gen_keys_schema_tree Schema tree for user-generated keys, used to construct the
* KV-pair log event.
* @param utc_offset UTC offset used to construct the KV-pair log event.
* @return A result containing the deserialized log event or an error code indicating the
Expand All @@ -75,8 +75,8 @@ namespace clp::ffi::ir_stream {
[[nodiscard]] auto deserialize_ir_unit_kv_pair_log_event(
ReaderInterface& reader,
encoded_tag_t tag,
std::shared_ptr<SchemaTree> auto_generated_schema_tree,
std::shared_ptr<SchemaTree> user_generated_schema_tree,
std::shared_ptr<SchemaTree> auto_gen_keys_schema_tree,
std::shared_ptr<SchemaTree> user_gen_keys_schema_tree,
UtcOffset utc_offset
) -> OUTCOME_V2_NAMESPACE::std_result<KeyValuePairLogEvent>;
} // namespace clp::ffi::ir_stream
Expand Down
2 changes: 1 addition & 1 deletion components/core/tests/test-ffi_IrUnitHandlerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ TEMPLATE_TEST_CASE(
REQUIRE(
(optional_log_event.has_value()
&& optional_log_event.value().get_utc_offset() == cTestUtcOffset
&& optional_log_event.value().get_user_generated_node_id_value_pairs().empty())
&& optional_log_event.value().get_user_gen_node_id_value_pairs().empty())
);
auto const& optional_schema_tree_locator{handler.get_schema_tree_node_locator()};
REQUIRE(
Expand Down
Loading

0 comments on commit 733c896

Please sign in to comment.