Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add create group operator #165

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Add create group operator #165

merged 2 commits into from
Oct 16, 2024

Conversation

glopesdev
Copy link
Contributor

This PR introduces a new CreateGroup operator used to convert the values in a sequence into a grouped observable, using each element of the input sequence as the group key. The values of each created group are specified through a nested workflow which receives the key value as its input.

@glopesdev glopesdev added the feature New planned feature label Oct 21, 2023
Copy link
Contributor

@aspaNeuro aspaNeuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking in using this group operator for the modular implementation of the devices?
If so I would like to understand better how. And what's the difference between this operator and the group by.

@glopesdev
Copy link
Contributor Author

glopesdev commented Oct 23, 2023

@aspaNeuro yes that is also the goal. The main difference with GroupBy is that you can create a sequence of grouped observables directly from the key, instead of having to do PairValueWithKey > GroupBy. Graphically below it is the difference between the left-hand and right-hand side workflows:

image

Notice that in the earlier workaround we were abusing GroupBy to construct a grouped observable by having effectively sequences where all items have the same key. There were costs associated with this, e.g. we are creating a dictionary with a single entry for each sequence and then doing a lookup on that dictionary for every single value. Granted, these are mostly negligible but more importantly we want to be able to specify for every group what is the nested workflow that generates values, which requires some kind of nested operator that captures this pattern, which is hard to do simply using the existing operators.

CreateGroup also works for changing the values of existing groups while keeping the same key, which is also currently clunky to do. Graphically again the difference between the left-hand and right-hand side workflows:

image

Basically in case the input is an existing grouped observable, the key is taken from the group key and the elements are simply the sequence defined in the nested workflow.

@aspaNeuro
Copy link
Contributor

aspaNeuro commented Oct 23, 2023 via email

@glopesdev glopesdev merged commit 184ae27 into main Oct 16, 2024
5 checks passed
@glopesdev glopesdev deleted the aeon-acquisition branch October 16, 2024 11:01
@glopesdev glopesdev restored the aeon-acquisition branch October 23, 2024 08:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature New planned feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants