1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-641 This commit adds support for SIGNED and ZEROFILL keywords in

CREATE TABLE. ZEROFILL is dummy though.

There is a new file with column width utilities.

Array access was replaced by a variable that is calculated only once in
TupleJoiner::updateCPData.
This commit is contained in:
drrtuy
2020-02-18 11:55:51 +03:00
committed by Roman Nozdrin
parent 93170c3b31
commit 2eb5af1d24
6 changed files with 115 additions and 58 deletions

View File

@ -0,0 +1,74 @@
/* Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef UTILS_COLWIDTH_H
#define UTILS_COLWIDTH_H
#define MAXLEGACYWIDTH 8
namespace utils
{
inline bool isWide(uint8_t width)
{
return width > MAXLEGACYWIDTH;
}
inline bool isNarrow(uint8_t width)
{
return width <= MAXLEGACYWIDTH;
}
// WIP MCOL-641 Replace with template
/** @brief Map a DECIMAL precision to data width in bytes */
inline uint8_t widthByPrecision(unsigned p)
{
switch (p)
{
case 1:
case 2:
return 1;
case 3:
case 4:
return 2;
case 5:
case 6:
case 7:
case 8:
case 9:
return 4;
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
return 8;
default:
return 16;
}
}
}
#endif // UTILS_COLWIDTH_H

View File

@ -1070,15 +1070,15 @@ void TupleJoiner::updateCPData(const Row& r)
for (col = 0; col < smallKeyColumns.size(); col++)
{
// if (r.getColumnWidth(smallKeyColumns[col]) > 8)
if (r.isLongString(smallKeyColumns[col]))
auto colIdx = smallKeyColumns[col];
if (r.isLongString(colIdx))
continue;
int64_t& min = cpValues[col][0], &max = cpValues[col][1];
auto& min = cpValues[col][0], &max = cpValues[col][1];
if (r.isCharType(smallKeyColumns[col]))
if (r.isCharType(colIdx))
{
int64_t val = r.getIntField(smallKeyColumns[col]);
int64_t val = r.getIntField(colIdx);
if (order_swap(val) < order_swap(min) ||
min == numeric_limits<int64_t>::max())
@ -1092,10 +1092,10 @@ void TupleJoiner::updateCPData(const Row& r)
max = val;
}
}
else if (r.isUnsigned(smallKeyColumns[col]))
else if (r.isUnsigned(colIdx))
{
uint64_t uval;
if (r.getColType(smallKeyColumns[col]) == CalpontSystemCatalog::LONGDOUBLE)
if (r.getColType(colIdx) == CalpontSystemCatalog::LONGDOUBLE)
{
double dval = (double)roundl(r.getLongDoubleField(smallKeyColumns[col]));
switch (largeRG.getColType(largeKeyColumns[col]))
@ -1116,7 +1116,7 @@ void TupleJoiner::updateCPData(const Row& r)
}
else
{
uval = r.getUintField(smallKeyColumns[col]);
uval = r.getUintField(colIdx);
}
if (uval > static_cast<uint64_t>(max))
@ -1128,9 +1128,9 @@ void TupleJoiner::updateCPData(const Row& r)
else
{
int64_t val;
if (r.getColType(smallKeyColumns[col]) == CalpontSystemCatalog::LONGDOUBLE)
if (r.getColType(colIdx) == CalpontSystemCatalog::LONGDOUBLE)
{
double dval = (double)roundl(r.getLongDoubleField(smallKeyColumns[col]));
double dval = (double)roundl(r.getLongDoubleField(colIdx));
switch (largeRG.getColType(largeKeyColumns[col]))
{
case CalpontSystemCatalog::DOUBLE:
@ -1147,9 +1147,16 @@ void TupleJoiner::updateCPData(const Row& r)
}
}
}
else if (utils::isWide(r.getColumnWidth(colIdx))
&& (r.getColType(colIdx) == CalpontSystemCatalog::DECIMAL
|| r.getColType(colIdx) == CalpontSystemCatalog::UDECIMAL))
{
// WIP MCOL-641
}
else
{
val = r.getIntField(smallKeyColumns[col]);
val = r.getIntField(colIdx);
}
if (val > max)

View File

@ -39,6 +39,7 @@
#include "stlpoolallocator.h"
#include "hasher.h"
#include "threadpool.h"
#include "columnwidth.h"
namespace joiner
{