You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Like a plain string, a varbinary object stores arbitrary data. Unlike
a plain string, it's encoded as a binary blob by the built-in encoders
that support the binary type (MsgPack, YAML). (Actually, encoding binary
blobs with the proper type is the main goal of the new type.)
The built-in decoders now decode binary data fields (fields with the
'binary' tag in YAML; the MP_BIN type in MsgPack) to a varbinary
object by default:
This also implies that the data stored in the database under the
'varbinary' field type is now returned to Lua not as a plain string,
but as a varbinary object. It's possible to revert to the old behavior
by toggling the new compat option binary_data_decoding because this
change may break backward compatibility:
There are no string manipulation methods, like string.sub or string.match. If you need to match a substring in a varbinary
object, you have to convert it to a string first.
Related issue: #1542
Related doc issue: #4237
Product: Tarantool
Since: 3.0.0-alpha1
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/ varbinary
https://www.tarantool.io/en/doc/latest/reference/reference_lua/compat/ binary_data_decoding
https://www.tarantool.io/en/doc/latest/concepts/data_model/value_store/#data-types
https://www.tarantool.io/en/doc/latest/how-to/app/cookbook/#ffi-varbinary-insert-lua
https://www.tarantool.io/en/doc/latest/concepts/data_model/value_store/#bin
SME: @ locker
Definition of done
varbinary
modulebinary_data_decoding
)Details
The new module
varbinary
was introduced. The module implements thefollowing functions:
varbinary.new
- constructs a varbinary object from a plain stringor cdata pointer and size (to be used with the
buffer
module).varbinary.is
- returns true if the argument is a varbinary object.Like a plain string, a varbinary object stores arbitrary data. Unlike
a plain string, it's encoded as a binary blob by the built-in encoders
that support the binary type (MsgPack, YAML). (Actually, encoding binary
blobs with the proper type is the main goal of the new type.)
Note, the JSON format doesn't support the binary type so a varbinary
object is still encoded as a plain string:
The built-in decoders now decode binary data fields (fields with the
'binary' tag in YAML; the
MP_BIN
type in MsgPack) to a varbinaryobject by default:
This also implies that the data stored in the database under the
'varbinary' field type is now returned to Lua not as a plain string,
but as a varbinary object. It's possible to revert to the old behavior
by toggling the new compat option
binary_data_decoding
because thischange may break backward compatibility:
Please create a documentation page for the new compat option:
https://tarantool.io/compat/binary_data_decoding
A varbinary object implements the following meta-methods:
__len
- returns the length of the binary data, in bytes.__tostring
- returns the data in a plain string.__eq
- returns true if the varbinary object containsthe same data as another varbinary object or a string.
There are no string manipulation methods, like
string.sub
orstring.match
. If you need to match a substring in a varbinaryobject, you have to convert it to a string first.
For more details, see the design document.
Requested by @locker in tarantool/tarantool@ba749e8.
The text was updated successfully, but these errors were encountered: