Decoding binary objects | Tarantool
Документация на русском языке
поддерживается сообществом

Decoding binary objects

Option: binary_data_decoding

Starting from version 3.0, Tarantool has the varbinary module for handling binary objects of arbitrary lengths. The binary_data_decoding compat option allows to define the format in which varbinary field values are returned for handling in Lua: plain strings or varbinary objects.

New behavior: varbinary field values are returned as varbinary objects.

tarantool> compat.binary_data_decoding = 'new'
---
...

tarantool> varbinary.is(msgpack.decode('\xC4\x02\xFF\xFE'))
---
- true
...

Old behavior: varbinary field values are returned as plain strings.

tarantool> compat.binary_data_decoding = 'old'
---
...

tarantool> varbinary.is(msgpack.decode('\xC4\x02\xFF\xFE'))
---
- false
...

tarantool> varbinary.is(yaml.decode('!!binary //4='))
---
- false
...

At this point, no incompatible modules are known.

String manipulation methods, such as string.sub() or string.match() are not defined for varbinary objects. Thus, if you use such methods on results of binary data decoding from MsgPack or YAML, convert them to strings explicitly using the tostring() method.

Нашли ответ на свой вопрос?
Обратная связь