SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
MessagePack(msgpack):
A Compact and Fast Serialization Library
Takatoshi Kondo
2015/5/14 1Copyright OGIS-RI 2015
• Taka (Takatoshi Kondo)
– from TOKYO, JAPAN
• OGIS-RI Co., Ltd.
– Developing Pub/Sub IoT Platform using MessagePack
• A committer on the msgpack-c OSS project
• Other experience: Wrote the “Boost.MSM Guide”
– http://redboltz.wikidot.com/boost-msm-guide
2015/5/14 Copyright OGIS-RI 2015 2
About me
What is MessagePack?
2015/5/14 Copyright OGIS-RI 2015 3
• Same as JSON
– Portable
– Contain basic type information
• For example, map, array, string, boolean...
– Composite data structure
• Different from JSON
– Smaller size
– Binary coded
– Can handle binary data without text encoding such as Base64
– Easier to parse, requires less computing power
2015/5/14 Copyright OGIS-RI 2015 4
MessagePack vs. JSON
• Same as JSON
– Portable
– Contain basic type information
• For example, map, array, string, boolean...
– Composite data structure
• Different from JSON
– Smaller size
– Binary coded
– Can handle binary data without text encoding such as Base64
– Easier to parse, requires less computing power
2015/5/14 Copyright OGIS-RI 2015 5
MessagePack vs. JSON
msgpack::object
nil boolean u64 i64 f64
str bin ext array map
*
*
double, float object_kv
key val
MessagePack/Boost.Serialization
2015/5/14 6Copyright OGIS-RI 2015
• The goals of the msgpack and the
Boost.Serialization are different.
– msgpack: Interexchange the data with
different programming languages.
– Boost.Serialization: Serialize every data and relations.
e.g.) shared_ptr
• msgpack can be used as a portable binary
archive of the Boost.Serialization.
– https://github.com/redboltz/rui/tree/support_boost_1_57_0
• Forked from Norihisa Fujita’s implementation
C++
msgpack
ruby
python
shared_ptr
shared_ptr
shared_ptr
42
42
Boost.Serialization
format
Supported Programming Languages
2015/5/14 Copyright OGIS-RI 2015 7
Pack/Unpack
2015/5/14 8
#include <tuple>
#include <string>
#include <sstream>
#include <msgpack.hpp>
int main() {
auto t1 = std::make_tuple("hello", true, 42, 12.3);
std::stringstream ss;
msgpack::pack(ss, t1);
msgpack::unpacked unpacked
= msgpack::unpack(ss.str().data(), ss.str().size());
msgpack::object obj = unpacked.get();
auto t2 = obj.as<std::tuple<std::string, bool, int, double>>();
assert(t1 == t2);
}
You can use any types that have
the member function
write(const char*, std::size_t);
Copyright OGIS-RI 2015
packing
unpacking
convering
Stream Deserialization
2015/5/14 9
class unpacker {
public:
// Constructor is omitted in this presentation
void reserve_buffer(std::size_t size);
char* buffer();
void buffer_consumed(std::size_t size);
bool next(unpacked& result);
};
Copyright OGIS-RI 2015
Stream Deserialization
2015/5/14 10Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
Stream Deserialization
2015/5/14 11Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
The size may decided by receive performance,
transmit layer's protocol and so on.
Stream Deserialization
2015/5/14 12Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
The size may decided by receive performance,
transmit layer's protocol and so on.
unp has at least try_read_size buffer on this point.
Stream Deserialization
2015/5/14 13Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
The size may decided by receive performance,
transmit layer's protocol and so on.
unp has at least try_read_size buffer on this point.
input is a kind of I/O library object.
read message to msgpack::unpacker's internal buffer directly.
Stream Deserialization
2015/5/14 14Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
The size may decided by receive performance,
transmit layer's protocol and so on.
unp has at least try_read_size buffer on this point.
input is a kind of I/O library object.
read message to msgpack::unpacker's internal buffer directly.
notify msgpack::unpacker actual consumed size.
Stream Deserialization
2015/5/14 15Copyright OGIS-RI 2015
std::size_t const try_read_size = 100;
msgpack::unpacker unp;
while (/* block until input becomes readable */) {
unp.reserve_buffer(try_read_size);
std::size_t actual_read_size = input.readsome(
unp.buffer(), try_read_size);
unp.buffer_consumed(actual_read_size);
msgpack::unpacked result;
// MessagePack data loop
while(unp.next(result)) {
msgpack::object obj(result.get());
}
}
The size may decided by receive performance,
transmit layer's protocol and so on.
unp has at least try_read_size buffer on this point.
input is a kind of I/O library object.
read message to msgpack::unpacker's internal buffer directly.
notify msgpack::unpacker actual consumed size.
Use obj. convert to C++ types
All complete msgpack message is processed at this point,
then continue to read addtional message.
Zero-Copy Deserialization
2015/5/14 16Copyright OGIS-RI 2015
unpacker buffer int string bin
header payload header payload
array
client memory
msgpack memory
Zero copy deserialization
2015/5/14 17Copyright OGIS-RI 2015
zone
chunk_list
finalizer_array
object
(array)
object
(int)
object
(string)
object
(bin)
via.array.ptr
chunk
unpacker buffer int string bin
header payload header payload
via.str.ptr via.bin.ptr
array
(msgpack format)
client memory
msgpack memory
managed using reference counter
unpacked
copy or reference is selectable
Zero copy deserialization
2015/5/14 18Copyright OGIS-RI 2015
zone
chunk_list
finalizer_array
object
(array)
object
(int)
object
(string)
object
(bin)
via.array.ptr
chunk
unpacker buffer int string bin
header payload header payload
via.str.ptr via.bin.ptr
array
(msgpack format)
client memory
msgpack memory
managed using reference counter
unpacked
convert
Convert to any types that adapts MessagePack
std::tuple<int, boost::string_ref, std::vector<char>>
copyref
copy or reference is selectable
MessagePack Adaptors
2015/5/14 19Copyright OGIS-RI 2015
https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor
C++ type msgpack::object type
bool bool
char* str
std::deque array
char positive/negative integer
signed ints *1 positive/negative integer
unsigned ints *2 positive integer
std::list array
std::map array
std::pair array
std::set array
std::string str
std::vector array
std::vector<char> bin
*1 signed ints signed char, signed short, signed int, signed long, signed long long
*2 unsigned ints unsigned char, unsigned short, unsigned int, signed long, signed long long
C++11 type
msgpack::
object type
std::array array
std::array<char> bin
std::forward_list array
std::tuple array
std::array array
std::unordered_map array
std::unordered_set array
boost type
msgpack::
object type
boost::optional<T> T
boost::string_ref str
MessagePack Adaptors
2015/5/14 20Copyright OGIS-RI 2015
https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor
#include <msgpack.hpp>
struct your_class : base1, base2 {
int a;
std::string b;
// You can choose any order.
// It is represented to the msgpack array elements order.
MSGPACK_DEFINE(a, b, MSGPACK_BASE(base1), MSGPACK_BASE(base2));
};
• If you have questions, feel free to contact me :)
• Takatoshi Kondo
– redboltz@gmail.com
– twitter: redboltz
• Resources
– MessagePack
• http://msgpack.org/
– msgpack-c
• https://github.com/msgpack/msgpack-c
– msgpack-c Documents
• https://github.com/msgpack/msgpack-c/wiki
– msgpack-c stream unpack algorithm
• A little old but concept is the same
• http://www.slideshare.net/taka111/msgpackc
2015/5/14 Copyright OGIS-RI 2015 21
Thank you
Extra Slides
2015/5/14 Copyright OGIS-RI 2015 22
Format
name
first byte (in binary) first byte (in hex)
positive
fixint
0xxxxxxx 0x00 - 0x7f
fixmap 1000xxxx 0x80 - 0x8f
fixarray 1001xxxx 0x90 - 0x9f
fixstr 101xxxxx 0xa0 - 0xbf
nil 11000000 0xc0
(never
used)
11000001 0xc1
false 11000010 0xc2
true 11000011 0xc3
bin 8 11000100 0xc4
bin 16 11000101 0xc5
bin 32 11000110 0xc6
ext 8 11000111 0xc7
ext 16 11001000 0xc8
ext 32 11001001 0xc9
float 32 11001010 0xca
float 64 11001011 0xcb
uint 8 11001100 0xcc
uint 16 11001101 0xcd
uint 32 11001110 0xce
uint 64 11001111 0xcf2015/5/14 Copyright OGIS-RI 2015 23
MessagePack Formats
https://github.com/msgpack/msgpack/blob/master/spec.md
Format
name
first byte (in binary) first byte (in hex)
int 8 11010000 0xd0
int 16 11010001 0xd1
int 32 11010010 0xd2
int 64 11010011 0xd3
fixext 1 11010100 0xd4
fixext 2 11010101 0xd5
fixext 4 11010110 0xd6
fixext 8 11010111 0xd7
fixext 16 11011000 0xd8
str 8 11011001 0xd9
str 16 11011010 0xda
str 32 11011011 0xdb
array 16 11011100 0xdc
array 32 11011101 0xdd
map 16 11011110 0xde
map 32 11011111 0xdf
negative
fixint
111xxxxx 0xe0 - 0xff
Format name first byte (in binary) first byte (in hex)
positive fixint 0xxxxxxx 0x00 - 0x7f
fixmap 1000xxxx 0x80 - 0x8f
fixarray 1001xxxx 0x90 - 0x9f
fixstr 101xxxxx 0xa0 - 0xbf
nil 11000000 0xc0
(never used) 11000001 0xc1
false 11000010 0xc2
true 11000011 0xc3
bin 8 11000100 0xc4
bin 16 11000101 0xc5
bin 32 11000110 0xc6
2015/5/14 Copyright OGIS-RI 2015 24
MessagePack Formats
https://github.com/msgpack/msgpack/blob/master/spec.md
2015/5/14 Copyright OGIS-RI 2015 25
MessagePack Format
https://github.com/msgpack/msgpack/blob/master/spec.md#int-format-family
2015/5/14 Copyright OGIS-RI 2015 26
MessagepPack format
What is MessagePack?
2015/5/14 Copyright OGIS-RI 2015 27

Más contenido relacionado

La actualidad más candente

Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いRetrieva inc.
 
Pythonとパッケージングと私
Pythonとパッケージングと私Pythonとパッケージングと私
Pythonとパッケージングと私Atsushi Odagiri
 
できる!並列・並行プログラミング
できる!並列・並行プログラミングできる!並列・並行プログラミング
できる!並列・並行プログラミングPreferred Networks
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBrendan Gregg
 
initとプロセス再起動
initとプロセス再起動initとプロセス再起動
initとプロセス再起動Takashi Takizawa
 
Visual C++で使えるC++11
Visual C++で使えるC++11Visual C++で使えるC++11
Visual C++で使えるC++11nekko1119
 
Flutter移行の苦労と、乗り越えた先に得られたもの
Flutter移行の苦労と、乗り越えた先に得られたものFlutter移行の苦労と、乗り越えた先に得られたもの
Flutter移行の苦労と、乗り越えた先に得られたものRecruit Lifestyle Co., Ltd.
 
Magnum IO GPUDirect Storage 最新情報
Magnum IO GPUDirect Storage 最新情報Magnum IO GPUDirect Storage 最新情報
Magnum IO GPUDirect Storage 最新情報NVIDIA Japan
 
GoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスGoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスToshiki Tsuboi
 
コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線Motonori Shindo
 
FD.io VPP事始め
FD.io VPP事始めFD.io VPP事始め
FD.io VPP事始めtetsusat
 
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)MicroAd, Inc.(Engineer)
 
Protocol Buffers 入門
Protocol Buffers 入門Protocol Buffers 入門
Protocol Buffers 入門Yuichi Ito
 
WASM(WebAssembly)入門 ペアリング演算やってみた
WASM(WebAssembly)入門 ペアリング演算やってみたWASM(WebAssembly)入門 ペアリング演算やってみた
WASM(WebAssembly)入門 ペアリング演算やってみたMITSUNARI Shigeo
 
いまさら聞けないselectあれこれ
いまさら聞けないselectあれこれいまさら聞けないselectあれこれ
いまさら聞けないselectあれこれlestrrat
 
Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門Fixstars Corporation
 
高位合成ツールVivado hlsのopen cv対応
高位合成ツールVivado hlsのopen cv対応高位合成ツールVivado hlsのopen cv対応
高位合成ツールVivado hlsのopen cv対応marsee101
 

La actualidad más candente (20)

Go入門
Go入門Go入門
Go入門
 
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
 
Pythonとパッケージングと私
Pythonとパッケージングと私Pythonとパッケージングと私
Pythonとパッケージングと私
 
できる!並列・並行プログラミング
できる!並列・並行プログラミングできる!並列・並行プログラミング
できる!並列・並行プログラミング
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame Graphs
 
initとプロセス再起動
initとプロセス再起動initとプロセス再起動
initとプロセス再起動
 
Visual C++で使えるC++11
Visual C++で使えるC++11Visual C++で使えるC++11
Visual C++で使えるC++11
 
Flutter移行の苦労と、乗り越えた先に得られたもの
Flutter移行の苦労と、乗り越えた先に得られたものFlutter移行の苦労と、乗り越えた先に得られたもの
Flutter移行の苦労と、乗り越えた先に得られたもの
 
Magnum IO GPUDirect Storage 最新情報
Magnum IO GPUDirect Storage 最新情報Magnum IO GPUDirect Storage 最新情報
Magnum IO GPUDirect Storage 最新情報
 
GoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスGoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティス
 
コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線コンテナネットワーキング(CNI)最前線
コンテナネットワーキング(CNI)最前線
 
FD.io VPP事始め
FD.io VPP事始めFD.io VPP事始め
FD.io VPP事始め
 
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)
DDD&Scalaで作られたプロダクトはその後どうなったか?(Current state of products made with DDD & Scala)
 
Protocol Buffers 入門
Protocol Buffers 入門Protocol Buffers 入門
Protocol Buffers 入門
 
Glibc malloc internal
Glibc malloc internalGlibc malloc internal
Glibc malloc internal
 
VTI の中身
VTI の中身VTI の中身
VTI の中身
 
WASM(WebAssembly)入門 ペアリング演算やってみた
WASM(WebAssembly)入門 ペアリング演算やってみたWASM(WebAssembly)入門 ペアリング演算やってみた
WASM(WebAssembly)入門 ペアリング演算やってみた
 
いまさら聞けないselectあれこれ
いまさら聞けないselectあれこれいまさら聞けないselectあれこれ
いまさら聞けないselectあれこれ
 
Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門
 
高位合成ツールVivado hlsのopen cv対応
高位合成ツールVivado hlsのopen cv対応高位合成ツールVivado hlsのopen cv対応
高位合成ツールVivado hlsのopen cv対応
 

Similar a MessagePack(msgpack): Compact and Fast Serialization Library

BUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxBUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxhartrobert670
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationGlobalLogic Ukraine
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by ExampleOlve Maudal
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11Russell Childs
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxvoversbyobersby
 
Unpack mechanism of the msgpack-c
Unpack mechanism of the msgpack-cUnpack mechanism of the msgpack-c
Unpack mechanism of the msgpack-cTakatoshi Kondo
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinaloscon2007
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinaloscon2007
 
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres OpenBruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres OpenPostgresOpen
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstackThierry Gayet
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS charsbar
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Max Kleiner
 
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...apidays
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...Mr. Vengineer
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeYung-Yu Chen
 
OSA Con 2022: Streaming Data Made Easy
OSA Con 2022:  Streaming Data Made EasyOSA Con 2022:  Streaming Data Made Easy
OSA Con 2022: Streaming Data Made EasyTimothy Spann
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...Altinity Ltd
 

Similar a MessagePack(msgpack): Compact and Fast Serialization Library (20)

BUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docxBUMP implementation in Java.docxThe project is to implemen.docx
BUMP implementation in Java.docxThe project is to implemen.docx
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python Integration
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
Multithreaded sockets c++11
Multithreaded sockets c++11Multithreaded sockets c++11
Multithreaded sockets c++11
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
 
Unpack mechanism of the msgpack-c
Unpack mechanism of the msgpack-cUnpack mechanism of the msgpack-c
Unpack mechanism of the msgpack-c
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinal
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinal
 
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres OpenBruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Hooking signals and dumping the callstack
Hooking signals and dumping the callstackHooking signals and dumping the callstack
Hooking signals and dumping the callstack
 
typemap in Perl/XS
typemap in Perl/XS  typemap in Perl/XS
typemap in Perl/XS
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
 
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
 
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2  「エッジAIモダン計測制御の世界」オ...
Google Edge TPUで TensorFlow Liteを使った時に 何をやっているのかを妄想してみる 2 「エッジAIモダン計測制御の世界」オ...
 
Why learn Internals?
Why learn Internals?Why learn Internals?
Why learn Internals?
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New Rope
 
OSA Con 2022: Streaming Data Made Easy
OSA Con 2022:  Streaming Data Made EasyOSA Con 2022:  Streaming Data Made Easy
OSA Con 2022: Streaming Data Made Easy
 
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
OSA Con 2022 - Streaming Data Made Easy - Tim Spann & David Kjerrumgaard - St...
 

Más de Takatoshi Kondo

CppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLCppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLTakatoshi Kondo
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asioTakatoshi Kondo
 
Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Takatoshi Kondo
 
Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Takatoshi Kondo
 
Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Takatoshi Kondo
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithmTakatoshi Kondo
 

Más de Takatoshi Kondo (10)

CppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLCppCon2016 report and Boost.SML
CppCon2016 report and Boost.SML
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asio
 
Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Effective Modern C++ study group Item39
Effective Modern C++ study group Item39
 
Boost sg msgpack
Boost sg msgpackBoost sg msgpack
Boost sg msgpack
 
Emcpp0506
Emcpp0506Emcpp0506
Emcpp0506
 
Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02
 
Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02
 
N3495 inplace realloc
N3495 inplace reallocN3495 inplace realloc
N3495 inplace realloc
 
N3701 concept lite
N3701 concept liteN3701 concept lite
N3701 concept lite
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithm
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Último (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

MessagePack(msgpack): Compact and Fast Serialization Library

  • 1. MessagePack(msgpack): A Compact and Fast Serialization Library Takatoshi Kondo 2015/5/14 1Copyright OGIS-RI 2015
  • 2. • Taka (Takatoshi Kondo) – from TOKYO, JAPAN • OGIS-RI Co., Ltd. – Developing Pub/Sub IoT Platform using MessagePack • A committer on the msgpack-c OSS project • Other experience: Wrote the “Boost.MSM Guide” – http://redboltz.wikidot.com/boost-msm-guide 2015/5/14 Copyright OGIS-RI 2015 2 About me
  • 3. What is MessagePack? 2015/5/14 Copyright OGIS-RI 2015 3
  • 4. • Same as JSON – Portable – Contain basic type information • For example, map, array, string, boolean... – Composite data structure • Different from JSON – Smaller size – Binary coded – Can handle binary data without text encoding such as Base64 – Easier to parse, requires less computing power 2015/5/14 Copyright OGIS-RI 2015 4 MessagePack vs. JSON
  • 5. • Same as JSON – Portable – Contain basic type information • For example, map, array, string, boolean... – Composite data structure • Different from JSON – Smaller size – Binary coded – Can handle binary data without text encoding such as Base64 – Easier to parse, requires less computing power 2015/5/14 Copyright OGIS-RI 2015 5 MessagePack vs. JSON msgpack::object nil boolean u64 i64 f64 str bin ext array map * * double, float object_kv key val
  • 6. MessagePack/Boost.Serialization 2015/5/14 6Copyright OGIS-RI 2015 • The goals of the msgpack and the Boost.Serialization are different. – msgpack: Interexchange the data with different programming languages. – Boost.Serialization: Serialize every data and relations. e.g.) shared_ptr • msgpack can be used as a portable binary archive of the Boost.Serialization. – https://github.com/redboltz/rui/tree/support_boost_1_57_0 • Forked from Norihisa Fujita’s implementation C++ msgpack ruby python shared_ptr shared_ptr shared_ptr 42 42 Boost.Serialization format
  • 7. Supported Programming Languages 2015/5/14 Copyright OGIS-RI 2015 7
  • 8. Pack/Unpack 2015/5/14 8 #include <tuple> #include <string> #include <sstream> #include <msgpack.hpp> int main() { auto t1 = std::make_tuple("hello", true, 42, 12.3); std::stringstream ss; msgpack::pack(ss, t1); msgpack::unpacked unpacked = msgpack::unpack(ss.str().data(), ss.str().size()); msgpack::object obj = unpacked.get(); auto t2 = obj.as<std::tuple<std::string, bool, int, double>>(); assert(t1 == t2); } You can use any types that have the member function write(const char*, std::size_t); Copyright OGIS-RI 2015 packing unpacking convering
  • 9. Stream Deserialization 2015/5/14 9 class unpacker { public: // Constructor is omitted in this presentation void reserve_buffer(std::size_t size); char* buffer(); void buffer_consumed(std::size_t size); bool next(unpacked& result); }; Copyright OGIS-RI 2015
  • 10. Stream Deserialization 2015/5/14 10Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } }
  • 11. Stream Deserialization 2015/5/14 11Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } } The size may decided by receive performance, transmit layer's protocol and so on.
  • 12. Stream Deserialization 2015/5/14 12Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } } The size may decided by receive performance, transmit layer's protocol and so on. unp has at least try_read_size buffer on this point.
  • 13. Stream Deserialization 2015/5/14 13Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } } The size may decided by receive performance, transmit layer's protocol and so on. unp has at least try_read_size buffer on this point. input is a kind of I/O library object. read message to msgpack::unpacker's internal buffer directly.
  • 14. Stream Deserialization 2015/5/14 14Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } } The size may decided by receive performance, transmit layer's protocol and so on. unp has at least try_read_size buffer on this point. input is a kind of I/O library object. read message to msgpack::unpacker's internal buffer directly. notify msgpack::unpacker actual consumed size.
  • 15. Stream Deserialization 2015/5/14 15Copyright OGIS-RI 2015 std::size_t const try_read_size = 100; msgpack::unpacker unp; while (/* block until input becomes readable */) { unp.reserve_buffer(try_read_size); std::size_t actual_read_size = input.readsome( unp.buffer(), try_read_size); unp.buffer_consumed(actual_read_size); msgpack::unpacked result; // MessagePack data loop while(unp.next(result)) { msgpack::object obj(result.get()); } } The size may decided by receive performance, transmit layer's protocol and so on. unp has at least try_read_size buffer on this point. input is a kind of I/O library object. read message to msgpack::unpacker's internal buffer directly. notify msgpack::unpacker actual consumed size. Use obj. convert to C++ types All complete msgpack message is processed at this point, then continue to read addtional message.
  • 16. Zero-Copy Deserialization 2015/5/14 16Copyright OGIS-RI 2015 unpacker buffer int string bin header payload header payload array client memory msgpack memory
  • 17. Zero copy deserialization 2015/5/14 17Copyright OGIS-RI 2015 zone chunk_list finalizer_array object (array) object (int) object (string) object (bin) via.array.ptr chunk unpacker buffer int string bin header payload header payload via.str.ptr via.bin.ptr array (msgpack format) client memory msgpack memory managed using reference counter unpacked copy or reference is selectable
  • 18. Zero copy deserialization 2015/5/14 18Copyright OGIS-RI 2015 zone chunk_list finalizer_array object (array) object (int) object (string) object (bin) via.array.ptr chunk unpacker buffer int string bin header payload header payload via.str.ptr via.bin.ptr array (msgpack format) client memory msgpack memory managed using reference counter unpacked convert Convert to any types that adapts MessagePack std::tuple<int, boost::string_ref, std::vector<char>> copyref copy or reference is selectable
  • 19. MessagePack Adaptors 2015/5/14 19Copyright OGIS-RI 2015 https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor C++ type msgpack::object type bool bool char* str std::deque array char positive/negative integer signed ints *1 positive/negative integer unsigned ints *2 positive integer std::list array std::map array std::pair array std::set array std::string str std::vector array std::vector<char> bin *1 signed ints signed char, signed short, signed int, signed long, signed long long *2 unsigned ints unsigned char, unsigned short, unsigned int, signed long, signed long long C++11 type msgpack:: object type std::array array std::array<char> bin std::forward_list array std::tuple array std::array array std::unordered_map array std::unordered_set array boost type msgpack:: object type boost::optional<T> T boost::string_ref str
  • 20. MessagePack Adaptors 2015/5/14 20Copyright OGIS-RI 2015 https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor #include <msgpack.hpp> struct your_class : base1, base2 { int a; std::string b; // You can choose any order. // It is represented to the msgpack array elements order. MSGPACK_DEFINE(a, b, MSGPACK_BASE(base1), MSGPACK_BASE(base2)); };
  • 21. • If you have questions, feel free to contact me :) • Takatoshi Kondo – redboltz@gmail.com – twitter: redboltz • Resources – MessagePack • http://msgpack.org/ – msgpack-c • https://github.com/msgpack/msgpack-c – msgpack-c Documents • https://github.com/msgpack/msgpack-c/wiki – msgpack-c stream unpack algorithm • A little old but concept is the same • http://www.slideshare.net/taka111/msgpackc 2015/5/14 Copyright OGIS-RI 2015 21 Thank you
  • 23. Format name first byte (in binary) first byte (in hex) positive fixint 0xxxxxxx 0x00 - 0x7f fixmap 1000xxxx 0x80 - 0x8f fixarray 1001xxxx 0x90 - 0x9f fixstr 101xxxxx 0xa0 - 0xbf nil 11000000 0xc0 (never used) 11000001 0xc1 false 11000010 0xc2 true 11000011 0xc3 bin 8 11000100 0xc4 bin 16 11000101 0xc5 bin 32 11000110 0xc6 ext 8 11000111 0xc7 ext 16 11001000 0xc8 ext 32 11001001 0xc9 float 32 11001010 0xca float 64 11001011 0xcb uint 8 11001100 0xcc uint 16 11001101 0xcd uint 32 11001110 0xce uint 64 11001111 0xcf2015/5/14 Copyright OGIS-RI 2015 23 MessagePack Formats https://github.com/msgpack/msgpack/blob/master/spec.md Format name first byte (in binary) first byte (in hex) int 8 11010000 0xd0 int 16 11010001 0xd1 int 32 11010010 0xd2 int 64 11010011 0xd3 fixext 1 11010100 0xd4 fixext 2 11010101 0xd5 fixext 4 11010110 0xd6 fixext 8 11010111 0xd7 fixext 16 11011000 0xd8 str 8 11011001 0xd9 str 16 11011010 0xda str 32 11011011 0xdb array 16 11011100 0xdc array 32 11011101 0xdd map 16 11011110 0xde map 32 11011111 0xdf negative fixint 111xxxxx 0xe0 - 0xff
  • 24. Format name first byte (in binary) first byte (in hex) positive fixint 0xxxxxxx 0x00 - 0x7f fixmap 1000xxxx 0x80 - 0x8f fixarray 1001xxxx 0x90 - 0x9f fixstr 101xxxxx 0xa0 - 0xbf nil 11000000 0xc0 (never used) 11000001 0xc1 false 11000010 0xc2 true 11000011 0xc3 bin 8 11000100 0xc4 bin 16 11000101 0xc5 bin 32 11000110 0xc6 2015/5/14 Copyright OGIS-RI 2015 24 MessagePack Formats https://github.com/msgpack/msgpack/blob/master/spec.md
  • 25. 2015/5/14 Copyright OGIS-RI 2015 25 MessagePack Format https://github.com/msgpack/msgpack/blob/master/spec.md#int-format-family
  • 26. 2015/5/14 Copyright OGIS-RI 2015 26 MessagepPack format
  • 27. What is MessagePack? 2015/5/14 Copyright OGIS-RI 2015 27