[PATCH v2 0/8] Decimal indices

Serge Petrenko sergepetrenko at tarantool.org
Thu Aug 8 14:55:51 MSK 2019


https://github.com/tarantool/tarantool/issues/4333
https://github.com/tarantool/tarantool/tree/sp/gh-4333-decimal-index

This patchset adds the ability to store decimals in spaces and to build indices
over them. As a prerequisite, the ability to encode and decode decimals as
msgpack is also added to both C and Lua modules.

First three patches contain various bugfixes found during the work on the issue.

The fourth and fifth patches are preparational, they introduce a new enum -
mp_field_type, with values MP_FIELD_* corresponding directly to Messagepack
types - MP_INT, MP_STR and so on. MP_FIELD_* is intended to be used with various
extension types we plan on adding: Instead of having MP_INT, ... MP_STR  and so
on together with MP_EXT and its various subtypes, we will have a single enum
with all tarantool-supported types, including decimal and everything we might
come up with later.
This allows to make all the switch cases over types plain and hide the MP_EXT
decoding logic into a single function - msgpack_to_field_type().

The sixth patch is the first one to make use of the preparatory work done up to
this point. It adds the methods to encode and decode decimals as msgpack, and
expands lua msgpack and msgpackffi modules with the same abilities.
This allows to store decimal values in tuples, and in space unindexed fields.

The seventh patch adds methods to cast decimals to 64 bit integers. This
functionality is needed to calculate comparison hints from decimals in scope of
patch 8.

Patch 8 finally introduces decimal fields, adds comparators for decimal values
and defines field types appropriate for storing decimals.

Changes in v2:
  - Various minor fixes regarding a review by
    Vladimir Davydov
  - All the bugfixes are extracted into separate
    patches
  - More tests are added to cover space.format and
    index.alter with decimal fields
  - A single enum is introduced to cover both existent
    msgpack types and the ones with which we might
    come up later
  - The patches covering the ability to encode/decode
    decimals as msgpack in C and Lua are squashed.

Serge Petrenko (8):
  lua: fix decimal comparison with nil
  decimal: fix encoding numbers with positive exponent.
  lua/pickle: fix a typo
  lua: rework luaL_field types to support msgpack extensions
  box: rework field_def and tuple_compare to work with mp_field_type
    instead of mp_type
  decimal: allow to encode/decode decimals as MsgPack
  decimal: add conversions to (u)int64_t
  decimal: allow to index decimals

 extra/exports                        |   4 +
 src/box/field_def.c                  |  50 ++--
 src/box/field_def.h                  |  13 +-
 src/box/key_def.h                    |   2 +-
 src/box/lua/call.c                   |  16 +-
 src/box/lua/execute.c                |  24 +-
 src/box/lua/tuple.c                  |  12 +-
 src/box/tuple_compare.cc             | 330 ++++++++++++++++---------
 src/box/tuple_format.c               |   2 +-
 src/lib/core/CMakeLists.txt          |   1 +
 src/lib/core/decimal.c               |  67 ++++-
 src/lib/core/decimal.h               |  27 ++
 src/lib/core/mp_decimal.c            |  72 ++++++
 src/lib/core/mp_decimal.h            |  70 ++++++
 src/lib/core/mp_user_types.h         | 104 ++++++++
 src/lib/core/mpstream.c              |  11 +
 src/lib/core/mpstream.h              |   4 +
 src/lua/decimal.c                    |   8 +-
 src/lua/decimal.h                    |   7 +
 src/lua/msgpack.c                    | 111 +++++----
 src/lua/msgpack.h                    |   6 +-
 src/lua/msgpackffi.lua               |  36 +++
 src/lua/pickle.c                     |  14 +-
 src/lua/utils.c                      |  73 +++---
 src/lua/utils.h                      |   7 +-
 test/app-tap/lua/serializer_test.lua |  14 ++
 test/app-tap/msgpackffi.test.lua     |   3 +-
 test/app/decimal.result              | 154 +++++++-----
 test/app/decimal.test.lua            |   8 +
 test/app/msgpack.result              |  41 +++
 test/app/msgpack.test.lua            |  15 ++
 test/box/tuple.result                |  85 +++++++
 test/box/tuple.test.lua              |  23 ++
 test/engine/ddl.result               |  85 ++++++-
 test/engine/ddl.test.lua             |  40 ++-
 test/engine/decimal.result           | 356 +++++++++++++++++++++++++++
 test/engine/decimal.test.lua         | 104 ++++++++
 test/unit/decimal.c                  | 139 ++++++++++-
 test/unit/decimal.result             | 283 ++++++++++++++++++++-
 third_party/decNumber                |   2 +-
 third_party/lua-cjson/lua_cjson.c    |  33 +--
 third_party/lua-yaml/lyaml.cc        |  27 +-
 42 files changed, 2112 insertions(+), 371 deletions(-)
 create mode 100644 src/lib/core/mp_decimal.c
 create mode 100644 src/lib/core/mp_decimal.h
 create mode 100644 src/lib/core/mp_user_types.h
 create mode 100644 test/engine/decimal.result
 create mode 100644 test/engine/decimal.test.lua

-- 
2.20.1 (Apple Git-117)




More information about the Tarantool-patches mailing list