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

Polymorphic class design support #10

Open
stijnb1234 opened this issue Oct 13, 2023 · 2 comments
Open

Polymorphic class design support #10

stijnb1234 opened this issue Oct 13, 2023 · 2 comments

Comments

@stijnb1234
Copy link

stijnb1234 commented Oct 13, 2023

I want to use storm with a Polymorphic class design. I have a Vehicle class which contains a List<Part> with different types of parts.

I have the following class design:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
abstract class Part {
  private double x;
  private double y;
  private double z;
}

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "type")
abstract class EquipablePart extends Part {
  private ItemStack item;
}

@JsonTypeName("seat")
class Seat extends Part {
  private boolean steer;
}

@JsonTypeName("skin")
class Skin extends EquipablePart {}

I would like to store this using Storm. This is currently not possible as far as I know. I'm also not fully sure how this should be implemented. If I convert to JSON using Jackson, it looks like this:

[
  {
    "type": "skin",
    "x": 0,
    "y": 0,
    "z": 0,
    "item": {
      "item": "rO0ABXcEAAAAAXNyABpvcmcuYnVra2l0LnV0aWwuaW8uV3JhcHBlcvJQR+zxEm8FAgABTAADbWFw\ndAAPTGphdmEvdXRpbC9NYXA7eHBzcgA1Y29tLmdvb2dsZS5jb21tb24uY29sbGVjdC5JbW11dGFi\nbGVNYXAkU2VyaWFsaXplZEZvcm0AAAAAAAAAAAIAAkwABGtleXN0ABJMamF2YS9sYW5nL09iamVj\ndDtMAAZ2YWx1ZXNxAH4ABHhwdXIAE1tMamF2YS5sYW5nLk9iamVjdDuQzlifEHMpbAIAAHhwAAAA\nBHQAAj09dAABdnQABHR5cGV0AARtZXRhdXEAfgAGAAAABHQAHm9yZy5idWtraXQuaW52ZW50b3J5\nLkl0ZW1TdGFja3NyABFqYXZhLmxhbmcuSW50ZWdlchLioKT3gYc4AgABSQAFdmFsdWV4cgAQamF2\nYS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAA36dAANTEVBVEhFUl9CT09UU3NxAH4AAHNxAH4A\nA3VxAH4ABgAAAAVxAH4ACHQACW1ldGEtdHlwZXQAC1VuYnJlYWthYmxldAAGRGFtYWdldAAFY29s\nb3J1cQB+AAYAAAAFdAAISXRlbU1ldGF0AA9DT0xPUkFCTEVfQVJNT1JzcgARamF2YS5sYW5nLkJv\nb2xlYW7NIHKA1Zz67gIAAVoABXZhbHVleHABc3EAfgAOAAAAAXNxAH4AAHNxAH4AA3VxAH4ABgAA\nAAVxAH4ACHQABUFMUEhBdAADUkVEdAAEQkxVRXQABUdSRUVOdXEAfgAGAAAABXQABUNvbG9yc3EA\nfgAOAAAA/3NxAH4ADgAAAP9zcQB+AA4AAAAAc3EAfgAOAAAA/w==\n"
    }
  },
  {
    "type": "seat",
    "x": 0.3,
    "y": -1.05,
    "z": 0.65,
    "steer": true
  }
]

Please note the type parameter, which is used to determine the class to convert to.

Do you have any idea on the best way to implement this into Storm? I think it can be useful in various situations.

@Mindgamesnl
Copy link
Owner

I'm currently in the planning phase for a new library, not suitable as a drop-in replacement for Storm but one to serve more than a minimal viable product and be less opinionated.

Key changes include proper schema, relations, and api's to extend base functionality.

SQL itself doesn't really have support for polymorphism due to its strictness on data types (by design), though there are popular methods to handle this (like the supertype model), which is one that we're considering.

I'll update this issue with a link to the project once it goes public (shouldn't be too long)

@stijnb1234
Copy link
Author

Thanks, sounds good! Please keep me updated. ;)

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