1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

MCOL-523 Add UDAF and UDAnF SDK

This commit is contained in:
David Hall
2017-07-26 11:53:08 -05:00
parent 630b113565
commit bc2a4e7795
75 changed files with 10250 additions and 4523 deletions

77
utils/windowfunction/wf_udaf.h Executable file
View File

@@ -0,0 +1,77 @@
/************************************************************************************
Copyright (C) 2017 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/
#ifndef UTILS_WF_UDAF_H
#define UTILS_WF_UDAF_H
#include <set>
#include "windowfunctiontype.h"
#include "mcsv1_udaf.h"
namespace windowfunction
{
// A class to control the execution of User Define Analytic Functions (UDAnF)
// as defined by a specialization of mcsv1sdk::mcsv1_UDAF
// The template parameter is currently only used to support DISTINCT, as
// as that is done via a set<T>
template<typename T>
class WF_udaf : public WindowFunctionType
{
public:
WF_udaf(int id, const std::string& name, mcsv1sdk::mcsv1Context& context) :
WindowFunctionType(id, name), fUDAFContext(context), fDistinct(false), bHasDropValue(true) {}
WF_udaf(WF_udaf& rhs);
// pure virtual in base
void operator()(int64_t b, int64_t e, int64_t c);
WindowFunctionType* clone() const;
void resetData();
void parseParms(const std::vector<execplan::SRCP>&);
virtual bool dropValues(int64_t, int64_t);
mcsv1sdk::mcsv1Context& getContext() {return fUDAFContext;}
bool getInterrupted() {return bInterrupted;}
bool getInterruptedPtr() {return &bInterrupted;}
bool getDistinct() {return fDistinct;}
protected:
void SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, int64_t e, int64_t c);
mcsv1sdk::mcsv1Context fUDAFContext; // The UDAF context
bool bInterrupted; // Shared by all the threads
bool fDistinct;
bool bRespectNulls; // respect null | ignore null
bool bHasDropValue; // Set to false when we discover the UDAnF doesn't implement dropValue.
std::set<T> fSet; // To hold distinct values
static_any::any fValOut; // The return value
public:
static boost::shared_ptr<WindowFunctionType> makeFunction(int id, const string& name,
int ct, mcsv1sdk::mcsv1Context& context);
};
} // namespace
#endif // UTILS_WF_UDAF_H
// vim:ts=4 sw=4: