Zaid-Ajaj / LiteDB.FSharp

Advanced F# Support for LiteDB, an embedded NoSql database for .NET with type-safe query expression through F# quotations
MIT License
180 stars 22 forks source link

Added typeshape mapper #38

Closed vshapenko closed 5 years ago

vshapenko commented 5 years ago

This PR adds typeshape mapper support for LiteDb.Fsharp. Currently it passes 76 of 78 tests

Zaid-Ajaj commented 5 years ago

Awesome! can you add your mapper to the tests to see which ones are failing? There is this function:

let useDatabase (f: LiteDatabase -> unit) = 
    let mapper = FSharpBsonMapper()
    use memoryStream = new MemoryStream()
    use db = new LiteDatabase(memoryStream, mapper)
    f db

create another one useTypeShapeDb:

let useTypeShapeDb(f: LiteDatabase -> unit) = 
    let mapper = Experiemental.TypeShapeMapper()
    use memoryStream = new MemoryStream()
    use db = new LiteDatabase(memoryStream, mapper)
    f db

Then parameterize the tests such that they take (useDatabase : LiteDatabase -> unit) parameter, what do you think?

vshapenko commented 5 years ago

@Zaid-Ajaj Based on tests, we got 3x performance gain

Zaid-Ajaj commented 5 years ago

Wohoo Nice! 🚀 it looks like these tests are failing:

I guess that is because Bson.deserialize and Bson.serialize are still mapper-dependent, can you parameterize these as well such that take and use a mapper as input?

Lastly, it would be great to add a little section to the README regarding how to use the type-shape mapper 🙏

vshapenko commented 5 years ago

Wohoo Nice! 🚀 it looks like these tests are failing:

I guess that is because Bson.deserialize and Bson.serialize are still mapper-dependent, can you parameterize these as well such that take and use a mapper as input?

Lastly, it would be great to add a little section to the README regarding how to use the type-shape mapper 🙏

Bson.serialize and deserialize do not depend on mapper

I guess tests failed because i use different serialization format for DU etc

Also looks like quotation expressions heavily tied to Bson.fs

Zaid-Ajaj commented 5 years ago

I see, I though we could make Bson.fs mapper-dependent but that is OK, I guess we can merge this, I will put the Bson specific tests in their own testList that only takes FSharpBsonMapper

Zaid-Ajaj commented 5 years ago

I will add a README section as well, will be able to work on this later this evening

Zaid-Ajaj commented 5 years ago

Published as of v2.12.0 :rocket: