You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-523 Add UDAF and UDAnF SDK
This commit is contained in:
5
dbcon/execplan/CMakeLists.txt
Normal file → Executable file
5
dbcon/execplan/CMakeLists.txt
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
|
||||
include_directories( ${ENGINE_COMMON_INCLUDES} )
|
||||
include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_UTILS_UDFSDK_INCLUDE} )
|
||||
|
||||
|
||||
########### next target ###############
|
||||
@ -41,7 +41,8 @@ set(execplan_LIB_SRCS
|
||||
treenode.cpp
|
||||
treenodeimpl.cpp
|
||||
vendorexecutionplan.cpp
|
||||
windowfunctioncolumn.cpp)
|
||||
windowfunctioncolumn.cpp
|
||||
udafcolumn.cpp)
|
||||
|
||||
add_library(execplan SHARED ${execplan_LIB_SRCS})
|
||||
|
||||
|
3
dbcon/execplan/aggregatecolumn.h
Normal file → Executable file
3
dbcon/execplan/aggregatecolumn.h
Normal file → Executable file
@ -70,7 +70,8 @@ public:
|
||||
BIT_AND,
|
||||
BIT_OR,
|
||||
BIT_XOR,
|
||||
GROUP_CONCAT
|
||||
GROUP_CONCAT,
|
||||
UDAF
|
||||
};
|
||||
|
||||
/**
|
||||
|
4
dbcon/execplan/calpontsystemcatalog.cpp
Normal file → Executable file
4
dbcon/execplan/calpontsystemcatalog.cpp
Normal file → Executable file
@ -1051,7 +1051,7 @@ const CalpontSystemCatalog::ColType CalpontSystemCatalog::colType(const OID& Oid
|
||||
colMap.insert(CMVT_(scale, srcp));
|
||||
srcp.reset(col[8]);
|
||||
colMap.insert(CMVT_(precision, srcp));
|
||||
// TODO: NULL value handling & convert to boost::any
|
||||
// TODO: NULL value handling & convert to static_any::any
|
||||
// delete this manually at fcn exit
|
||||
srcp.reset(col[9]);
|
||||
colMap.insert(CMVT_(defaultvalue, srcp));
|
||||
@ -5045,7 +5045,7 @@ void CalpontSystemCatalog::getSchemaInfo(const string& in_schema)
|
||||
colMap.insert(CMVT_(scale, srcp));
|
||||
srcp.reset(col[8]);
|
||||
colMap.insert(CMVT_(precision, srcp));
|
||||
// TODO: NULL value handling & convert to boost::any
|
||||
// TODO: NULL value handling & convert to static_any::any
|
||||
// delete this manually at fcn exit
|
||||
srcp.reset(col[9]);
|
||||
colMap.insert(CMVT_(defaultvalue, srcp));
|
||||
|
29
dbcon/execplan/calpontsystemcatalog.h
Normal file → Executable file
29
dbcon/execplan/calpontsystemcatalog.h
Normal file → Executable file
@ -156,7 +156,8 @@ public:
|
||||
TEXT, /*!< TEXT type */
|
||||
NUM_OF_COL_DATA_TYPE, /* NEW TYPES ABOVE HERE */
|
||||
LONGDOUBLE, /* @bug3241, dev and variance calculation only */
|
||||
STRINT /* @bug3532, string as int for fast comparison */
|
||||
STRINT, /* @bug3532, string as int for fast comparison */
|
||||
UNDEFINED /*!< Undefined - used in UDAF API */
|
||||
};
|
||||
|
||||
/** the set of column constraint types
|
||||
@ -914,6 +915,32 @@ inline bool isCharType(const execplan::CalpontSystemCatalog::ColDataType type)
|
||||
/** convenience function to determine if column type is an
|
||||
* unsigned type
|
||||
*/
|
||||
inline bool isNumeric(const execplan::CalpontSystemCatalog::ColDataType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
case execplan::CalpontSystemCatalog::UTINYINT:
|
||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||
case execplan::CalpontSystemCatalog::UMEDINT:
|
||||
case execplan::CalpontSystemCatalog::UINT:
|
||||
case execplan::CalpontSystemCatalog::UBIGINT:
|
||||
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isUnsigned(const execplan::CalpontSystemCatalog::ColDataType type)
|
||||
{
|
||||
switch (type)
|
||||
|
7
dbcon/execplan/execplan.vpj
Normal file → Executable file
7
dbcon/execplan/execplan.vpj
Normal file → Executable file
@ -213,6 +213,7 @@
|
||||
<F N="filter.cpp"/>
|
||||
<F N="functioncolumn.cpp"/>
|
||||
<F N="groupconcatcolumn.cpp"/>
|
||||
<F N="intervalcolumn.cpp"/>
|
||||
<F N="logicoperator.cpp"/>
|
||||
<F N="mysqlexecutionplan.cpp"/>
|
||||
<F N="objectidmanager.cpp"/>
|
||||
@ -221,6 +222,7 @@
|
||||
<F N="oracleexecutionplan.cpp"/>
|
||||
<F N="outerjoinonfilter.cpp"/>
|
||||
<F N="predicateoperator.cpp"/>
|
||||
<F N="pseudocolumn.cpp"/>
|
||||
<F N="range.cpp"/>
|
||||
<F N="returnedcolumn.cpp"/>
|
||||
<F N="rowcolumn.cpp"/>
|
||||
@ -232,6 +234,7 @@
|
||||
<F N="simplescalarfilter.cpp"/>
|
||||
<F N="treenode.cpp"/>
|
||||
<F N="treenodeimpl.cpp"/>
|
||||
<F N="udafcolumn.cpp"/>
|
||||
<F N="vendorexecutionplan.cpp"/>
|
||||
<F N="windowfunctioncolumn.cpp"/>
|
||||
</Folder>
|
||||
@ -258,6 +261,7 @@
|
||||
<F N="filter.h"/>
|
||||
<F N="functioncolumn.h"/>
|
||||
<F N="groupconcatcolumn.h"/>
|
||||
<F N="intervalcolumn.h"/>
|
||||
<F N="logicoperator.h"/>
|
||||
<F N="mysqlexecutionplan.h"/>
|
||||
<F N="njlcolumnresult.h"/>
|
||||
@ -268,6 +272,7 @@
|
||||
<F N="outerjoinonfilter.h"/>
|
||||
<F N="parsetree.h"/>
|
||||
<F N="predicateoperator.h"/>
|
||||
<F N="pseudocolumn.h"/>
|
||||
<F N="range.h"/>
|
||||
<F N="returnedcolumn.h"/>
|
||||
<F N="rowcolumn.h"/>
|
||||
@ -282,7 +287,9 @@
|
||||
<F N="simplescalarfilter.h"/>
|
||||
<F N="treenode.h"/>
|
||||
<F N="treenodeimpl.h"/>
|
||||
<F N="udafcolumn.h"/>
|
||||
<F N="vendorexecutionplan.h"/>
|
||||
<F N="wf_frame.h"/>
|
||||
<F N="windowfunctioncolumn.h"/>
|
||||
</Folder>
|
||||
<Folder
|
||||
|
6
dbcon/execplan/objectreader.cpp
Normal file → Executable file
6
dbcon/execplan/objectreader.cpp
Normal file → Executable file
@ -32,6 +32,7 @@
|
||||
#include "treenode.h"
|
||||
#include "returnedcolumn.h"
|
||||
#include "aggregatecolumn.h"
|
||||
#include "udafcolumn.h"
|
||||
#include "arithmeticcolumn.h"
|
||||
#include "constantcolumn.h"
|
||||
#include "functioncolumn.h"
|
||||
@ -121,6 +122,9 @@ TreeNode* ObjectReader::createTreeNode(messageqcpp::ByteStream& b) {
|
||||
case GROUPCONCATCOLUMN:
|
||||
ret = new GroupConcatColumn();
|
||||
break;
|
||||
case UDAFCOLUMN:
|
||||
ret = new UDAFColumn();
|
||||
break;
|
||||
case ARITHMETICCOLUMN:
|
||||
ret = new ArithmeticColumn();
|
||||
break;
|
||||
@ -293,6 +297,8 @@ void ObjectReader::checkType(messageqcpp::ByteStream& b, const CLASSID id)
|
||||
throw UnserializeException("Not a CalpontSelectExecutionPlan");
|
||||
case NULL_CLASS:
|
||||
throw UnserializeException("Not NULL"); // ??
|
||||
case MCSV1_CONTEXT:
|
||||
throw UnserializeException("Not a MCSV1_CONTEXT");
|
||||
default:
|
||||
throw UnserializeException("Bad id");
|
||||
}
|
||||
|
4
dbcon/execplan/objectreader.h
Normal file → Executable file
4
dbcon/execplan/objectreader.h
Normal file → Executable file
@ -114,6 +114,10 @@ public:
|
||||
CALPONTSELECTEXECUTIONPLAN,
|
||||
CONSTANTFILTER,
|
||||
OUTERJOINONFILTER,
|
||||
|
||||
/** UDAF SDK */
|
||||
MCSV1_CONTEXT,
|
||||
UDAFCOLUMN,
|
||||
};
|
||||
|
||||
typedef uint8_t id_t; //expand as necessary
|
||||
|
130
dbcon/execplan/udafcolumn.cpp
Executable file
130
dbcon/execplan/udafcolumn.cpp
Executable file
@ -0,0 +1,130 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
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 <sstream>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "bytestream.h"
|
||||
using namespace messageqcpp;
|
||||
|
||||
#include "rowgroup.h"
|
||||
using namespace rowgroup;
|
||||
|
||||
#include "joblisttypes.h"
|
||||
using namespace joblist;
|
||||
|
||||
#include "simplefilter.h"
|
||||
#include "constantfilter.h"
|
||||
#include "arithmeticcolumn.h"
|
||||
#include "functioncolumn.h"
|
||||
#include "objectreader.h"
|
||||
#include "groupconcatcolumn.h"
|
||||
#include "udafcolumn.h"
|
||||
|
||||
namespace execplan {
|
||||
|
||||
/**
|
||||
* Constructors/Destructors
|
||||
*/
|
||||
UDAFColumn::UDAFColumn():
|
||||
AggregateColumn()
|
||||
{
|
||||
}
|
||||
|
||||
UDAFColumn::UDAFColumn(const uint32_t sessionID):
|
||||
AggregateColumn(sessionID)
|
||||
{
|
||||
}
|
||||
|
||||
UDAFColumn::UDAFColumn(const UDAFColumn& rhs, const uint32_t sessionID):
|
||||
AggregateColumn(dynamic_cast<const AggregateColumn&>(rhs))
|
||||
{
|
||||
}
|
||||
|
||||
UDAFColumn::~UDAFColumn()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
|
||||
const string UDAFColumn::toString() const
|
||||
{
|
||||
ostringstream output;
|
||||
output << "UDAFColumn " << endl;
|
||||
output << AggregateColumn::toString() << endl;
|
||||
output << context.toString() << endl;
|
||||
return output.str();
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& output, const UDAFColumn& rhs)
|
||||
{
|
||||
output << rhs.toString();
|
||||
return output;
|
||||
}
|
||||
|
||||
void UDAFColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
{
|
||||
b << (uint8_t) ObjectReader::UDAFCOLUMN;
|
||||
AggregateColumn::serialize(b);
|
||||
context.serialize(b);
|
||||
}
|
||||
|
||||
void UDAFColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
{
|
||||
ObjectReader::checkType(b, ObjectReader::UDAFCOLUMN);
|
||||
AggregateColumn::unserialize(b);
|
||||
context.unserialize(b);
|
||||
}
|
||||
|
||||
bool UDAFColumn::operator==(const UDAFColumn& t) const
|
||||
{
|
||||
const AggregateColumn *rc1, *rc2;
|
||||
|
||||
rc1 = static_cast<const AggregateColumn*>(this);
|
||||
rc2 = static_cast<const AggregateColumn*>(&t);
|
||||
if (*rc1 != *rc2)
|
||||
return false;
|
||||
if (context != t.context)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UDAFColumn::operator==(const TreeNode* t) const
|
||||
{
|
||||
const UDAFColumn *ac;
|
||||
|
||||
ac = dynamic_cast<const UDAFColumn*>(t);
|
||||
if (ac == NULL)
|
||||
return false;
|
||||
return *this == *ac;
|
||||
}
|
||||
|
||||
bool UDAFColumn::operator!=(const UDAFColumn& t) const
|
||||
{
|
||||
return !(*this == t);
|
||||
}
|
||||
|
||||
bool UDAFColumn::operator!=(const TreeNode* t) const
|
||||
{
|
||||
return !(*this == t);
|
||||
}
|
||||
|
||||
} // namespace execplan
|
131
dbcon/execplan/udafcolumn.h
Executable file
131
dbcon/execplan/udafcolumn.h
Executable file
@ -0,0 +1,131 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
/***********************************************************************
|
||||
* $Id: groupconcatcolumn.h 9210 2013-01-21 14:10:42Z rdempsey $
|
||||
*
|
||||
*
|
||||
***********************************************************************/
|
||||
/** @file */
|
||||
|
||||
#ifndef UDAFCOLUMN_H
|
||||
#define UDAFCOLUMN_H
|
||||
#include <string>
|
||||
|
||||
#include "calpontselectexecutionplan.h"
|
||||
#include "aggregatecolumn.h"
|
||||
#include "mcsv1_udaf.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
class ByteStream;
|
||||
}
|
||||
|
||||
using namespace mcsv1sdk;
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
/**
|
||||
* @brief A class to represent an aggregate return column
|
||||
*
|
||||
* This class is a specialization of class ReturnedColumn that
|
||||
* handles a user defined aggregate function (UDAF) call.
|
||||
*/
|
||||
class UDAFColumn : public AggregateColumn {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructors
|
||||
*/
|
||||
UDAFColumn();
|
||||
|
||||
UDAFColumn(const uint32_t sessionID);
|
||||
|
||||
UDAFColumn(const UDAFColumn& rhs, const uint32_t sessionID=0);
|
||||
|
||||
/**
|
||||
* Destructors
|
||||
*/
|
||||
virtual ~UDAFColumn();
|
||||
|
||||
/**
|
||||
* Overloaded stream operator
|
||||
*/
|
||||
virtual const std::string toString() const;
|
||||
|
||||
/** return a copy of this pointer
|
||||
*
|
||||
* deep copy of this pointer and return the copy
|
||||
*/
|
||||
virtual UDAFColumn* clone() const { return new UDAFColumn(*this); }
|
||||
|
||||
/**
|
||||
* Accessors and Mutators
|
||||
*/
|
||||
mcsv1Context& getContext() {return context;}
|
||||
|
||||
/**
|
||||
* Serialize interface
|
||||
*/
|
||||
virtual void serialize(messageqcpp::ByteStream&) const;
|
||||
virtual void unserialize(messageqcpp::ByteStream&);
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this;
|
||||
* false otherwise
|
||||
*/
|
||||
virtual bool operator==(const TreeNode* t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return true iff every member of t is a duplicate copy of every member of this;
|
||||
* false otherwise
|
||||
*/
|
||||
virtual bool operator==(const UDAFColumn& t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this;
|
||||
* true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const TreeNode* t) const;
|
||||
|
||||
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
|
||||
*
|
||||
* Do a deep, strict (as opposed to semantic) equivalence test.
|
||||
* @return false iff every member of t is a duplicate copy of every member of this;
|
||||
* true otherwise
|
||||
*/
|
||||
virtual bool operator!=(const UDAFColumn& t) const;
|
||||
|
||||
private:
|
||||
mcsv1Context context;
|
||||
};
|
||||
|
||||
/**
|
||||
* stream operator
|
||||
*/
|
||||
std::ostream& operator<<(std::ostream& os, const UDAFColumn& rhs);
|
||||
|
||||
}
|
||||
#endif //UDAFCOLUMN_H
|
||||
|
95
dbcon/execplan/wf_frame.h
Executable file
95
dbcon/execplan/wf_frame.h
Executable file
@ -0,0 +1,95 @@
|
||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
/***********************************************************************
|
||||
* $Id: wf_frame.h 9679 2017-06-11 $
|
||||
*
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef WINDOW_FUNCTION_FRAME_H
|
||||
#define WINDOW_FUNCTION_FRAME_H
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
#include "returnedcolumn.h"
|
||||
|
||||
/**
|
||||
* Namespace
|
||||
*/
|
||||
namespace execplan {
|
||||
|
||||
// This enum is made consistant with mysql Item_window_func
|
||||
enum WF_FRAME
|
||||
{
|
||||
WF_PRECEDING = 0,
|
||||
WF_FOLLOWING,
|
||||
WF_UNBOUNDED_PRECEDING,
|
||||
WF_UNBOUNDED_FOLLOWING,
|
||||
WF_CURRENT_ROW,
|
||||
WF_UNKNOWN
|
||||
};
|
||||
|
||||
struct WF_Boundary
|
||||
{
|
||||
WF_Boundary() {}
|
||||
WF_Boundary(WF_FRAME frame):fFrame(frame) {}
|
||||
~WF_Boundary() {}
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
SRCP fVal; /// has to evaluate to unsigned value
|
||||
SRCP fBound; /// order by col +, -, date_add or date_sub for RANGE window
|
||||
enum WF_FRAME fFrame;
|
||||
};
|
||||
|
||||
struct WF_Frame
|
||||
{
|
||||
WF_Frame(): fIsRange(true)
|
||||
{
|
||||
fStart.fFrame = WF_UNBOUNDED_PRECEDING;
|
||||
fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
|
||||
}
|
||||
~WF_Frame() {}
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
WF_Boundary fStart;
|
||||
WF_Boundary fEnd;
|
||||
bool fIsRange; /// RANGE or ROWS
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to represent the order by clause of window function
|
||||
*/
|
||||
struct WF_OrderBy
|
||||
{
|
||||
WF_OrderBy() {}
|
||||
WF_OrderBy(std::vector<SRCP> orders): fOrders(orders) {}
|
||||
~WF_OrderBy() {};
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
std::vector<SRCP> fOrders;
|
||||
WF_Frame fFrame;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
2
dbcon/execplan/windowfunctioncolumn.cpp
Normal file → Executable file
2
dbcon/execplan/windowfunctioncolumn.cpp
Normal file → Executable file
@ -257,6 +257,7 @@ void WindowFunctionColumn::serialize(messageqcpp::ByteStream& b) const
|
||||
for (uint32_t i = 0; i < fPartitions.size(); i++)
|
||||
fPartitions[i]->serialize(b);
|
||||
fOrderBy.serialize(b);
|
||||
udafContext.serialize(b);
|
||||
}
|
||||
|
||||
void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
@ -283,6 +284,7 @@ void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
|
||||
fPartitions.push_back(srcp);
|
||||
}
|
||||
fOrderBy.unserialize(b);
|
||||
udafContext.unserialize(b);
|
||||
}
|
||||
|
||||
void WindowFunctionColumn::addToPartition(vector<SRCP>& groupByList)
|
||||
|
62
dbcon/execplan/windowfunctioncolumn.h
Normal file → Executable file
62
dbcon/execplan/windowfunctioncolumn.h
Normal file → Executable file
@ -31,6 +31,8 @@
|
||||
|
||||
#include "returnedcolumn.h"
|
||||
#include "functor.h"
|
||||
#include "mcsv1_udaf.h"
|
||||
#include "wf_frame.h"
|
||||
|
||||
namespace messageqcpp {
|
||||
class ByteStream;
|
||||
@ -41,61 +43,6 @@ class ByteStream;
|
||||
*/
|
||||
namespace execplan {
|
||||
|
||||
// This enum is made consistant with mysql Item_window_func
|
||||
enum WF_FRAME
|
||||
{
|
||||
WF_PRECEDING = 0,
|
||||
WF_FOLLOWING,
|
||||
WF_UNBOUNDED_PRECEDING,
|
||||
WF_UNBOUNDED_FOLLOWING,
|
||||
WF_CURRENT_ROW,
|
||||
WF_UNKNOWN
|
||||
};
|
||||
|
||||
struct WF_Boundary
|
||||
{
|
||||
WF_Boundary() {}
|
||||
WF_Boundary(WF_FRAME frame):fFrame(frame) {}
|
||||
~WF_Boundary() {}
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
SRCP fVal; /// has to evaluate to unsigned value
|
||||
SRCP fBound; /// order by col +, -, date_add or date_sub for RANGE window
|
||||
enum WF_FRAME fFrame;
|
||||
};
|
||||
|
||||
struct WF_Frame
|
||||
{
|
||||
WF_Frame(): fIsRange(true)
|
||||
{
|
||||
fStart.fFrame = WF_UNBOUNDED_PRECEDING;
|
||||
fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
|
||||
}
|
||||
~WF_Frame() {}
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
WF_Boundary fStart;
|
||||
WF_Boundary fEnd;
|
||||
bool fIsRange; /// RANGE or ROWS
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to represent the order by clause of window function
|
||||
*/
|
||||
struct WF_OrderBy
|
||||
{
|
||||
WF_OrderBy() {}
|
||||
WF_OrderBy(std::vector<SRCP> orders): fOrders(orders) {}
|
||||
~WF_OrderBy() {};
|
||||
const std::string toString() const;
|
||||
void serialize(messageqcpp::ByteStream&) const;
|
||||
void unserialize(messageqcpp::ByteStream&);
|
||||
std::vector<SRCP> fOrders;
|
||||
WF_Frame fFrame;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A class to represent a functional column
|
||||
*
|
||||
@ -182,6 +129,9 @@ public:
|
||||
virtual bool hasWindowFunc();
|
||||
void adjustResultType();
|
||||
|
||||
// UDAnF support
|
||||
mcsv1sdk::mcsv1Context& getUDAFContext() {return udafContext;}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Fields
|
||||
@ -197,6 +147,8 @@ private:
|
||||
virtual bool operator!=(const TreeNode* t) const { return false; }
|
||||
bool operator!=(const WindowFunctionColumn& t) const;
|
||||
|
||||
// UDAnF support
|
||||
mcsv1sdk::mcsv1Context udafContext;
|
||||
/***********************************************************
|
||||
* F&E framework *
|
||||
***********************************************************/
|
||||
|
Reference in New Issue
Block a user