You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
Renamed datatypes/decimal.* into csdecimal to avoid collision with MDB.
This commit is contained in:
@ -200,12 +200,11 @@ ENDIF()
|
|||||||
|
|
||||||
|
|
||||||
SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed")
|
SET (ENGINE_LDFLAGS "-Wl,--no-as-needed -Wl,--add-needed")
|
||||||
SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt libmysql_client)
|
SET (ENGINE_COMMON_LIBS messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt libmysql_client datatypes)
|
||||||
SET (ENGINE_OAM_LIBS oamcpp alarmmanager)
|
SET (ENGINE_OAM_LIBS oamcpp alarmmanager)
|
||||||
SET (ENGINE_BRM_LIBS brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS})
|
SET (ENGINE_BRM_LIBS brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS})
|
||||||
SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk regr dataconvert common compress querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
|
SET (ENGINE_EXEC_LIBS joblist execplan windowfunction joiner rowgroup funcexp udfsdk regr dataconvert common compress querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
|
||||||
SET (ENGINE_WRITE_LIBS ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS})
|
SET (ENGINE_WRITE_LIBS ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS})
|
||||||
SET (ENGINE_DATATYPES_LIBS datatypes)
|
|
||||||
|
|
||||||
SET (ENGINE_COMMON_LDFLAGS "")
|
SET (ENGINE_COMMON_LDFLAGS "")
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
include_directories( ${ENGINE_COMMON_INCLUDES} )
|
include_directories( ${ENGINE_COMMON_INCLUDES} )
|
||||||
set(datatypes_LIB_SRCS
|
set(datatypes_LIB_SRCS
|
||||||
decimal.cpp)
|
csdecimal.cpp)
|
||||||
|
|
||||||
add_library(datatypes SHARED ${datatypes_LIB_SRCS})
|
add_library(datatypes SHARED ${datatypes_LIB_SRCS})
|
||||||
|
|
||||||
|
30
datatypes/csdecimal.cpp
Normal file
30
datatypes/csdecimal.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* 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. */
|
||||||
|
|
||||||
|
#include "csdecimal.h"
|
||||||
|
|
||||||
|
const datatypes::Decimal someDecimal;
|
||||||
|
|
||||||
|
namespace datatypes
|
||||||
|
{
|
||||||
|
|
||||||
|
int Decimal::compare(const execplan::IDB_Decimal& l, const execplan::IDB_Decimal& r)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end of namespace
|
@ -18,14 +18,21 @@
|
|||||||
#ifndef H_DECIMALDATATYPE
|
#ifndef H_DECIMALDATATYPE
|
||||||
#define H_DECIMALDATATYPE
|
#define H_DECIMALDATATYPE
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace execplan
|
||||||
|
{
|
||||||
|
struct IDB_Decimal;
|
||||||
|
}
|
||||||
|
|
||||||
namespace datatypes
|
namespace datatypes
|
||||||
{
|
{
|
||||||
|
|
||||||
class Decimal
|
class Decimal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Decimal() { };
|
Decimal() { };
|
||||||
~Decimal() { };
|
~Decimal() { };
|
||||||
|
static int compare(const execplan::IDB_Decimal& l, const execplan::IDB_Decimal& r);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end of namespace
|
} //end of namespace
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_UTILS_UDFSDK_INCLUDE} )
|
include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_UTILS_UDFSDK_INCLUDE} ${ENGINE_DATATYPES_INCLUDE})
|
||||||
|
|
||||||
|
|
||||||
########### next target ###############
|
########### next target ###############
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "calpontsystemcatalog.h"
|
#include "calpontsystemcatalog.h"
|
||||||
#include "exceptclasses.h"
|
#include "exceptclasses.h"
|
||||||
#include "dataconvert.h"
|
#include "dataconvert.h"
|
||||||
|
#include "columnwidth.h"
|
||||||
|
#include "csdecimal.h"
|
||||||
|
|
||||||
using int128_t = __int128;
|
using int128_t = __int128;
|
||||||
|
|
||||||
@ -116,45 +118,105 @@ struct IDB_Decimal
|
|||||||
|
|
||||||
bool operator==(const IDB_Decimal& rhs) const
|
bool operator==(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value == rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value == rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) == 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) == 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value == rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator>(const IDB_Decimal& rhs) const
|
bool operator>(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value > rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value > rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) > 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) > 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value > rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator<(const IDB_Decimal& rhs) const
|
bool operator<(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value < rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value < rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) < 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) < 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value < rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) < 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator>=(const IDB_Decimal& rhs) const
|
bool operator>=(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value >= rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value >= rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) >= 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) >= 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value >= rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) >= 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator<=(const IDB_Decimal& rhs) const
|
bool operator<=(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value <= rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value <= rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) <= 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) <= 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value <= rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) <= 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator!=(const IDB_Decimal& rhs) const
|
bool operator!=(const IDB_Decimal& rhs) const
|
||||||
{
|
{
|
||||||
if (scale == rhs.scale)
|
if (utils::widthByPrecision(precision) == 16)
|
||||||
return value != rhs.value;
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return s128Value != rhs.s128Value;
|
||||||
|
else
|
||||||
|
return (datatypes::Decimal::compare(*this, rhs) != 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return (decimalComp(rhs) != 0);
|
{
|
||||||
|
if (scale == rhs.scale)
|
||||||
|
return value != rhs.value;
|
||||||
|
else
|
||||||
|
return (decimalComp(rhs) != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int128_t s128Value;
|
int128_t s128Value;
|
||||||
|
@ -143,10 +143,10 @@ namespace cal_impl_if
|
|||||||
extern bool nonConstFunc(Item_func* ifp);
|
extern bool nonConstFunc(Item_func* ifp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using int128_t = __int128;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using int128_t = __int128;
|
|
||||||
using uint128_t = unsigned __int128;
|
|
||||||
// Calpont vtable non-support error message
|
// Calpont vtable non-support error message
|
||||||
const string infinidb_autoswitch_warning = "The query includes syntax that is not supported by MariaDB Columnstore distributed mode. The execution was switched to standard mode with downgraded performance.";
|
const string infinidb_autoswitch_warning = "The query includes syntax that is not supported by MariaDB Columnstore distributed mode. The execution was switched to standard mode with downgraded performance.";
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
#include "decimal.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
const datatypes::Decimal someDecimal;
|
TEST(DataConvertTest, Strtoll128)
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(true);
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
#ifndef UTILS_COLWIDTH_H
|
#ifndef UTILS_COLWIDTH_H
|
||||||
#define UTILS_COLWIDTH_H
|
#define UTILS_COLWIDTH_H
|
||||||
|
|
||||||
|
#include "branchpred.h"
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
@ -34,10 +35,12 @@ namespace utils
|
|||||||
return width <= MAXLEGACYWIDTH;
|
return width <= MAXLEGACYWIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WIP MCOL-641 Replace with template
|
|
||||||
/** @brief Map a DECIMAL precision to data width in bytes */
|
/** @brief Map a DECIMAL precision to data width in bytes */
|
||||||
inline uint8_t widthByPrecision(unsigned p)
|
inline uint8_t widthByPrecision(unsigned p)
|
||||||
{
|
{
|
||||||
|
if (LIKELY(p > 18 && p < 39))
|
||||||
|
return 16;
|
||||||
|
|
||||||
switch (p)
|
switch (p)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -70,6 +73,7 @@ namespace utils
|
|||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t precisionByWidth(unsigned w)
|
inline uint8_t precisionByWidth(unsigned w)
|
||||||
{
|
{
|
||||||
switch(w)
|
switch(w)
|
||||||
|
Reference in New Issue
Block a user