Skip to content

Conversation

@Indra-db
Copy link
Owner

@Indra-db Indra-db commented May 11, 2025

merge typed, first, second and id functions into one function

Introduce:

fn id<T: ComponentId>()
IntoEntity trait
improved IntoId trait
before:
    world
        .query::<()>()
        .with::<Position>()
        .with_id(some_entity)
        .with_first::<Position>(some_entity)

after:
    world
        .query::<()>()
        .with(id::<Position>())
        .with(some_entity)
        .with((id::<Position>(),some_entity))
before
    world
        .entity()
        .add::<Position>()
        .add_id(some_id)
        .add_first::<Likes>(some_entity)
        .add_second::<Bob>(likes);

after
    world
        .entity()
        .add(id::<Position>())
        .add(some_id)
        .add((id::<Likes>(), some_entity))
        .add((likes, id::<Bob>));

previously: 261 functions
now: 100
reduction: 62%

=== World ================================================
* add_id
* add
* add_first
* add_second
--> add

* remove
* remove_id
* remove_first
* remove_second
--> remove

* modified
* modified_id
--> modified

* doc_name
* doc_name_id
--> doc_name

* doc_brief
* doc_brief_id
--> doc_brief

* doc_detail
* doc_detail_id
--> doc_detail

* doc_link
* doc_link_id
--> doc_link

* doc_color
* doc_color_id
--> doc_color

* doc_uuid
* doc_uuid_id
--> doc_uuid

* doc_name
* doc_name_id
--> doc_name

* set_doc_brief
* set_doc_brief_id
--> set_doc_brief

* set_doc_detail
* set_doc_detail_id
--> set_doc_detail

* set_doc_link
* set_doc_link_id
--> set_doc_link

* set_doc_color
* set_doc_color_id
--> set_doc_color

* set_doc_uuid
* set_doc_uuid_id
--> set_doc_uuid

* cursor
* cursor_id
--> cursor

* array
* array_id
--> array

* to_expr_id --> to_expr
* to_expr --> to_expr_typed

* script_entity_from_id
* script_entity_from
--> script_entity_from

* set_scope
* set_scope_id
--> set_scope

* scope
* scope_id
--> scope

* with
* with_id
* with_first
* with_second
* with_name
* with_names
* with_name_first
* with_name_second
--> with

* delete_entities_with
* delete_entities_with_id
* delete_entities_with_first
* delete_entities_with_second
--> delete_entities_with

* remove_all
* remove_all_id
* remove_all_first
* remove_all_second
--> remove_all

* count
* count_id
* count_first
* count_second
--> count

* run_in_scope_with
* run_in_scope_with_id
--> run_in_scope_with

* component_untyped_from
* component_untyped_from_id
--> component_untyped_from

* set_pipeline
* set_pipeline_id
--> set_pipeline

* run_pipeline
* run_pipeline_id
--> run_pipeline

* run_pipeline_time
* run_pipeline_id_time
--> run_pipeline_time

* id_from
* id_from_id
* id_first
* id_second
--> id_view_from

=== EntityView ================================================
* add_id
* add
* add_first
* add_second
--> add

* add_if
* add_id_if
* add_if_first
* add_if_second
--> add_if

* remove
* remove_id
* remove_first
* remove_second
--> remove

* is_a_id
* is_a
--> is_a

*.child_of
* child_of
--> child_of

* depends_on_id
* depends_on
--> depends_on

* slot_of_id
* slot_of
--> slot

* auto_override_id
* auto_override
* auto_override_first
* auto_override_second
* set_pair_override
--> auto_override

* enable
* enable_id
* enable_first
* enable_second
--> enable

* is_enabled
* is_enabled_id
* is_enabled_first
* is_enabled_second
--> is_enabled

* disable
* disable_id
* disable_first
* disable_second
--> disable

* modified
* modified_id
* modified_first
* modified_second
--> modified

* has
* has_id
* has_first
* has_second
--> has

* has_enum
* has_enum_id
--> has_enum

* owns
* owns_id
* owns_first
* owns_second
--> owns

* with_first
* with_second
* with_first_id
* with_second_id
--> with_first / with_second

* set_json
* set_json_id
* set_json_first
* set_json_second
--> set_json

* path_from
* path_from_id
path_from_id_default_sep
--> path_from

* path_from_w_sep
* path_from_id_w_sep
--> path_from_w_sep

* hierarchy_path_from_parent_type
--> hierarchy_path_from_parent

* each_target
* each_target_id
--> each_target

* each_child_of
* each_child_of_id
--> each_child_of

* count_relationship
* count_relationship_id
--> count_relationship

* target
* target_id
--> target

* target_for
* target_for_id
--> target_for

* depth
* depth_id
--> depth

=== EventBuilder ================================================
* add
* add_id
* add_first
* add_second
--> Add

=== System ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

=== SystemBuilder ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

* kind_id
* kind
--> kind

=== AlertBuilder ================================================

* severity
* severity_id
--> severity

* severity_filter
* severity_filter_id
--> severity_filter

* member_id
--> member

=== UntypedComponent ================================================

* member_id
* member
--> member

* member_id_unit
* member_unit
--> member_unit

=== MetricBuilder ===

* member_id
--> member

* kind_id
* kind
--> kind

* id
* id_pair
* id_type
* id_first
* id_second
--> id

=== UnManagedScript================================================

* to_expr
* to_expr_id
--> to_expr

=== ObserverBuilder ================================================

* add_event
* add_event_id
--> add_event

=== TermBuilder ===

* set_second
* set_second_id
--> set_second

* set_first
* set_first_id
--> set_first

* up_id
* up_type
--> up_id

* cascade_id
* cascade_type
--> cascade_id

* set_src
* set_src_id
* set_src_name
--> set_src

=== QueryBuilder ================================================

* with
* with_id
* with_first
* with_second
--> with

* without
* without_id
* without_first
* without_second
--> without

* with_second_id
* with_first_name
--> with_name_first

* with_first_id
* with_second_name
--> with_name_second

* without_first_id
* without_second_name
--> without_name_second

* without_second_id
* without_first_name
--> without_name_first

* write
* write_id
* write_first
* write_second
* write_name
* write_names
* write_name_first
* write_name_second
--> write

* read
* read_id
* read_first
* read_second
* write_name
* write_names
* write_name_first
* write_name_second
--> read

* with_first_id --> with_name_second
* with_second_id --> with_name_first

* write_first_name --> write_name_second
* write_second_name --> write_name_first

* read_first_name --> read_name_second
* read_second_name --> read_name_first

* set_second, set_second_name --> set_second
* set_first, set_first_name --> set_first

* group_by
* group_by_id
--> group_by

=== QueryIter ================================================

* set_group
* set_group_id
--> set_group

=== Table ================================================

* find_type_index
* find_type_index_id
* find_type_index_pair_ids
* find_type_index_pair
* find_type_index_first
* find_type_index_second
--> find_type_index

* find_column_index
* find_column_index_id
* find_column_index_pair
* find_column_index_pair_ids
* find_column_index_first
* find_column_index_second
--> find_column_index

* has_type
* has_type_id
* has_pair
* has_pair_ids
--> has

* depth
* depth_id
--> depth

=== Query ================================================

* set_group
* set_group_id
--> set_group

Indra-db added 3 commits May 7, 2025 22:16
merge typed, first, second and id functions into one function

previously: 247 functions
now: 98
reduction: 60%

=== World ===
* add_id
* add
* add_first
* add_second
--> add

* remove
* remove_id
* remove_first
* remove_second
--> remove

* modified
* modified_id
--> modified

* doc_name
* doc_name_id
--> doc_name

* doc_brief
* doc_brief_id
--> doc_brief

* doc_detail
* doc_detail_id
--> doc_detail

* doc_link
* doc_link_id
--> doc_link

* doc_color
* doc_color_id
--> doc_color

* doc_uuid
* doc_uuid_id
--> doc_uuid

* doc_name
* doc_name_id
--> doc_name

* set_doc_brief
* set_doc_brief_id
--> set_doc_brief

* set_doc_detail
* set_doc_detail_id
--> set_doc_detail

* set_doc_link
* set_doc_link_id
--> set_doc_link

* set_doc_color
* set_doc_color_id
--> set_doc_color

* set_doc_uuid
* set_doc_uuid_id
--> set_doc_uuid

* cursor
* cursor_id
--> cursor

* array
* array_id
--> array

* to_expr_id --> to_expr
* to_expr --> to_expr_typed

* script_entity_from_id
* script_entity_from
--> script_entity_from

* set_scope
* set_scope_id
--> set_scope

* scope
* scope_id
--> scope

* with
* with_id
* with_first
* with_second
--> with

* delete_entities_with
* delete_entities_with_id
* delete_entities_with_first
* delete_entities_with_second
--> delete_entities_with

* remove_all
* remove_all_id
* remove_all_first
* remove_all_second
--> remove_all

* count
* count_id
* count_first
* count_second
--> count

* run_in_scope_with
* run_in_scope_with_id
--> run_in_scope_with

* component_untyped_from
* component_untyped_from_id
--> component_untyped_from

* set_pipeline
* set_pipeline_id
--> set_pipeline

* run_pipeline
* run_pipeline_id
--> run_pipeline

* run_pipeline_time
* run_pipeline_id_time
--> run_pipeline_time

* id_from
* id_from_id
* id_first
* id_second
--> id_view_from

//////////////////////////

=== EntityView ===
* add_id
* add
* add_first
* add_second
--> add

* add_if
* add_id_if
* add_if_first
* add_if_second
--> add_if

* remove
* remove_id
* remove_first
* remove_second
--> remove

* is_a_id
* is_a
--> is_a

*.child_of
* child_of
--> child_of

* depends_on_id
* depends_on
--> depends_on

* slot_of_id
* slot_of
--> slot

* auto_override_id
* auto_override
* auto_override_first
* auto_override_second
* set_pair_override
--> auto_override

* enable
* enable_id
* enable_first
* enable_second
--> enable

* is_enabled
* is_enabled_id
* is_enabled_first
* is_enabled_second
--> is_enabled

* disable
* disable_id
* disable_first
* disable_second
--> disable

* modified
* modified_id
* modified_first
* modified_second
--> modified

* has
* has_id
* has_first
* has_second
--> has

* has_enum
* has_enum_id
--> has_enum

* owns
* owns_id
* owns_first
* owns_second
--> owns

* with_first
* with_second
* with_first_id
* with_second_id
--> with_first / with_second

* set_json
* set_json_id
* set_json_first
* set_json_second
--> set_json

* path_from
* path_from_id
path_from_id_default_sep
--> path_from

* path_from_w_sep
* path_from_id_w_sep
--> path_from_w_sep

* hierarchy_path_from_parent_type
--> hierarchy_path_from_parent

* each_target
* each_target_id
--> each_target

* each_child_of
* each_child_of_id
--> each_child_of

* count_relationship
* count_relationship_id
--> count_relationship

* target
* target_id
--> target

* target_for
* target_for_id
--> target_for

* depth
* depth_id
--> depth

=== EventBuilder ==
* add
* add_id
* add_first
* add_second
--> Add

=== System ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

=== SystemBuilder ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

* kind_id
* kind
--> kind

=== AlertBuilder ===

* severity
* severity_id
--> severity

* severity_filter
* severity_filter_id
--> severity_filter

* member_id
--> member

=== UntypedComponent ===

* member_id
* member
--> member

* member_id_unit
* member_unit
--> member_unit

=== MetricBuilder ===

* member_id
--> member

* kind_id
* kind
--> kind

* id
* id_pair
* id_type
* id_first
* id_second
--> id

=== UnManagedScript ===

* to_expr
* to_expr_id
--> to_expr

=== ObserverBuilder ===

* add_event
* add_event_id
--> add_event

=== TermBuilder ===

* set_second
* set_second_id
--> set_second

* set_first
* set_first_id
--> set_first

* up_id
* up_type
--> up_id

* cascade_id
* cascade_type
--> cascade_id

* set_src
* set_src_id
--> set_src

=== QueryBuilder ===

* with
* with_id
* with_first
* with_second
--> with

* without
* without_id
* without_first
* without_second
--> without

* with_second_id
* with_first_name
--> with_name_first

* with_first_id
* with_second_name
--> with_name_second

* without_first_id
* without_second_name
--> without_name_second

* without_second_id
* without_first_name
--> without_name_first

* write
* write_id
* write_first
* write_second
--> write

* read
* read_id
* read_first
* read_second
--> read

* with_first_id --> with_name_second
* with_second_id --> with_name_first

* write_first_name --> write_name_second
* write_second_name --> write_name_first

* read_first_name --> read_name_second
* read_second_name --> read_name_first

* group_by
* group_by_id
--> group_by

=== QueryIter ===

* set_group
* set_group_id
--> set_group

=== Table ===

* find_type_index
* find_type_index_id
* find_type_index_pair_ids
* find_type_index_pair
* find_type_index_first
* find_type_index_second
--> find_type_index

* find_column_index
* find_column_index_id
* find_column_index_pair
* find_column_index_pair_ids
* find_column_index_first
* find_column_index_second
--> find_column_index

* has_type
* has_type_id
* has_pair
* has_pair_ids
--> has

* depth
* depth_id
--> depth

=== Query ===

* set_group
* set_group_id
--> set_group
Indra-db added 3 commits May 16, 2025 11:12
some further API reduction:

with_name variants  (with_first_name etc) will also got merged with with
set_second_name and set_second merged into set_second
set_first_name set_first merged into set_first
set_src set_src_name merged into set_src
@Indra-db Indra-db changed the title Breaking change: chore(API): merge typed and id, pair API Breaking change: feat(API): merge typed and id, pair, name API May 16, 2025
@Indra-db Indra-db merged commit 41acc1b into main May 16, 2025
11 checks passed
Indra-db added a commit that referenced this pull request May 16, 2025
* feat(id-merge): Id struct, IntoEntity, IntoId improvements

* feat(API): merge typed, first, second and id functions into one function

* feat(API): unify ID and name handlers

merge typed, first, second and id functions into one function

previously: 247 functions
now: 98
reduction: 60%

=== World ===
* add_id
* add
* add_first
* add_second
--> add

* remove
* remove_id
* remove_first
* remove_second
--> remove

* modified
* modified_id
--> modified

* doc_name
* doc_name_id
--> doc_name

* doc_brief
* doc_brief_id
--> doc_brief

* doc_detail
* doc_detail_id
--> doc_detail

* doc_link
* doc_link_id
--> doc_link

* doc_color
* doc_color_id
--> doc_color

* doc_uuid
* doc_uuid_id
--> doc_uuid

* doc_name
* doc_name_id
--> doc_name

* set_doc_brief
* set_doc_brief_id
--> set_doc_brief

* set_doc_detail
* set_doc_detail_id
--> set_doc_detail

* set_doc_link
* set_doc_link_id
--> set_doc_link

* set_doc_color
* set_doc_color_id
--> set_doc_color

* set_doc_uuid
* set_doc_uuid_id
--> set_doc_uuid

* cursor
* cursor_id
--> cursor

* array
* array_id
--> array

* to_expr_id --> to_expr
* to_expr --> to_expr_typed

* script_entity_from_id
* script_entity_from
--> script_entity_from

* set_scope
* set_scope_id
--> set_scope

* scope
* scope_id
--> scope

* with
* with_id
* with_first
* with_second
--> with

* delete_entities_with
* delete_entities_with_id
* delete_entities_with_first
* delete_entities_with_second
--> delete_entities_with

* remove_all
* remove_all_id
* remove_all_first
* remove_all_second
--> remove_all

* count
* count_id
* count_first
* count_second
--> count

* run_in_scope_with
* run_in_scope_with_id
--> run_in_scope_with

* component_untyped_from
* component_untyped_from_id
--> component_untyped_from

* set_pipeline
* set_pipeline_id
--> set_pipeline

* run_pipeline
* run_pipeline_id
--> run_pipeline

* run_pipeline_time
* run_pipeline_id_time
--> run_pipeline_time

* id_from
* id_from_id
* id_first
* id_second
--> id_view_from

//////////////////////////

=== EntityView ===
* add_id
* add
* add_first
* add_second
--> add

* add_if
* add_id_if
* add_if_first
* add_if_second
--> add_if

* remove
* remove_id
* remove_first
* remove_second
--> remove

* is_a_id
* is_a
--> is_a

*.child_of
* child_of
--> child_of

* depends_on_id
* depends_on
--> depends_on

* slot_of_id
* slot_of
--> slot

* auto_override_id
* auto_override
* auto_override_first
* auto_override_second
* set_pair_override
--> auto_override

* enable
* enable_id
* enable_first
* enable_second
--> enable

* is_enabled
* is_enabled_id
* is_enabled_first
* is_enabled_second
--> is_enabled

* disable
* disable_id
* disable_first
* disable_second
--> disable

* modified
* modified_id
* modified_first
* modified_second
--> modified

* has
* has_id
* has_first
* has_second
--> has

* has_enum
* has_enum_id
--> has_enum

* owns
* owns_id
* owns_first
* owns_second
--> owns

* with_first
* with_second
* with_first_id
* with_second_id
--> with_first / with_second

* set_json
* set_json_id
* set_json_first
* set_json_second
--> set_json

* path_from
* path_from_id
path_from_id_default_sep
--> path_from

* path_from_w_sep
* path_from_id_w_sep
--> path_from_w_sep

* hierarchy_path_from_parent_type
--> hierarchy_path_from_parent

* each_target
* each_target_id
--> each_target

* each_child_of
* each_child_of_id
--> each_child_of

* count_relationship
* count_relationship_id
--> count_relationship

* target
* target_id
--> target

* target_for
* target_for_id
--> target_for

* depth
* depth_id
--> depth

=== EventBuilder ==
* add
* add_id
* add_first
* add_second
--> Add

=== System ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

=== SystemBuilder ===
* set_tick_source
* set_tick_source_id
--> set_tick_source

* kind_id
* kind
--> kind

=== AlertBuilder ===

* severity
* severity_id
--> severity

* severity_filter
* severity_filter_id
--> severity_filter

* member_id
--> member

=== UntypedComponent ===

* member_id
* member
--> member

* member_id_unit
* member_unit
--> member_unit

=== MetricBuilder ===

* member_id
--> member

* kind_id
* kind
--> kind

* id
* id_pair
* id_type
* id_first
* id_second
--> id

=== UnManagedScript ===

* to_expr
* to_expr_id
--> to_expr

=== ObserverBuilder ===

* add_event
* add_event_id
--> add_event

=== TermBuilder ===

* set_second
* set_second_id
--> set_second

* set_first
* set_first_id
--> set_first

* up_id
* up_type
--> up_id

* cascade_id
* cascade_type
--> cascade_id

* set_src
* set_src_id
--> set_src

=== QueryBuilder ===

* with
* with_id
* with_first
* with_second
--> with

* without
* without_id
* without_first
* without_second
--> without

* with_second_id
* with_first_name
--> with_name_first

* with_first_id
* with_second_name
--> with_name_second

* without_first_id
* without_second_name
--> without_name_second

* without_second_id
* without_first_name
--> without_name_first

* write
* write_id
* write_first
* write_second
--> write

* read
* read_id
* read_first
* read_second
--> read

* with_first_id --> with_name_second
* with_second_id --> with_name_first

* write_first_name --> write_name_second
* write_second_name --> write_name_first

* read_first_name --> read_name_second
* read_second_name --> read_name_first

* group_by
* group_by_id
--> group_by

=== QueryIter ===

* set_group
* set_group_id
--> set_group

=== Table ===

* find_type_index
* find_type_index_id
* find_type_index_pair_ids
* find_type_index_pair
* find_type_index_first
* find_type_index_second
--> find_type_index

* find_column_index
* find_column_index_id
* find_column_index_pair
* find_column_index_pair_ids
* find_column_index_first
* find_column_index_second
--> find_column_index

* has_type
* has_type_id
* has_pair
* has_pair_ids
--> has

* depth
* depth_id
--> depth

=== Query ===

* set_group
* set_group_id
--> set_group

* chore(ci): fixes docs

* WIP: merge name and ids

some further API reduction:

with_name variants  (with_first_name etc) will also got merged with with
set_second_name and set_second merged into set_second
set_first_name set_first merged into set_first
set_src set_src_name merged into set_src

* chore(docs): improve, cleanup docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants