Skip to content

Introduce fixed-size numeric types #9548

@locker

Description

@locker

Tarantool has unsigned and integer types which can store 64-bit integer values. We don't have fixed-size integer types like uint8_t or int16_t because the MsgPack format used internally by Tarantool efficiently packs integer values, e.g. 129 would be encoded as a 2-byte sequence \xcc\x81, not as a 8-byte value.

However, sometimes it may be useful to have fixed-size numeric types. For example, one may want to store them unencoded in an array for effective scanning (like a column store). For this purpose, let's introduce the following new types to Tarantool:

  • uint8: integer in range [0 .. 255]
  • int8: integer in range [-128 .. 127]
  • uint16: integer in range [0 .. 65,535]
  • int16: integer in range [-32,768 .. 32,767]
  • uint32: integer in range [0 .. 4,294,967,295]
  • int32: integer in range [-2,147,483,648 .. 2,147,483,647]
  • uint64: integer in range [0 .. 18,446,744,073,709,551,615]
  • int64: integer in range [-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807]
  • float32: 32-bit floating point number
  • float64: 64-bit floating point number

The types shouldn't affect how data is stored in Tarantool's memtx or vinyl engines but they should enforce the limits when a tuple is inserted or updated.

Note, introduction of the new field types may require updating the SQL subsystem.

Metadata

Metadata

Assignees

Labels

featureA new functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions