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

geojson: marshal/unmarshal BSON #123

Merged
merged 1 commit into from
Feb 19, 2023
Merged

geojson: marshal/unmarshal BSON #123

merged 1 commit into from
Feb 19, 2023

Conversation

paulmach
Copy link
Owner

Requested in #122

This PR adds BSON marshaling and unmarshaling support to the geojson types. The goal is to mimic the functionality of the JSON. This should allow the types to work seamlessly with the mongodb driver.

Benchmarks for JSON vs. BSON are interesting. BSON is faster but uses much more memory.

BenchmarkFeatureMarshalJSON-10           2916        2038514 ns/op        748287 B/op     7234 allocs/op
BenchmarkFeatureMarshalBSON-10           4378        1369295 ns/op       1100787 B/op    12993 allocs/op
BenchmarkFeatureUnmarshalJSON-10         1477        4060850 ns/op        766427 B/op    23047 allocs/op
BenchmarkFeatureUnmarshalBSON-10         2944        2074189 ns/op       1490398 B/op    32654 allocs/op
BenchmarkGeometryMarshalJSON-10         23251         258126 ns/op         49462 B/op        3 allocs/op
BenchmarkGeometryMarshalBSON-10         49639         121049 ns/op         69519 B/op      909 allocs/op
BenchmarkGeometryUnmarshalJSON-10        8845         675808 ns/op         79992 B/op     2046 allocs/op
BenchmarkGeometryUnmarshalBSON-10       19322         312273 ns/op        272869 B/op     6020 allocs/op

@jclaessens97
Copy link

Works like a charm 👌

Thanks a lot, @paulmach 🙏

@paulmach paulmach merged commit 2f8f920 into master Feb 19, 2023
@paulmach paulmach deleted the bson branch February 19, 2023 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants