Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gob encoding and internal data types #46

Closed
ostafen opened this issue May 4, 2022 Discussed in #41 · 0 comments · Fixed by #47
Closed

Gob encoding and internal data types #46

ostafen opened this issue May 4, 2022 Discussed in #41 · 0 comments · Fixed by #47
Labels
enhancement New feature or request
Milestone

Comments

@ostafen
Copy link
Owner

ostafen commented May 4, 2022

Discussed in #41

Originally posted by ostafen May 1, 2022
Hi, everyone, I created this discussion to collect opinions and suggestions, since this is a very sensitive topic.
Currently, CloverDB serializes documents to json before storing them on disk. This has been done because of the fact that, early versions of the library used ".json" files directly to store data.
But since Clover evolved since that time (it now uses the badger kv-store), this solution is no more acceptable for the following reasons:

  • instances of the time.Time struct cannot be correctly recovered, because they are converted to string when serialized and, as a consequence, json.Unmarshal() deserializes them to normal stings. This affects queries involving dates or times (unless you decide to store them as a timestamp during document insertion).
  • All numbers are silently converted to float64.

To fix these issues, I was thinking to switch to the gob encoding, which preserves the correct type for each document field.
This open a new question about internal data types:

Which numeric types should be supported by clover? Should we preserve all of the types (int, uint8/int8, uint16/int16... and so on) or should we restrict types (using int64 for integer numbers and float64 for double numbers, for example).

What do you think about this?

@ostafen ostafen mentioned this issue May 4, 2022
@ostafen ostafen linked a pull request May 4, 2022 that will close this issue
@ostafen ostafen added the enhancement New feature or request label May 4, 2022
@ostafen ostafen added this to the 1.2.0 milestone May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant