-
Notifications
You must be signed in to change notification settings - Fork 37
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
[proposal] Series struct like Ecto.Schema #30
Comments
I don't know if I understand you correctly, so I might tell you things that might not answer your question at all. Please tell me if that happens. The definition is called When writing points it is necessary to know whether a value is a tag or a field. Otherwise the measurement and series name would be the same and no field would be used internally for indexing and structuring the data. Might be no fun when querying. That is also the way the data is set up when writing: fields = %MySeries.Fields{ value: 100, value_desc: nil }
tags = %MySeries.Tags{ host: "www", core: nil }
point = %MySeries{ fields: fields, tags: tags } A thing however might be an automatic separation of values into their respective fields an tags: # somewhat abbreviated
MySeries.from_map(%{ host: "www", value: 100 }) The result of that would be identical to the above one, just with said automatic detection what goes where. And that looks like some really usable feature while still maintaining the current structure and internal workings. If you meant something different please say so. After all even a rename of |
as per your last example, I believe that you have understood very well my suggestion. After all, the idea is that the internal operation is basically the same (separation through tags and fields). What changes would the final structure, that is, the internally I've already done this implementation in a project, if you want I can make a PR with it and already take this opportunity to add tests. Even I like it to be made into a new module ( |
I whipped up a somewhat prototypical implementation for this hydration operations in a separate branch (full diff). Having the ability to construct any struct from a plain map also made it easy to be able to turn individual query results back into them. Something I had on my to do list for quite some time... Would definitely like to see your approach before going any further with this 👍 |
I have created the PR without tests for now, so you can take a look. I believe that if we add the my connection with override and helpers:
|
From what I see the basic intent is to flatten the current series struct (remove the nesting for fields/tags). Your helper methods are mostly looking like a rewording to other things ( Please correct me if I am misunderstanding something. One thing to take into account with a flattened map is the |
why not use a
struct
likeEcto.Schema
for theSeries
?ex:
The text was updated successfully, but these errors were encountered: