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

Deep Migration #233

Open
jkeon opened this issue Apr 30, 2023 · 3 comments
Open

Deep Migration #233

jkeon opened this issue Apr 30, 2023 · 3 comments

Comments

@jkeon
Copy link
Member

jkeon commented Apr 30, 2023

Building off of #232 there is a chance that Entity references aren't remapped if you bury them deep inside collections.

  • There are still some ways you can miss Entities. If you have an EPD then you have a relationship of Key: Entity to Value: Something.
    • The Key can be remapped no problem
    • The Something might be a Collection like UnsafeParallelHashMap. If the key or something in that collection's value has an Entity reference, there's no way right now for us to know.
    • I think I can scan this an account for it, but I might have to add the check for each type of Unsafe Collection.
@jkeon jkeon mentioned this issue Apr 30, 2023
2 tasks
@mbaker3
Copy link
Member

mbaker3 commented May 1, 2023

For the time being can we have a warning or something that comes up?

@jkeon jkeon mentioned this issue May 1, 2023
2 tasks
@jkeon
Copy link
Member Author

jkeon commented May 1, 2023

Added a PR #237 to emit a warning.

To implement this fully we'll want to do the following:

  1. Possibly just scan all types in the Assemblies.
    1. Locate the Entity references and check for collections that might be hiding Entity references.
  2. When we find a collection, we register that to the TypeOffsetInfo for the type so that we know where in the struct that collection is located and also what type is is. HashMap vs Array etc.
  3. When we go to remap, there's the basic remap of Entity fields like normal
  4. But we also check if there are any fields that might have Entity references hidden inside them and run those as well.
  5. And we also check if there are any Collections fields that might have Entity references hidden inside them and run those too.

For the nested struct check, it's just piping through the same remap function.
For the collections check, we'll need to check the "type" of collection via the TypeOffsetInfo and map that to a function that exists to be able to remap the contents of the collection.

  • The remapping for a HashMap will be different vs an Array for example.
  • If no remapping function exists for a type, we'll error to let the developer register a custom one. (In case they build their own custom collection).
  • For each instance in the collection, we just run through the regular remap function.

The recursive nature will ensure that we nab every single nested Entity reference even if it's in a collection of collections of collections etc.

@jkeon
Copy link
Member Author

jkeon commented May 1, 2023

From : #237 (comment)

I don't know where you want to put this for future reference but we discussed how there may be cases where a pointer is being stored that we do not want to dive into an migrate. Maybe that memory address has already been migrated or something.

We want to figure out how to handle these situations. Maybe require developers to annotate unsafe fields with a [RemapUnsafeEntityDataOnMove] or something. Would need an [ExcludeUnsafeEntityDataOnMove] (names WIP)

There may be cases where we don't want a collection or pointer to be remapped, so we'll make the developers opt in on this to both and squawk when they don't let us know how to handle it.

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

2 participants