Skip to content

Conversation

lynchsft
Copy link
Collaborator

@lynchsft lynchsft commented Dec 2, 2024

Yams is able to coalesce references to objects decoded with YAML anchors.

The main use-case for dereferencing aliases in a YML document is when decoding into class types. If the yaml document is large and contains many references (perhaps it is a representation of a dense graph) then, decoding into structs will require the of large amounts of system memory to represent highly redundant (duplicated) data structures.

However, if the same document is decoded into class types and the decoding uses an AliasDereferencingStrategy such as BasicAliasDereferencingStrategy then the emitted value will have its class references coalesced. No duplicate objects will be initialized. In some scenarios this may significantly reduce the memory footprint of the decoded type.

This PR builds on concepts from an earlier PR: #428

@PeqNP
Copy link

PeqNP commented Dec 31, 2024

Do any of these new strategies require a test to ensure they work as expected? Or do the current tests do a good job of covering what was added?

@lynchsft
Copy link
Collaborator Author

Do any of these new strategies require a test to ensure they work as expected? Or do the current tests do a good job of covering what was added?

@PeqNP I believe the new reference coalescing strategies are covered by the tests. This PR is now much easier to read after having merged #428 . Your review is appreciated! 🙏🏻

@lynchsft
Copy link
Collaborator Author

Additional tests covering the AliasingStrategies have been added here

@lynchsft lynchsft merged commit 9d13ea4 into jpsim:main Apr 29, 2025
41 checks passed
@lynchsft lynchsft deleted the reference_coalescing branch May 17, 2025 23:23
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.

2 participants