Skip to content

[2pt] Add example about working with varbinary fields #1542

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

Open
akudiyar opened this issue Sep 15, 2020 · 0 comments
Open

[2pt] Add example about working with varbinary fields #1542

akudiyar opened this issue Sep 15, 2020 · 0 comments
Labels
add details [nature] More details needed, some info missing. Documentation is incomplete. example Problem with a code example. server [area] Task relates to Tarantool's server (core) functionality

Comments

@akudiyar
Copy link
Contributor

akudiyar commented Sep 15, 2020

Product: Tarantool
Audience/target: developers
Root document: https://www.tarantool.io/en/doc/latest/book/box/data_model/
SME: ?

This might lead to restructuring the Indexes section, which is a separate task.


"How to save and load binary fields" is a frequently asked question by customers. There are no mentions of the right ways of using varbinary fields in the documentation.

An example of example:

tarantool> box.schema.create_space('test')
---
- engine: memtx
  before_replace: 'function: 0x010c252e98'
  on_replace: 'function: 0x010c252e60'
  ck_constraint: []
  field_count: 0
  temporary: false
  index: []
  is_local: false
  enabled: false
  name: test
  id: 512
- created
...
tarantool> box.space.test:create_index('primary', {unique=true, parts = {1, 'unsigned'}})
---
- unique: true
  parts:
  - type: unsigned
    is_nullable: false
    fieldno: 1
  id: 0
  space_id: 512
  type: TREE
  name: primary
...
tarantool> mp = require'msgpack'
---
...

tarantool> s = '\xc4\10aaaabbbbccccdddd'
---
...

tarantool> m = mp.encode(s)
---
...

tarantool> box.space.test:insert({1, m})
---
- [1, !!binary ssQKYWFhYWJiYmJjY2NjZGRkZA==]
...

tarantool> dg = require'digest'
---
...

tarantool> dg.base64_decode(mp.decode(box.space.test:select(1)[1][2]))
---
- !!binary aaaabbbbccccdddd
...

Also more information about using indexes with binary fields, limitations and typical patterns will be nice. The example above may need some beautification.

@akudiyar akudiyar added the reference [location] Tarantool manual, Reference part label Sep 15, 2020
@patiencedaur patiencedaur added this to the Estimate [@patiencedaur] milestone Oct 28, 2021
@patiencedaur patiencedaur changed the title Add example about working with varbinary fields [2pt] Add example about working with varbinary fields Oct 28, 2021
@patiencedaur patiencedaur added add details [nature] More details needed, some info missing. Documentation is incomplete. server [area] Task relates to Tarantool's server (core) functionality and removed reference [location] Tarantool manual, Reference part labels Oct 29, 2021
@patiencedaur patiencedaur removed this from the Estimate [@patiencedaur] milestone Oct 29, 2021
@patiencedaur patiencedaur added the example Problem with a code example. label Feb 28, 2022
@TarantoolBot TarantoolBot removed the 2sp label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add details [nature] More details needed, some info missing. Documentation is incomplete. example Problem with a code example. server [area] Task relates to Tarantool's server (core) functionality
Projects
None yet
Development

No branches or pull requests

4 participants