[MCOL-4531] New string-to-decimal conversion implementation Created: 2021-02-04  Updated: 2021-04-21  Resolved: 2021-03-02

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 6.1.1
Fix Version/s: 6.1.1

Type: Task Priority: Critical
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MCOL-4462 CAST(varchar_expr AS DECIMAL(M,N)) re... Closed
blocks MCOL-4500 Bit functions processing throws inter... Closed
blocks MCOL-4532 CAST(AS DECIMAL) returns a garbage fo... Closed
Relates
relates to MCOL-4464 Bitwise operations not like in MariaDB Closed
relates to MDEV-24790 CAST('0e1111111111' AS DECIMAL(38,0))... Closed

 Description   

We have at least two implementations of string-to-decimal conversion:

  • dataconvert::number_int_value(), which is used either directly or inside the wrapper SystemCatalog::TypeAttributesStd::decimal128FromString().
  • Func_cast_decimal::getDecimalVal()

These two implementations have a lot of duplicate code and have problems:

  • MCOL-4462 - This problem existed for a long time
  • MCOL-4500 - This problem was introduced by MCOL-4464
  • MCOL-4532 - Introduced by MCOL-641
  • They use a lot of std::string objects copying and padding, which is not performance friendly.

Under terms of this task we'll do the following:

  • Introduce a new implementation of a string-to-decimal conversion function which won't have the mentioned bugs
  • The new function should not do any std::string copying/padding and should only use the source string (and therefore should hopefully be faster). It should only iterate on the source string.
  • The new function should get a const char * pointer and its length instead of a '\0' terminated C-style string. This is to avoid calling string::c_ptr() which is also not performance friendly.
  • Add a new constructor:

    Decimal::Decimal(const char *str, size_t length, DataCondition & convError,
                    int8_t s, uint8_t p)
    

    which will use the new conversion function internally.

  • Replace the code in GenericToBitOperand() in func_bit.cc to the new function call
  • Replace the code in Func_cast_decimal::getDecimalVal() to thew new constructor call

Further steps

Note, after these changes, the functions dataconvert::number_int_value() and SystemCatalog::TypeAttributesStd::decimal128FromString() will still exist.

Later, under terms of a separate tasks (or even multiple tasks), we'll:

  • Replace all remaining calls for dataconvert::number_int_value() to the new functionality.
  • Replace all remaining calls for SystemCatalog::TypeAttributesStd::decimal128FromString() to the new functionality.
  • Remove dataconvert::number_int_value() and SystemCatalog::TypeAttributesStd::decimal128FromString() completely.

Generated at Thu Feb 08 02:51:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.