[MCOL-4801] Replace Row methods getStringLength() and getStringPointer() to getConstString() Created: 2021-07-06  Updated: 2021-07-22  Resolved: 2021-07-22

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

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

Issue Links:
Blocks
blocks MCOL-4691 Major Regression: Selects with aggreg... Closed

 Description   

These two methods:

inline const uint8_t* Row::getStringPointer(uint32_t colIndex) const
{
    if (inStringTable(colIndex))
        return strings->getPointer(*((uint64_t*) &data[offsets[colIndex]]));
 
    return &data[offsets[colIndex]];
}

inline uint32_t Row::getStringLength(uint32_t colIndex) const
{
    if (inStringTable(colIndex))
        return strings->getStringLength(*((uint64_t*) &data[offsets[colIndex]]));
 
    return strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex));
}

test exactly the same condition isStringTable(colIndex). In 99% cases these two methods are used at the same time. Therefore, the condition is tested two times.

Also, under terms of MCOL-4691 we'll introduce a new VARCHAR in-memory format (length followed by the actual data) to avoid strnlen() calls. This will make this duplicate condition more complex.

In order to avoid duplicate code and double condition evaluation, let's do the following:

  • Remove the above two methods
  • Change getConstString() as follows:
    inline utils::ConstString Row::getConstString(uint32_t colIndex) const { return inStringTable(colIndex) ? strings->getConstString(*((uint64_t*) &data[offsets[colIndex]])) : getShortConstString(colIndex); }
  • Change all the affected code to use getConstString() instead of the removed methods

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