Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-17 Thread Sofiane Cherchalli
Thanks Medina! I'll give it a try On Friday, August 11, 2017 at 1:19:50 AM UTC+2, Diego Medina wrote: > > Hope you had a goo time on vacation. > > No need for custom types, specially with csv files, all you get are > "string" type, but you know that some columns are actually float values, or >

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-11 Thread Egon
I've suggested this approach based in the slack, adding it here as well to make it searchable. Implement Reader/Writer such that you can do: func ProcessLine(in *Reader, out *Writer) error { start, finish, participant := in.Float64(), in.Float64(), in.String() if err := in.Err(); err !=

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-10 Thread Diego Medina
Hope you had a goo time on vacation. No need for custom types, specially with csv files, all you get are "string" type, but you know that some columns are actually float values, or ints or plain text. So we have several functions that "clean, format, etc" different kinds of data, and just call

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-10 Thread Sofiane Cherchalli
Hi Medina, Sorry I was on vacations. So do you mean the way to do it is to hardcode most of functionality. No need to use custom types, interfaces. Just plain text parsing? In that case, how easy is it to evolve or refactor the code? Thanks On Wednesday, July 26, 2017 at 8:36:15 PM UTC+2,

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-26 Thread Diego Medina
I think we have a similar setup to what you are trying to do, we also started with Scala and about 3 years ago we moved it to Go (still use Scala for other parts of our app). While working in Scala and other languages you are encourage to abstract things as much as you can, in Go it is often

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-26 Thread Sofiane Cherchalli
The schema is statically specified. The values always arrive in a defined order. Each value has a defined type. On Tuesday, July 25, 2017 at 3:01:14 AM UTC+2, rog wrote: > > On 24 July 2017 at 23:21, Sofiane Cherchalli > wrote: > >> Yes, I'm trying to stream CSV values

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-24 Thread roger peppe
On 24 July 2017 at 23:21, Sofiane Cherchalli wrote: > Yes, I'm trying to stream CSV values encoded in strings. A schema defines > a type of each value, so I have to parse values to verify they match the > type. Once validation is done, I apply functions on each value. > Is

[go-nuts] Re: Code Review - Applying functions on custom types

2017-07-24 Thread Sofiane Cherchalli
Hi Whom, Yes you could with columnar CSV and apply functions to column values, something basically similar to what does spark. In my case I receive streams of rows. Thx -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-24 Thread roger peppe
On 24 July 2017 at 05:10, Sofiane Cherchalli wrote: > Hi Silviu, > > On Sunday, July 23, 2017 at 2:11:29 AM UTC+2, Silviu Capota Mera wrote: >> >> Hi Sofiane, >> >> "Is my design wrong?" >> Without a bigger picture of what your final aim is, it's hard for an >> external

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-23 Thread Sofiane Cherchalli
Hi Silviu, On Sunday, July 23, 2017 at 2:11:29 AM UTC+2, Silviu Capota Mera wrote: > > Hi Sofiane, > > "Is my design wrong?" > Without a bigger picture of what your final aim is, it's hard for an > external observer to tell you if your design is right or wrong. > I was unable to fully grasp the

[go-nuts] Re: Code Review - Applying functions on custom types

2017-07-22 Thread Egon
In a uniform column situation I would model a single Column, effectively have: type StringColumn struct{ Cells []string } type FloatColumn struct{ Cells []int } This should also make many of the operations easier to implement. But since I'm unclear what the end goal of this solution is, I'm

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-22 Thread Sofiane Cherchalli
Hi Silviu, Thanks for the example. I have some questions popping up in my mind: Is my design wrong? Is your example and/or Roger's the most idiomatic way to do it in Go? Is it wrong to use type assertions in Go? Thanks. On Thursday, July 20, 2017 at 6:32:47 PM UTC+2, Silviu Capota Mera

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-21 Thread Sofiane Cherchalli
Hi Rog, Please inline comments. Thx On Thursday, July 20, 2017 at 1:58:09 PM UTC+2, rog wrote: > > I'm not convinced that holding all your values in a uniform way > is going to be that helpful for you. You might be better using reflection > to map the columns into a struct type (there's

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-21 Thread Sofiane Cherchalli
Hi Rog, Please inline comments. Thx On Thursday, July 20, 2017 at 1:58:09 PM UTC+2, rog wrote: > > I'm not convinced that holding all your values in a uniform way > is going to be that helpful for you. You might be better using reflection > to map the columns into a struct type (there's

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-20 Thread silviucapota
Hi Sofiane, Answering the "what type" question is pretty much unavoidable. You can embed that forking logic inside the "on the fly" function, like in Roger's example (using a switch v := v.(type) construct) or you can use reflect. Alternatively, you can group your transformation functions

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-07-20 Thread roger peppe
I'm not convinced that holding all your values in a uniform way is going to be that helpful for you. You might be better using reflection to map the columns into a struct type (there's probably a package out there already that can do that). However, to answer without questioning the whole