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

Align ReactiveField & Reference behavior #901

Open
stephenh opened this issue Nov 30, 2023 · 0 comments
Open

Align ReactiveField & Reference behavior #901

stephenh opened this issue Nov 30, 2023 · 0 comments

Comments

@stephenh
Copy link
Collaborator

Currently:

  • PAP.load always pulls in its full load hint
  • PAP.isLoaded always checks the isLoaded(entity, hint)
  • populateDataLoader skips calling PAP.load for any non-maybe-dirty PAPs

For PAR:

  • PAR.load conditionally pulls in the full load hint only if dirty, otherwise loads the ref
  • PAR.isLoaded checks maybe-dirty, if dirty checks isLoaded(entity, hint), otherwise loaded
  • populateDataLoader always calls PAR.load to ensure the ref is loaded

Ideally we want to be able to:

  • Have a list of ~1000 books with PAPs like isPublic
  • Create a new 1001st book, and have it calc's isPublic
  • Have the author that owns 1001 books count a.books.get.sum(b.isPublic.get) without causing the 1000 existing books to load their properties

Also:

  • In em.flush, we do specifically walk from "actually changed/dirty fields" to "actually need recalced", i.e. em.flush/ReactionsManager will itself only recall relation.load() on known-dirty entities. However this accurate reversal retries async hopping.
  • We do have a heuristic of "maybe dirty", which can be asked synchronously, but it is just a guess--if we have 1000 books loaded in memory, all of their book.isPublic-s will be "maybe dirty"
  • It seems like ideally we only want to use "maybe dirty" in synchronous checks like isLoaded, and then once we have the opportunity to be async, i.e. load, we should switch away from the lossy "maybe dirty" and ask ReactionsManager to tell if we're "actually dirty"
  • This will mean that PAP.load() and PAR.load() become (for PAP) or stay (for PAR) opaque and "ignore" the user's request to load the full load hint. This should be fine.
  • The only place that needs to override this is em.touch and/or em.recalc.
  • All other usages of forceReload (that is not touch/recalc) should go away
@stephenh stephenh changed the title Align PersistedAsyncProperty & Reference behavior Align ReactiveField & Reference behavior Mar 23, 2024
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

No branches or pull requests

1 participant