Skip to content

refactor: Store data in unhydrated nodes directly instead of wrapping MapTree nodes #24739

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

Merged
merged 32 commits into from
Jun 9, 2025

Conversation

CraigMacomber
Copy link
Contributor

@CraigMacomber CraigMacomber commented May 30, 2025

Description

Implement map tree APIs with UnhydratedFlexTreeNode directly instead of a wrapping a MapTree.

Store contextual default providers directly in a strongly typed way in the tree. Implicitly generate them using a global context if requested while unhydrated instead of special casing identifiers in the read code paths in multiple places.

Provide contextual defaults as part of prepare for hydration pass instead of its own pass.

Overall, this refactor should make the handling un unhydrated data simpler and more robust:

  • It is no longer possible for the unhydrated tree and map tree and/or the maps associating them to be out of sync.
  • The special case handling of identifiers has been implemented in a general way that will handle any contextual defaults, and no longer needs special logic in any code path reading from the tree.
  • There is no longer questionable ownership of ExclusiveMapTree nodes due to cache lookup.
  • Memory use should be slightly reduced by avoiding having the separate map tree objects and the caches to associate them with the unhydrated nodes.

Breaking Changes

Defaulted Identifiers show up when enumerating fields on an unhydrated node.

This seems like an improvement/simplification (makes unhydrated and hydrated nodes more similar, and identifiers less special), but could theoretically break something.

Reviewer Guidance

The review process is outlined on this wiki page.

@github-actions github-actions bot added base: main PRs targeted against main branch area: dds Issues related to distributed data structures area: dds: tree labels May 30, 2025
CraigMacomber added a commit that referenced this pull request May 31, 2025
@CraigMacomber CraigMacomber changed the title Unhydrated refactor refactor: Store data in unhydrated nodes directly instead of wrapping MapTree nodes Jun 2, 2025
@@ -10,30 +10,24 @@ import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
import {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file and its functions have not been renamed yet to help simplify the diff.
A follow-up change will rename them.

@CraigMacomber CraigMacomber marked this pull request as ready for review June 2, 2025 17:08
@noencke noencke requested a review from daesunp June 2, 2025 22:48
@CraigMacomber CraigMacomber merged commit 3a5d0ac into microsoft:main Jun 9, 2025
34 checks passed
@CraigMacomber CraigMacomber deleted the unhydratedRefactor branch June 9, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree area: dds Issues related to distributed data structures base: main PRs targeted against main branch changeset-present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants