tirkarthi / clj-foundationdb

A Clojure wrapper for FoundationDB
MIT License
19 stars 0 forks source link

get-val converts everything to tuple #15

Open piranha opened 6 years ago

piranha commented 6 years ago

When you do (get-val tr "test") it's the same as (get-val tr ["test"]). I'm pretty sure that's what you intended, but from the point of view of somebody who is just learning how to use FoundationDB, it's really surprising.

I'd say it would be nice to convert only sequences to tuples, and leave strings as just bytes.

tirkarthi commented 6 years ago

Hi @piranha ,

Thanks for the issue. It's the intended action. I started this project while learning about FoundationDB using the Java client which used Tuples and I assumed tuples to be the only way to store the data. Later I came to realize that the client just needs bytes while looking at the Python docs and not everything has to be tuple. I can do the change but the problems was that while de-serializing I don't know whether it was stored as a simple byte or as a tuple encoded one and I thought to encode everything as a Tuple to ease the implementation. I felt the implementation and API to be more easy to use when the user has to pass only the string or vector and I encode and decode them with tuple layer without them worrying about the underlying encoding and decoding.

I agree it's a limitation from my side and this also involves doing tuple encoding for everything that has a slight performance impact. I would encourage you to look at https://github.com/vedang/clj_fdb/ for an alternate implementation which is more composable and low-level where you have more control over the serialization. Maybe I will add a note on this in the README or docs about this implementation detail.

Thanks