[PATCH v3 0/6] Decimal indices

Serge Petrenko sergepetrenko at tarantool.org
Tue Aug 20 20:09:58 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 sixth patch 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 v3:
  - minor fixes as per review by Kostja
    and Vladimir.
  - Remove patches introducing the new
    enum mp_field_type (patches 4 & 5 previously)
  - Basically return to v1 with some additional
    review fixes and better checks for MP_EXT
    subtypes in patch 6

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 (6):
  lua: fix decimal comparison with nil
  decimal: fix encoding numbers with positive exponent.
  lua/pickle: fix a typo
  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                  |  45 +-
 src/box/field_def.h                  |  23 +-
 src/box/key_def.h                    |   3 +-
 src/box/tuple_compare.cc             | 198 +++++++-
 src/box/tuple_format.c               |   3 +-
 src/lib/core/CMakeLists.txt          |   1 +
 src/lib/core/decimal.c               |  99 +++-
 src/lib/core/decimal.h               |  27 +
 src/lib/core/mp_decimal.c            |  72 +++
 src/lib/core/mp_decimal.h            |  70 +++
 src/lib/core/mp_extension_types.h    |  47 ++
 src/lib/core/mpstream.c              |  11 +
 src/lib/core/mpstream.h              |   4 +
 src/lua/decimal.c                    |  23 +-
 src/lua/decimal.h                    |   7 +
 src/lua/msgpack.c                    |  53 +-
 src/lua/msgpackffi.lua               |  38 ++
 src/lua/pickle.c                     |   4 +-
 src/lua/utils.c                      |  16 +-
 src/lua/utils.h                      |   8 +-
 test/app-tap/lua/serializer_test.lua |  14 +
 test/app-tap/msgpackffi.test.lua     |   3 +-
 test/app/decimal.result              | 172 ++++---
 test/app/decimal.test.lua            |   8 +
 test/app/msgpack.result              |  41 ++
 test/app/msgpack.test.lua            |  15 +
 test/app/pack.result                 |   8 +
 test/app/pack.test.lua               |   2 +
 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/engine/iterator.result          | 730 +++++++++++++++++++++++++++
 test/engine/iterator.test.lua        |  22 +
 test/unit/decimal.c                  | 139 ++++-
 test/unit/decimal.result             | 283 ++++++++++-
 third_party/decNumber                |   2 +-
 third_party/lua-cjson/lua_cjson.c    |  12 +-
 third_party/lua-yaml/lyaml.cc        |  10 +-
 42 files changed, 2764 insertions(+), 146 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_extension_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