objectbox / objectbox-go

Embedded Go Database, the fast alternative to SQLite, gorm, etc.
https://objectbox.io
Apache License 2.0
1.07k stars 46 forks source link

Query.Find() can't handle large slice attributes #20

Closed liquidiert closed 4 years ago

liquidiert commented 4 years ago

I'm currently facing an odd behaviour of queries on, and that's probably important, the raspberry pi.

Normal behaviour of a query with a condition like Record_.Patient.Equals(patient.Id), where Patient is another entity and linked via one (Patient) to many (Record) and patient.Id is the ObjectBox id, to return a slice of all records that match the condition. Records also has an attribute Points which is the "ObjectBox native type" []string.

So the problem now is, that if the Points attribute contains more than roughly 500 strings Find() returns an empty slice. Though Count() and other methods still work perfectly fine.

My current workaround is to use FindIds() and get the Points via GetMany()

liquidiert commented 4 years ago

I've got to use []string because I need float precision and []float isn't supported yet btw

vaind commented 4 years ago

I'll try to reproduce that on the RPi and get back to you.

liquidiert commented 4 years ago

Thanks @vaind 👍 I made a repo with simple dummy code for you ;)
https://github.com/liquidiert/obx_rpi_bug

vaind commented 4 years ago

There was an issue with the objectbox-c not reporting the right value in obx_supports_bytes_array(). This caused the Go lib to use vector-based methods which in some cases failed (on large objects). We have released a new version of the C library (v0.8.2) so in order to resolve the issue for yourself, please update, e.g. using the install.sh script in this (Go) repo..

Additionally, I've noticed your example silently ignores all errors (the _ underscore secondary return in many calls). If that hasn't been the case, you'd have got an actual error text related to the issue above. As general advice, you should almost never ignore errors but rather act upon them (e.g. fail method execution and propagating them).

liquidiert commented 4 years ago

Ah ok didn't thought there were still errors from the underlying c library but good to know. And thanks! Closing 👍