tarantool / tarantool/doc

[2pt] Add example about working with varbinary fields

Open
#1,542 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

add details example server
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the data model documentation at the linked root document and review its Indexes section alongside the provided Tarantool console example. Document how to save and load varbinary fields, including the example's encoding and decoding flow, and clarify relevant binary-index limitations or patterns if they fit the scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.