rticommunity / rticommunity/rticonnextdds-examples

Improve of partitions iteration order

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
148
Forks
153
PR merge metrics
No merged PRs in 30d

Description

In the partitions examples for C, C++, C# and Java, the order in which the partitions filter changes is not the same always. Every 5 samples the partition filter change, with the current implementation the order is:
Filter1 -> Filter2 -> Filter3 -> Filter4 -> Filter5 -> Filter3 -> Filter1 -> Filter4 -> Filter3 -> Filter5...

The order depends on the result of the modulo operation with the counter value:

if ((count+1) % 25 == 0)
...
else if ((count+1) % 20 == 0)
...
else if ((count+1) % 15 == 0)
...
else if ((count+1) % 10 == 0)
...
else if ((count+1) % 5 == 0)
...

For the first 25 samples this works, the problem is after them, since 30 is common multiple of 5 and 15, instead of start again at 5, it is catched by 15, with 35, instead of be 10 it's catched by 5, with 40 is catched by 20 instead of 15 and so on...

I propose to do the modulo operation over the same value, 25, and check its result:

if ((count+1) % 25 == 0)
...
else if ((count+1) % 25 == 20)
...
else if ((count+1) % 25 == 15)
...
else if ((count+1) % 25 == 10)
...
else if ((count+1) % 25 == 5)
...

In this way, after the first 25 sample, the same order of change is used.

Another improvement in this example could be to clean the second partition filter when non-used. Only two partitions are used in the first 5 samples (default from XML) and iteration 25-30. For 5 to 25 is used only one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the partitions examples for C, C++, C# and Java and locate the counter-based filter-selection logic described in the issue. Compare the modulo checks across the examples, then verify that the filter changes repeat in the same five-step order after the first 25 samples and that the examples still behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, csharp, java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.