diff --git a/dbcon/mysql/mysql.vpj b/dbcon/mysql/mysql.vpj
index fd92a4562..246b58003 100644
--- a/dbcon/mysql/mysql.vpj
+++ b/dbcon/mysql/mysql.vpj
@@ -614,6 +614,7 @@
+
fUDAFContext);
- context.setRowCnt(rowCnt);
context.setInterrupted(bInterrupted);
context.createUserData();
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
@@ -3191,10 +3189,8 @@ void RowAggregationUM::doNotNullConstantAggregate(const ConstantAggData& aggData
case ROWAGG_UDAF:
{
- int64_t rowCnt = 0;
bool bInterrupted = false;
mcsv1sdk::mcsv1Context context(((RowUDAFFunctionCol*)fFunctionCols[i].get())->fUDAFContext);
- context.setRowCnt(rowCnt);
context.setInterrupted(bInterrupted);
context.createUserData();
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
diff --git a/utils/udfsdk/allnull.cpp b/utils/udfsdk/allnull.cpp
index 0e34c8c77..132e0c076 100755
--- a/utils/udfsdk/allnull.cpp
+++ b/utils/udfsdk/allnull.cpp
@@ -15,11 +15,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include
-#include
#include "allnull.h"
-#include "bytestream.h"
-#include "objectreader.h"
using namespace mcsv1sdk;
@@ -31,7 +27,7 @@ struct allnull_data
#define OUT_TYPE int64_t
mcsv1_UDAF::ReturnCode allnull::init(mcsv1Context* context,
- COL_TYPES& colTypes)
+ COL_TYPES& colTypes)
{
context->setUserDataSize(sizeof(allnull_data));
if (colTypes.size() < 1)
@@ -46,11 +42,6 @@ mcsv1_UDAF::ReturnCode allnull::init(mcsv1Context* context,
return mcsv1_UDAF::SUCCESS;
}
-mcsv1_UDAF::ReturnCode allnull::finish(mcsv1Context* context)
-{
- return mcsv1_UDAF::SUCCESS;
-}
-
mcsv1_UDAF::ReturnCode allnull::reset(mcsv1Context* context)
{
struct allnull_data* data = (struct allnull_data*)context->getUserData()->data;
diff --git a/utils/udfsdk/allnull.h b/utils/udfsdk/allnull.h
index 3d720b17d..dc685b9f9 100755
--- a/utils/udfsdk/allnull.h
+++ b/utils/udfsdk/allnull.h
@@ -38,22 +38,9 @@
* 6. restart the Columnstore system.
* 7. notify mysqld about the new functions with commands like:
*
- * // An example of xor over a range for UDAF and UDAnF
- * CREATE AGGREGATE FUNCTION mcs_bit_xor returns BOOL soname
- * 'libudfsdk.so';
+ * CREATE AGGREGATE FUNCTION allnull returns BOOL soname
+ * 'libudf_mysql.so';
*
- * // An example that only makes sense as a UDAnF
- * CREATE AGGREGATE FUNCTION mcs_interpolate returns REAL
- * soname 'libudfsdk.so';
- *
- * The UDAF functions may run distributed in the Columnstore
- * engine. UDAnF do not run distributed.
- *
- * UDAF is User Defined Aggregate Function.
- * UDAnF is User Defined Analytic Function.
- * UDA(n)F is an acronym for a function that could be either. It
- * is also used to describe the interface that is used for
- * either.
*/
#ifndef HEADER_allnull
#define HEADER_allnull
@@ -116,18 +103,7 @@ public:
* colTypes or wrong number of arguments. Else return
* mcsv1_UDAF::SUCCESS.
*/
- virtual ReturnCode init(mcsv1Context* context,
- COL_TYPES& colTypes);
-
- /**
- * finish()
- *
- * Mandatory. Completes the UDA(n)F. Called once per SQL
- * statement. Do not free any memory allocated by
- * context->setUserDataSize(). The SDK Framework owns that memory
- * and will handle that. Often, there is nothing to do here.
- */
- virtual ReturnCode finish(mcsv1Context* context);
+ virtual ReturnCode init(mcsv1Context* context, COL_TYPES& colTypes);
/**
* reset()
@@ -162,8 +138,7 @@ public:
*
* valsIn (in) - a vector of the parameters from the row.
*/
- virtual ReturnCode nextValue(mcsv1Context* context,
- std::vector& valsIn);
+ virtual ReturnCode nextValue(mcsv1Context* context, std::vector& valsIn);
/**
* subEvaluate()
diff --git a/utils/udfsdk/avg_mode.cpp b/utils/udfsdk/avg_mode.cpp
index b29bcd69c..6567dc4c6 100755
--- a/utils/udfsdk/avg_mode.cpp
+++ b/utils/udfsdk/avg_mode.cpp
@@ -57,11 +57,6 @@ mcsv1_UDAF::ReturnCode avg_mode::init(mcsv1Context* context,
}
-mcsv1_UDAF::ReturnCode avg_mode::finish(mcsv1Context* context)
-{
- return mcsv1_UDAF::SUCCESS;
-}
-
mcsv1_UDAF::ReturnCode avg_mode::reset(mcsv1Context* context)
{
ModeData* data = static_cast(context->getUserData());
diff --git a/utils/udfsdk/avg_mode.h b/utils/udfsdk/avg_mode.h
index 8bf375fa8..7556a643f 100755
--- a/utils/udfsdk/avg_mode.h
+++ b/utils/udfsdk/avg_mode.h
@@ -136,16 +136,6 @@ public:
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
- /**
- * finish()
- *
- * Mandatory. Completes the UDA(n)F. Called once per SQL
- * statement. Do not free any memory allocated by
- * context->setUserDataSize(). The SDK Framework owns that memory
- * and will handle that. Often, there is nothing to do here.
- */
- virtual ReturnCode finish(mcsv1Context* context);
-
/**
* reset()
*
diff --git a/utils/udfsdk/mcsv1_udaf.cpp b/utils/udfsdk/mcsv1_udaf.cpp
index de01c6033..f0b157d76 100755
--- a/utils/udfsdk/mcsv1_udaf.cpp
+++ b/utils/udfsdk/mcsv1_udaf.cpp
@@ -113,7 +113,6 @@ bool mcsv1Context::operator==(const mcsv1Context& c) const
|| fResultType != c.fResultType
|| fResultscale != c.fResultscale
|| fResultPrecision != c.fResultPrecision
- || fRowsInPartition != c.fRowsInPartition
|| fStartFrame != c.fStartFrame
|| fEndFrame != c.fEndFrame
|| fStartConstant != c.fStartConstant
@@ -135,7 +134,7 @@ const std::string mcsv1Context::toString() const
output << " UserDataSize=" << fUserDataSize << " ResultType=" << colDataTypeToString(fResultType) << std::endl;
output << " Resultscale=" << fResultscale << " ResultPrecision=" << fResultPrecision << std::endl;
output << " ErrorMsg=" << errorMsg << std::endl;
- output << " bInterrupted=" << bInterrupted << " RowsInPartition=" << fRowsInPartition << std::endl;
+ output << " bInterrupted=" << bInterrupted << std::endl;
output << " StartFrame=" << fStartFrame << " EndFrame=" << fEndFrame << std::endl;
output << " StartConstant=" << fStartConstant << " EndConstant=" << fEndConstant << std::endl;
return output.str();
@@ -199,7 +198,6 @@ void mcsv1Context::serialize(messageqcpp::ByteStream& b) const
b << errorMsg;
// Don't send dataflags. These are set for each call
// bInterrupted is set internally.
- b << fRowsInPartition;
b << (uint32_t)fStartFrame;
b << (uint32_t)fEndFrame;
b << fStartConstant;
@@ -218,7 +216,6 @@ void mcsv1Context::unserialize(messageqcpp::ByteStream& b)
b >> fResultscale;
b >> fResultPrecision;
b >> errorMsg;
- b >> fRowsInPartition;
uint32_t frame;
b >> frame;
fStartFrame = (WF_FRAME)frame;
diff --git a/utils/udfsdk/mcsv1_udaf.h b/utils/udfsdk/mcsv1_udaf.h
index 33e15188d..052ecbbcb 100755
--- a/utils/udfsdk/mcsv1_udaf.h
+++ b/utils/udfsdk/mcsv1_udaf.h
@@ -32,20 +32,24 @@
* 2. Create the UDF function implementation in some .cpp file
* 3. Create the connector stub (MariaDB UDAF definition) for
* this UDF function.
- * 4. build the dynamic library using all of the source.
+ * 4. build the dynamic librarys using all of the source.
* 5 Put the library in $COLUMNSTORE_INSTALL/lib of
* all modules
- * 6. restart the Columnstore system.
- * 7. notify mysqld about the new functions with commands like:
+ * 6. Put the connector stub in $COLUMNSTORE_INSTALL/mysql/lib
+ * of all UMs
+ * 7. restart the Columnstore system. 7. notify mysqld about the
+ * new functions with commands like:
*
- * // An example of xor over a range for UDAF and UDAnF
- * CREATE AGGREGATE FUNCTION mcs_bit_xor returns BOOL soname
- * 'libudfsdk.so';
+ * CREATE AGGREGATE FUNCTION all_null returns BOOL soname
+ * 'libudf_mysql.so';
*
* // An example that only makes sense as a UDAnF
* CREATE AGGREGATE FUNCTION mcs_interpolate returns REAL
- * soname 'libudfsdk.so';
- *
+ * soname 'libudf_mysql.so';
+ *
+ * Use the name of the connector stub library in CREATE
+ * AGGREGATE FUNCTION
+ *
* The UDAF functions may run distributed in the Columnstore
* engine. UDAnF do not run distributed.
*
@@ -55,6 +59,7 @@
* is also used to describe the interface that is used for
* either.
*/
+
#ifndef HEADER_mcsv1_udaf
#define HEADER_mcsv1_udaf
@@ -133,9 +138,9 @@ struct UserData
/**
* serialize()
*
- * User data is passed between process. In order to do so, it
+ * User data is passed between processes. In order to do so, it
* must be serialized. Since user data can have sub objects,
- * containers and the like, it is up to the UDAF to provide the
+ * containers and the like, it is up to the UDAF to provide the
* serialize function. The streaming functionality of
* messageqcpp::ByteStream must be used.
*
@@ -147,7 +152,7 @@ struct UserData
/**
* unserialize()
*
- * User data is passed between process. In order to do so, it
+ * User data is passed between processes. In order to do so, it
* must be unserialized. Since user data can have sub objects,
* containers and the like, it is up to the UDAF to provide the
* unserialize function. The streaming functionality of
@@ -198,7 +203,7 @@ typedef std::vector >C
// This is the context class that is passed to all API callbacks
// The framework potentially sets data here for each invocation of
// mcsv1_UDAF methods. Access methods are given for data useful to UDA(n)F.
-// Don't modify anything directly except data retrieved with getUserData().
+// Don't modify anything directly except the struct retrieved with getUserData().
// UDA(n)F devlopers should not modify this class. The framework and other UDA(n)F
// rely on it being as it was when they were compiled.
@@ -257,23 +262,23 @@ public:
EXPORT bool isPM();
// Parameter refinement description accessors
- // valid in nextValue, dropValue and evaluateCumulative
+ // valid in nextValue and dropValue
size_t getParameterCount() const;
// Determine if an input parameter is NULL
- // valid in nextValue, dropValue and evaluateCumulative
+ // valid in nextValue and dropValue
EXPORT bool isParamNull(int paramIdx);
- // If a parameter is a constant, the UDA(n)F could presumably optimize its workings.
- // During the first call to nextValue() or evaluateCumulative().
+ // If a parameter is a constant, the UDA(n)F could presumably optimize its workings
+ // during the first call to nextValue().
// Is there a better way to determine this?
- // valid in nextValue, dropValue and evaluateCumulative
+ // valid in nextValue
EXPORT bool isParamConstant(int paramIdx);
// For getting the result type.
EXPORT CalpontSystemCatalog::ColDataType getResultType() const;
- // For getting the decimal characteristics for the return value.
+ // For getting the decimal characteristics for the return type.
// These will be set to the default before init().
EXPORT int32_t getScale() const;
EXPORT int32_t getPrecision() const;
@@ -302,16 +307,6 @@ public:
// method should clean up and exit.
EXPORT bool getInterrupted() const;
- // Returns the actual number of rows in the partition. If no partitioning, returns 0.
- // valid in reset()
- EXPORT uint64_t getRowsInPartition() const;
-
- // Returns the number of rows in the aggregate. This could be the total number of rows,
- // the number of rows in the group, or the number of rows in the PM's subaggregate,
- // depending on the context it was called.
- // valid in subEvaluate() end evaluate().
- EXPORT uint64_t getRowCnt() const;
-
// Allocate instance specific memory. This should be type cast to a structure overlay
// defined by the function. The actual allocatoin occurs in the various modules that
// do the aggregation. If the UDAF is being calculated in a distributed fashion, then
@@ -362,18 +357,16 @@ public:
private:
uint64_t fRunFlags; // Set by the user to define the type of UDA(n)F
- uint64_t fContextFlags; // Set by the framework to define this specific call.
+ uint64_t fContextFlags; // Set by the framework to define this specific call.
int32_t fUserDataSize;
boost::shared_ptr fUserData;
CalpontSystemCatalog::ColDataType fResultType;
- int32_t fColWidth; // The length in bytes of the return type
- int32_t fResultscale; // For scale, the number of digits to the right of the decimal
+ int32_t fColWidth; // The length in bytes of the return type
+ int32_t fResultscale; // For scale, the number of digits to the right of the decimal
int32_t fResultPrecision; // The max number of digits allowed in the decimal value
std::string errorMsg;
std::vector* dataFlags; // one entry for each parameter
- bool* bInterrupted; // Gets set to true by the Framework if something happens
- uint64_t fRowsInPartition; // Only valid in reset()
- int64_t fRowCnt; // The number of rows involved in this aggregate.
+ bool* bInterrupted; // Gets set to true by the Framework if something happens
WF_FRAME fStartFrame; // Is set to default to start, then modified by the actual frame in the call
WF_FRAME fEndFrame; // Is set to default to start, then modified by the actual frame in the call
int32_t fStartConstant; // for start frame WF_PRECEEDIMG or WF_FOLLOWING
@@ -398,7 +391,6 @@ public:
EXPORT void setDataFlags(std::vector* flags);
EXPORT void setInterrupted(bool interrupted);
EXPORT void setInterrupted(bool* interrupted);
- EXPORT void setRowCnt(uint64_t cnt);
EXPORT mcsv1sdk::mcsv1_UDAF* getFunction();
EXPORT mcsv1sdk::mcsv1_UDAF* getFunction() const;
EXPORT boost::shared_ptr getUserDataSP();
@@ -407,11 +399,11 @@ public:
// Since aggregate functions can operate on any data type, we use the following structure
// to define the input row data. To be type insensiteve, data is stored in type static_any::any.
//
-// To access the data it must be type cast to the correct type using boost::any_cast.
+// To access the data it must be type cast to the correct type using static_any::cast.
// example for int data:
//
-// if (dataType == CalpontSystemCatalog::INT)
-// int myint = boost::any_castcolumnData;
+// if (valIn.compatible(intTypeId)
+// int myint = valIn.cast();
//
// For multi-paramter aggregations, the colsIn vector of next_value()
// contains the ordered set of row parameters.
@@ -469,16 +461,6 @@ public:
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes) = 0;
- /**
- * finish()
- *
- * Mandatory. Completes the UDA(n)F. Called once per SQL
- * statement. Do not free any memory allocated by
- * createUserData(). The SDK Framework owns that memory
- * and will handle that. Often, there is nothing to do here.
- */
- virtual ReturnCode finish(mcsv1Context* context) = 0;
-
/**
* reset()
*
@@ -647,7 +629,6 @@ inline mcsv1Context::mcsv1Context() :
fResultPrecision(18),
dataFlags(NULL),
bInterrupted(NULL),
- fRowsInPartition(0),
fStartFrame(WF_UNBOUNDED_PRECEDING),
fEndFrame(WF_CURRENT_ROW),
fStartConstant(0),
@@ -845,16 +826,6 @@ inline bool mcsv1Context::getInterrupted() const
return false;
}
-inline uint64_t mcsv1Context::getRowsInPartition() const
-{
- return fRowsInPartition;
-}
-
-inline uint64_t mcsv1Context::getRowCnt() const
-{
- return fRowCnt;
-}
-
inline void mcsv1Context::setUserDataSize(int bytes)
{
fUserDataSize = bytes;
@@ -930,11 +901,6 @@ inline void mcsv1Context::setName(std::string name)
functionName = name;
}
-inline void mcsv1Context::setRowCnt(uint64_t cnt)
-{
- fRowCnt = cnt;
-}
-
inline uint64_t mcsv1Context::getContextFlags() const
{
return fContextFlags;
diff --git a/utils/udfsdk/median.cpp b/utils/udfsdk/median.cpp
index b91d17d4b..aacb335f5 100755
--- a/utils/udfsdk/median.cpp
+++ b/utils/udfsdk/median.cpp
@@ -57,11 +57,6 @@ mcsv1_UDAF::ReturnCode median::init(mcsv1Context* context,
}
-mcsv1_UDAF::ReturnCode median::finish(mcsv1Context* context)
-{
- return mcsv1_UDAF::SUCCESS;
-}
-
mcsv1_UDAF::ReturnCode median::reset(mcsv1Context* context)
{
MedianData* data = static_cast(context->getUserData());
diff --git a/utils/udfsdk/median.h b/utils/udfsdk/median.h
index 9d529aa87..4bf3dc65c 100755
--- a/utils/udfsdk/median.h
+++ b/utils/udfsdk/median.h
@@ -136,16 +136,6 @@ public:
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
- /**
- * finish()
- *
- * Mandatory. Completes the UDA(n)F. Called once per SQL
- * statement. Do not free any memory allocated by
- * context->setUserDataSize(). The SDK Framework owns that memory
- * and will handle that. Often, there is nothing to do here.
- */
- virtual ReturnCode finish(mcsv1Context* context);
-
/**
* reset()
*
diff --git a/utils/udfsdk/ssq.cpp b/utils/udfsdk/ssq.cpp
index 1be9aafb1..3b6fa9dc7 100755
--- a/utils/udfsdk/ssq.cpp
+++ b/utils/udfsdk/ssq.cpp
@@ -67,11 +67,6 @@ mcsv1_UDAF::ReturnCode ssq::init(mcsv1Context* context,
}
-mcsv1_UDAF::ReturnCode ssq::finish(mcsv1Context* context)
-{
- return mcsv1_UDAF::SUCCESS;
-}
-
mcsv1_UDAF::ReturnCode ssq::reset(mcsv1Context* context)
{
struct ssq_data* data = (struct ssq_data*)context->getUserData()->data;
diff --git a/utils/udfsdk/ssq.h b/utils/udfsdk/ssq.h
index 893c578af..e8d042c43 100755
--- a/utils/udfsdk/ssq.h
+++ b/utils/udfsdk/ssq.h
@@ -116,16 +116,6 @@ public:
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
- /**
- * finish()
- *
- * Mandatory. Completes the UDA(n)F. Called once per SQL
- * statement. Do not free any memory allocated by
- * context->createUserData(). The SDK Framework owns that memory
- * and will handle that. Often, there is nothing to do here.
- */
- virtual ReturnCode finish(mcsv1Context* context);
-
/**
* reset()
*
diff --git a/utils/udfsdk/udfsdk.vpj b/utils/udfsdk/udfsdk.vpj
index 919c73d17..664b0e7de 100755
--- a/utils/udfsdk/udfsdk.vpj
+++ b/utils/udfsdk/udfsdk.vpj
@@ -229,10 +229,10 @@
+
-