1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@ -16,10 +16,10 @@
MA 02110-1301, USA. */
/****************************************************************************
* $Id: func_rand.cpp 3495 2013-01-21 14:09:51Z rdempsey $
*
*
****************************************************************************/
* $Id: func_rand.cpp 3495 2013-01-21 14:09:51Z rdempsey $
*
*
****************************************************************************/
#include <cstdlib>
#include <string>
@ -35,7 +35,6 @@ using namespace execplan;
#include "dataconvert.h"
namespace funcexp
{
uint64_t maxValue = 0x3FFFFFFFL;
@ -45,61 +44,58 @@ uint64_t maxValue = 0x3FFFFFFFL;
*/
double Func_rand::getRand()
{
uint64_t fSeed1_save = fSeed1;
fSeed1 = (fSeed1 * 3 + fSeed2) % maxValue;
uint64_t fSeed1_save = fSeed1;
fSeed1 = (fSeed1 * 3 + fSeed2) % maxValue;
// prevent the seed to repeat itself. e.g. seed1 = 1073741790; seed2 = 66;
if (fSeed1_save == fSeed1)
fSeed1 += 23;
// prevent the seed to repeat itself. e.g. seed1 = 1073741790; seed2 = 66;
if (fSeed1_save == fSeed1)
fSeed1 += 23;
fSeed2 = (fSeed1 + fSeed2 + 33) % maxValue;
fSeed2 = (fSeed1 + fSeed2 + 33) % maxValue;
return (((double) fSeed1) / (double)maxValue);
return (((double)fSeed1) / (double)maxValue);
}
CalpontSystemCatalog::ColType Func_rand::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
CalpontSystemCatalog::ColType Func_rand::operationType(FunctionParm& fp,
CalpontSystemCatalog::ColType& resultType)
{
return resultType;
return resultType;
}
double Func_rand::getDoubleVal(rowgroup::Row& row,
FunctionParm& parm,
bool& isNull,
double Func_rand::getDoubleVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
execplan::CalpontSystemCatalog::ColType& op_ct)
{
// NOTE: this function needs to use 32bit ints otherwise it will break for negative values
uint32_t seedParm = 0;
// NOTE: this function needs to use 32bit ints otherwise it will break for negative values
uint32_t seedParm = 0;
// rand with parameter. if the parm is constanct, then a column is attached for fetching
if (parm.size() == 1 || parm.size() == 2)
// rand with parameter. if the parm is constanct, then a column is attached for fetching
if (parm.size() == 1 || parm.size() == 2)
{
execplan::ConstantColumn* cc = dynamic_cast<execplan::ConstantColumn*>(parm[0].get()->data());
if (!fSeedSet || !cc)
{
execplan::ConstantColumn* cc = dynamic_cast<execplan::ConstantColumn*>(parm[0].get()->data());
if (!fSeedSet || !cc)
{
/* Copied from item_func.cpp */
seedParm = parm[0]->data()->getIntVal(row, isNull);
fSeed1 = (uint32_t)(seedParm * 0x10001L + 55555555L);
fSeed2 = (uint32_t)(seedParm * 0x10000001L);
fSeedSet = true;
}
/* Copied from item_func.cpp */
seedParm = parm[0]->data()->getIntVal(row, isNull);
fSeed1 = (uint32_t)(seedParm * 0x10001L + 55555555L);
fSeed2 = (uint32_t)(seedParm * 0x10000001L);
fSeedSet = true;
}
// rand without parameter. thd->rand are passed in. The 3rd is a simple column for fetching
else
}
// rand without parameter. thd->rand are passed in. The 3rd is a simple column for fetching
else
{
idbassert(parm.size() == 3);
if (fSeedSet)
{
idbassert(parm.size() == 3);
if (fSeedSet)
{
fSeed1 = parm[0]->data()->getIntVal(row, isNull);
fSeed2 = parm[1]->data()->getIntVal(row, isNull);
fSeedSet = true;
}
fSeed1 = parm[0]->data()->getIntVal(row, isNull);
fSeed2 = parm[1]->data()->getIntVal(row, isNull);
fSeedSet = true;
}
}
return getRand();
return getRand();
}
} // namespace funcexp
} // namespace funcexp
// vim:ts=4 sw=4: