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

@ -17,7 +17,6 @@
// $Id: wf_count.cpp 3932 2013-06-25 16:08:10Z xlou $
//#define NDEBUG
#include <iostream>
#include <cassert>
@ -49,150 +48,140 @@ using namespace joblist;
#include "wf_count.h"
namespace windowfunction
{
template<typename T>
boost::shared_ptr<WindowFunctionType> WF_count<T>::makeFunction(int id, const string& name, int ct, WindowFunctionColumn* wc)
template <typename T>
boost::shared_ptr<WindowFunctionType> WF_count<T>::makeFunction(int id, const string& name, int ct,
WindowFunctionColumn* wc)
{
boost::shared_ptr<WindowFunctionType> func;
boost::shared_ptr<WindowFunctionType> func;
switch (ct)
switch (ct)
{
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
{
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
{
func.reset(new WF_count<string>(id, name));
break;
}
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
decltype(datatypes::MAXDECIMALWIDTH) width =
wc->functionParms()[0]->resultType().colWidth;
if (width < datatypes::MAXDECIMALWIDTH)
{
func.reset(new WF_count<int64_t>(id, name));
}
else if (width == datatypes::MAXDECIMALWIDTH)
{
func.reset(new WF_count<int128_t>(id, name));
}
break;
}
default:
{
func.reset(new WF_count<int64_t>(id, name));
break;
}
func.reset(new WF_count<string>(id, name));
break;
}
return func;
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
{
decltype(datatypes::MAXDECIMALWIDTH) width = wc->functionParms()[0]->resultType().colWidth;
if (width < datatypes::MAXDECIMALWIDTH)
{
func.reset(new WF_count<int64_t>(id, name));
}
else if (width == datatypes::MAXDECIMALWIDTH)
{
func.reset(new WF_count<int128_t>(id, name));
}
break;
}
default:
{
func.reset(new WF_count<int64_t>(id, name));
break;
}
}
return func;
}
template<typename T>
template <typename T>
WindowFunctionType* WF_count<T>::clone() const
{
return new WF_count(*this);
return new WF_count(*this);
}
template<typename T>
template <typename T>
void WF_count<T>::resetData()
{
fCount = 0;
fSet.clear();
fCount = 0;
fSet.clear();
WindowFunctionType::resetData();
WindowFunctionType::resetData();
}
template<typename T>
template <typename T>
void WF_count<T>::operator()(int64_t b, int64_t e, int64_t c)
{
if ((fFrameUnit == WF__FRAME_ROWS) ||
(fPrev == -1) ||
(!fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(fPrev)))))
if ((fFrameUnit == WF__FRAME_ROWS) || (fPrev == -1) ||
(!fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(fPrev)))))
{
// for unbounded - current row special handling
if (fPrev >= b && fPrev < c)
b = c;
else if (fPrev <= e && fPrev > c)
e = c;
// for count(*), the column is optimized out, index[1] does not exist.
int64_t colIn = (fFunctionId == WF__COUNT_ASTERISK) ? 0 : fFieldIndex[1];
// constant param will have fFieldIndex[1] of -1. Get value of constant param
if (colIn == -1)
{
// for unbounded - current row special handling
if (fPrev >= b && fPrev < c)
b = c;
else if (fPrev <= e && fPrev > c)
e = c;
ConstantColumn* cc = static_cast<ConstantColumn*>(fConstantParms[0].get());
// for count(*), the column is optimized out, index[1] does not exist.
int64_t colIn = (fFunctionId == WF__COUNT_ASTERISK) ? 0 : fFieldIndex[1];
if (cc)
{
bool isNull = false;
cc->getIntVal(fRow, isNull);
// constant param will have fFieldIndex[1] of -1. Get value of constant param
if (colIn == -1)
if (!isNull)
{
ConstantColumn* cc = static_cast<ConstantColumn*>(fConstantParms[0].get());
if (cc)
{
bool isNull = false;
cc->getIntVal(fRow, isNull);
if (!isNull)
{
// constant, set fCount to row count
fCount += e - b + 1;
}
}
// constant, set fCount to row count
fCount += e - b + 1;
}
else if (fFunctionId == WF__COUNT_ASTERISK)
}
}
else if (fFunctionId == WF__COUNT_ASTERISK)
{
// count(*), set fCount to row count
fCount += e - b + 1;
}
else
{
for (int64_t i = b; i <= e; i++)
{
if (i % 1000 == 0 && fStep->cancelled())
break;
fRow.setData(getPointer(fRowData->at(i)));
if (fRow.isNullValue(colIn) == true)
continue;
if (fFunctionId != WF__COUNT_DISTINCT)
{
// count(*), set fCount to row count
fCount += e - b + 1;
fCount++;
}
else
{
for (int64_t i = b; i <= e; i++)
{
if (i % 1000 == 0 && fStep->cancelled())
break;
T valIn;
getValue(colIn, valIn);
fRow.setData(getPointer(fRowData->at(i)));
if (fSet.find(valIn) == fSet.end())
{
fCount++;
if (fRow.isNullValue(colIn) == true)
continue;
if (fFunctionId != WF__COUNT_DISTINCT)
{
fCount++;
}
else
{
T valIn;
getValue(colIn, valIn);
if (fSet.find(valIn) == fSet.end())
{
fCount++;
if (fFunctionId == WF__COUNT_DISTINCT)
fSet.insert(valIn);
}
}
}
if (fFunctionId == WF__COUNT_DISTINCT)
fSet.insert(valIn);
}
}
}
}
}
setValue(CalpontSystemCatalog::BIGINT, b, e, c, &fCount);
setValue(CalpontSystemCatalog::BIGINT, b, e, c, &fCount);
fPrev = c;
fPrev = c;
}
template boost::shared_ptr<WindowFunctionType> WF_count<int64_t>::makeFunction(int, const string&, int,
WindowFunctionColumn*);
template
boost::shared_ptr<WindowFunctionType> WF_count<int64_t>::makeFunction(int, const string&, int, WindowFunctionColumn*);
} //namespace
} // namespace windowfunction
// vim:ts=4 sw=4: