Skip to content

box: introduce fixed-size numeric field types#9592

Merged
locker merged 3 commits intotarantool:masterfrom
Gumix:iverbin/gh-9548-introduce-fixed-size-numeric-types
Jan 16, 2024
Merged

box: introduce fixed-size numeric field types#9592
locker merged 3 commits intotarantool:masterfrom
Gumix:iverbin/gh-9548-introduce-fixed-size-numeric-types

Conversation

@Gumix
Copy link
Contributor

@Gumix Gumix commented Jan 12, 2024

Closes #9548

Gumix added 2 commits January 10, 2024 19:50
commit 51af059 ("box: compare and hash msgpack value of double key
field as double") changed `field_mp_type[FIELD_TYPE_DOUBLE]', but the
corresponding column of `field_type_compatibility[]' wasn't updated.

Now a field of type DOUBLE can store MP_UINT and MP_INT, i.e. it can
store any value from fields of type UNSIGNED, NUMBER, INTEGER.
In fact, FIELD_TYPE_DOUBLE is now an alias for FIELD_TYPE_NUMBER.

It's hard to create a test, because e.g. during CheckSpaceFormat even if
field_type1_contains_type2() erroneously returns false, then each tuple is
correctly validated anyway. So this patch actually fixes performance issue.

NO_TEST=see above
NO_DOC=minor fix
NO_CHANGELOG=minor fix
All the information needed by this function is stored in `field_mp_type[]'
and `field_ext_type[]'. Get rid of redundant `field_type_compatibility[]',
which is hard to extend and which can introduce additional bugs.

NO_DOC=refactoring
NO_CHANGELOG=refactoring
@Gumix Gumix requested review from a team as code owners January 12, 2024 16:54
@coveralls
Copy link

coveralls commented Jan 12, 2024

Coverage Status

coverage: 86.933% (+0.05%) from 86.886%
when pulling a9dfd30 on Gumix:iverbin/gh-9548-introduce-fixed-size-numeric-types
into 8762732
on tarantool:master
.

@Gumix Gumix requested a review from locker January 12, 2024 17:14
@locker locker assigned Gumix and unassigned locker Jan 15, 2024
@Gumix Gumix requested a review from locker January 16, 2024 14:21
@Gumix Gumix assigned locker and unassigned Gumix Jan 16, 2024
@locker locker assigned Gumix and unassigned locker Jan 16, 2024
See the docbot request for details.

Closes #9548

@TarantoolBot document
Title: Document fixed-size numeric field types
Product: Tarantool
Since: 3.1
Root document: https://www.tarantool.io/en/doc/latest/concepts/data_model/value_store/#field-type-details

 ### Fixed-size field types

Tarantool supports the following fixed-size numeric field types:

 * `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

These types don't affect how data is stored in Tarantool's memtx or vinyl
engines but they enforce the limits when a tuple is inserted or updated.
@Gumix Gumix requested a review from locker January 16, 2024 15:56
@Gumix Gumix assigned locker and unassigned Gumix Jan 16, 2024
@locker locker added the full-ci Enables all tests for a pull request label Jan 16, 2024
@locker locker merged commit 2e0f9a3 into tarantool:master Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce fixed-size numeric types

5 participants