Skip to content

Commit

Permalink
BSON etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Dec 9, 2024
1 parent 39d9cae commit e2e5bc1
Showing 1 changed file with 82 additions and 8 deletions.
90 changes: 82 additions & 8 deletions lesson11.slide
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ https://github.com/RedHatOfficial/GoCourse
- gob
- CBOR
- BSON
- MessagePack

- https://en.wikipedia.org/wiki/Comparison_of_data-serialization_formats



Expand Down Expand Up @@ -283,24 +286,95 @@ https://github.com/RedHatOfficial/GoCourse



* MessagePack

- binary format
- efficient data storage
- objects can be stored as maps
- true arrays

* MessagePack: supported data types

- Nil (null, None)
- Boolean
- Integer (small ones stored efficently)
- Float (single, double) incl. Nan + Infinity
- String
- Binary (byte array)
- Array (sequence of objects)
- Map (sequence of key-value pairs)
- Extension

* MessagePack: serializing `nil`

.play lesson11/msgpack_nil.go /^package main/,/^func main/

* cont.

.play lesson11/msgpack_nil.go /^func main/,/^}/

* MessagePack: serializing small integer

.play lesson11/msgpack_small_int.go /^func main/,/^}/

* MessagePack: serializing single float

.play lesson11/msgpack_single.go /^func main/,/^}/

* MessagePack: serializing a map

.play lesson11/msgpack_map.go /^func main/,/^}/

* MessagePack: serializing map of any 1/2

.play lesson11/msgpack_map2.go /^func main/,/Encoder created/

* MessagePack: serializing map of any 2/2

.play lesson11/msgpack_map2.go /Encoder created/,/^}/

* gob

- Gobs of data
- based on reflection
- very efficient (size+speed)
- built-in into Go stanard library

* gob marshalling 1/2

.play lesson11/gob_marshal_struct.go /^package/,/^func main/

* gob marshalling 2/2

.play lesson11/gob_marshal_struct.go /^func main/,/^}/

* BSON

* CBOR
- "binary JSON"

* BSON serialization 1/2

.play lesson11/bson_serialize.go /^package/,/^func main/

- Concise Binary Object Representation
* BSON serialization 2/2

.play lesson11/bson_serialize.go /^func main/,/^}/

* BSON deserialization 1/2

.play lesson11/bson_deserialize.go /^package/,/^func main/

* BSON deserialization 2/2

.play lesson11/bson_deserialize.go /^func main/,/^}/

* Size comparisons

.code lesson11/sizes.txt
.play lesson11/size_comparison.go

* Configuration files
* Size comparisons

- INI files
- TOML
- YAML
- even JSON, XML etc.
.code lesson11/sizes.txt


#last slide
Expand Down

0 comments on commit e2e5bc1

Please sign in to comment.