Closed tpetricek closed 9 years ago
Looks great to me. Is it efficient? I see you emit code, but do we end up avoiding a lot of boxing or other inefficient stuff?
The current version is more of a proof of concept and it does not avoid unboxing. It basically generates something like:
member x.Foo : float =
underlyingVector.GetObject(<index>)
|> Convert.convertType<float> ConversionKind.Flexible
Now that I think more about this, it should be possible to generate more clever code that would avoid boxing & unboxing and would be faster. Thanks for the suggestion - I'll look into that and update the PR.
Two updates here:
As for the performance, I added the following to performance tests. First, using typed:
let rows = titanic.GetRowsAs<ITitanicRow>()
let mutable c = 0
for i in fst rows.KeyRange .. snd rows.KeyRange do
c <- c + rows.[i].Pclass
And the same thing using untyped API:
let rows = titanic.Rows
let mutable c = 0
for i in fst rows.KeyRange .. snd rows.KeyRange do
c <- c + titanic.Rows.[i].GetAs<int>("Pclass")
The typed version takes ~0.4ms and the untyped one ~40ms :-)
Sweet!
Wow, that's a great win!
Looks great! Please merge at your convenience!
Thanks - I got rid of the forgotten comments & I'm merging this.
Initial implementation that makes it possible to use frame rows in a more type safe way than using just
df.Rows
(without waiting for type provider features in the next version of F#). This lets the user define an interface (by hand) and then fits the columns of the frame to the members of the interface:Here are some things & questions to do before checking this in: