rkdb
rkdb copied to clipboard
Make data types bijective
right now, we have clear conversions from KDB types to R types, but it is not bijective so converting from R to KDB is not clear. For example, KDB time converts to R difftime, but KDB minute also converts to R difftime.
If I send R difftime to KDB, I get a dictionary on the other side with the attributes as keys.
But this gives us a clue for a useful refactor of rkdb. Lets use custom attributes in R to construct types that rkdb can convert into proper KDB types. For exmaple, make a function like rkdb::minute()
that sets the attribute and ultimate results in a minute type in KDB. On the way back, the same thing happens. It is still a difftime in R, but has this attribute indicating which KDB type it came from.