realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Java/Android equivalent of Swift's Type Projection? #7701

Closed ghost closed 1 year ago

ghost commented 1 year ago

Problem

I am working on an app that stores large arrays of data from sensors. (Easily upwards of 10k elements per array). I have noticed that this is starting to significantly slow down realm, and in some cases stop it in its tracks entirely from syncing to atlas due to timeout.

In some tests, I've determined that if I serialize the data as JSON, my problems go away and everything is back up to speed as expected. While reading through iOS documentation, I found type projection. This would be a huge help as I can "hide" the serialization/deserialization and continue to work with arrays in my app while storing everything as JSON within Mongo.

The problem is I don't see any equivalent for Android. Am I missing something obvious like a constructor I can override?

Solution

An equivalent to Swift's Type Projection but for Android/Java.

Alternatives

Obviously I can work around this using something like the Enum Solution but it would be far more convenient and clean to have something like Swift's type projection.

How important is this improvement for you?

I'd like to see it, but have a workaround

rorbech commented 1 year ago

Hi @GriffinJBC. We already have an issue for tracking support for projections in #5426, so will close this one, but maybe you would rather track the similar feature in our new Kotlin SDK (https://github.com/realm/realm-kotlin/issues/947)