Support for vectors of int16/32/64
Looking at the schema example: https://github.com/objectbox/objectbox-generator/blob/main/test/comparison/testdata/fbs/typeful/schema.fbs There is only support for vector of string, byte, ubyte and recently float in v4 beat. Are there plans to support vector of: int16, int32, int64, uint16, uint32 and uint64.
I have a system that needs a vector of uint64 and have had to resort to using a vector of strings and perform conversion when reading and writing to this field, this is not ideal. Would rather not have to create a new table and have each row store one item of the vector and make a relationship to the parent table.
Yes, there are plans to support all vector types.
vector of uint64 and have had to resort to using a vector of strings
or a byte vector; may be easier (just a cast)?
Not sure what you mean by casting. I tried a byte vector and objectbox-generator creates in database.obx.hpp:
struct TestTable{
...
std::vector<int8_t> testvector;
};
Test code, note: int8_t range: −128 to +127
TestTable record = {};
record.testvector.emplace_back(100); // In range of int8_t
record.testvector.emplace_back(999); // out of range of int8_t
obx_id id = testTable.put(record);
testTable.get(id); // print contents of testvector
After putting this in table and reading back get: 100 and 231(999 overflow as expected)
std::vector<int8_t> cannot be cast to std::vector<uint32_t> I'm getting overflow behavior (which is what I expected), getting (uint32_t)testvector[1] equals 4294967271, not 999 as the other bits are set to 1 in this case
Vector support for the other datatypes would be most appreciate.
You need to look at this from the memory perspective; anything is stored in memory, and C/C++ gives you flexibility what is stored in memory.
Example:
std::vector<int8_t> testvector{42, 0, 0, 0, 0, 0, 0, 0, -128, 0, 0, 0, 0, 0, 0, 0}; // 16 bytes
uint64_t* ptr = (uint64_t*) testvector.data();
size_t size = testvector.size() / sizeof(uint64_t);
assert(size == 2);
assert(ptr[0] == 42);
assert(ptr[1] == 255);