Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support 2076-2-style structures in reassignIds #184

Merged
merged 29 commits into from
Dec 14, 2023

Conversation

firthm01
Copy link
Contributor

@firthm01 firthm01 commented Dec 5, 2023

Closes #181

See issue ticket for more details

The approach has been to process ACFs stemming from ATUIDs in the reassignAudioTrackUidIds. If an ACF is found, apply an available ACF ID.

However, other ACF IDs (and ATF and ASF IDs) were applied in the reassignAudioStreamFormatIds function which just blindly applies IDs sequentially, because previously this was fine and logical to do - it was the only function assigning IDs to ACF elements. Therefore this function could now inadvertently assign the same ID to more than one ACF because there were no checks to see if the ID was available.

Therefore the new getAvailableIdValue function was written will find an available ID value to use with ACF, ATF and ASF groups. It ensures the ID value is available for all 3 element types so that they can share the same value and make the ADM XML more readable and easy to follow.

The disadvantage of this approach is that available ID lookup has exponential complexity based on ACF count. However, given that reassignIds is not expected to be called repeatedly, and that even a "large" ADM document only has maybe 128 ACFs requiring ID assignment, this is probably fine.

Update:
The whole reassignIds logic has been wrapped in a class, with an IdIssuer class used to track IDs and ensure only unique ID's are issued to elements. This avoids the need for lookups and reduces to linear complexity. Note that a common ID value is used for groups of ACF, ATF and ASF elements so that the ADM XML is more readable and easy to follow.

This implementation uses the ID value of the ATUID as part of the ACF ID. This means assigned ACF ID's will not necessarily be consecutive, (since some ATUID's may use common definitions ACFs which don't need defining) but they will be unique....
... in most cases. It may throw in ID set methods due to conflicts when 2076-2-style references are mixed with 2076-1 references in the same document. This is because ACF ids mimic the associated ASF and ATF ID's which are assigned in a simple loop with an incrementing counter.
@firthm01 firthm01 self-assigned this Dec 5, 2023
Don't respond as if the actual comparison failed
Not sure why it was commented out. Makes sense to have it in, and it works. Was commented out since "initial commit". Perhaps it wasn't working back then?
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (9955fbd) 89.56% compared to head (61d9c36) 89.91%.

Files Patch % Lines
src/utilities/id_assignment.cpp 89.40% 16 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #184      +/-   ##
==========================================
+ Coverage   89.56%   89.91%   +0.34%     
==========================================
  Files         125      125              
  Lines        5781     5812      +31     
==========================================
+ Hits         5178     5226      +48     
+ Misses        603      586      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@firthm01 firthm01 marked this pull request as ready for review December 7, 2023 12:54
Copy link
Member

@tomjnixon tomjnixon left a comment

Choose a reason for hiding this comment

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

Looks good to me in general. I actually understand it while I don't think i did before. The comments are mostly small stuff.

src/utilities/id_assignment.cpp Outdated Show resolved Hide resolved
src/utilities/id_assignment.cpp Show resolved Hide resolved
src/utilities/id_assignment.cpp Outdated Show resolved Hide resolved
src/utilities/id_assignment.cpp Outdated Show resolved Hide resolved
src/utilities/id_assignment.cpp Show resolved Hide resolved
src/utilities/id_assignment.cpp Outdated Show resolved Hide resolved
include/adm/utilities/object_creation.hpp Outdated Show resolved Hide resolved
@@ -93,4 +97,48 @@ namespace adm {
}
///@}

class IdReassigner {
Copy link
Member

@tomjnixon tomjnixon Dec 8, 2023

Choose a reason for hiding this comment

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

Could this go in the implementation file? It doesn't look like it should be used by users.

It might be worth a quick comment on IdReassigner and IdIssuer to say what they are for (especially in the presence if IdAssigner, which could also do with explaining itself).

I'm fine with the structure as it is, but I would be tempted to merge these into one class, and perhaps pass the document to the reassignXIds functions instead of storing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think passing document to IdReassigner::reassignAllIds might suggest that a single IdReassigner instance can be used to process multiple documents, which is fine, but it would mean reconstructing IdIssuer on each passed in document (also fine). Since that IdIssuer instance is associated with just that one document, they should be passed to functions together. I think then the code would become less clean. That said, I have no strong feeling either way...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could wrap a Document with its IdIssuer in a struct and pass that around

Copy link
Member

Choose a reason for hiding this comment

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

I think passing document to IdReassigner::reassignAllIds might suggest that a single IdReassigner instance can be used to process multiple documents

Oh yeah, true, it looks good to me as-is.

@firthm01 firthm01 merged commit 3f94a9b into master Dec 14, 2023
8 checks passed
@firthm01 firthm01 deleted the fix181-reassignIds-2076-2 branch December 14, 2023 16:55
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.

reassignIds makes invalid ACF IDs in 2076-2-style structures
4 participants