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-1201 Modify docs. Fix group concat bug
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
.. _ColumnDatum:
|
||||
|
||||
ColumnDatum
|
||||
===========
|
||||
|
||||
@ -13,7 +15,7 @@ Example for int data:
|
||||
int myint = valIn.cast<int>();
|
||||
|
||||
|
||||
For multi-paramter aggregations (not available in Columnstore 1.1), the colsIn vector of next_value() contains the ordered set of row parameters.
|
||||
For multi-paramter aggregations (not available in Columnstore 1.1), the colsIn array of next_value() contains the ordered set of row parameters.
|
||||
|
||||
For char, varchar, text, varbinary and blob types, columnData will be std::string.
|
||||
|
||||
@ -59,7 +61,7 @@ The provided values are:
|
||||
* - SMALLINT
|
||||
- A signed two byte integer
|
||||
* - DECIMAL
|
||||
- A Columnstore Decimal value. For Columnstore 1.1, this is stored in the smallest integer type field that will hold the required precision.
|
||||
- A Columnstore Decimal value. This is stored in the smallest integer type field that will hold the required precision.
|
||||
* - MEDINT
|
||||
- A signed four byte integer
|
||||
* - INT
|
||||
|
@ -13,7 +13,7 @@ The library placed in mysql/lib is the name you use in the SQL CREATE AGGREGATE
|
||||
|
||||
CREATE AGGREGATE FUNCTION ssq returns REAL soname 'libudf_mysql.so';
|
||||
|
||||
Unlike the code you write for the Columnstore UDAF, MariaDB does not handle allocation and de-allocation of your memory structures. If writing your function for other engines, you must handle allocation and de-alloaction in :ref:`function_init <func_init>` and :ref:`function_deinit <func_deinit>`
|
||||
Unlike the code you write for the Columnstore UDAF, MariaDB does not handle allocation and de-allocation of your memory structures in other engines. If writing your function for other engines, you must handle allocation and de-alloaction in :ref:`function_init <func_init>` and :ref:`function_deinit <func_deinit>`
|
||||
|
||||
All of the MariaDB UDF and UDAF example functions are in a single source file named udfmysql.cpp and linked into libudf_mysql.so.
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
UDAFMap
|
||||
=======
|
||||
|
||||
The UDAFMap is where we tell the system about our function. For Columnstore 1.1, you must manually place your function into this map.
|
||||
The UDAFMap is where we tell the system about our function. For Columnstore 1.2, you must manually place your function into this map.
|
||||
|
||||
* open mcsv1_udaf.cpp
|
||||
* add your header to the #include list
|
||||
|
@ -150,7 +150,7 @@ Use these to determine the way your UDA(n)F was called
|
||||
|
||||
.. c:function:: size_t getParameterCount() const;
|
||||
|
||||
:returns: the number of parameters to the function in the SQL query. Columnstore 1.1 only supports one parameter.
|
||||
:returns: the number of parameters to the function in the SQL query.
|
||||
|
||||
.. c:function:: bool isParamNull(int paramIdx);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.. _ mcsv1_udaf:
|
||||
.. _mcsv1_udaf:
|
||||
|
||||
mcsv1_UDAF
|
||||
==========
|
||||
@ -11,12 +11,14 @@ The base class has no data members. It is designed to be only a container for yo
|
||||
|
||||
However, adding static const members makes sense.
|
||||
|
||||
For UDAF (not Wndow Functions) Aggregation takes place in three stages:
|
||||
For UDAF (not Window Functions) Aggregation takes place in three stages:
|
||||
|
||||
* Subaggregation on the PM. nextValue()
|
||||
* Consolodation on the UM. subevaluate()
|
||||
* Evaluation of the function on the UM. evaluate()
|
||||
|
||||
There are situations where the system makes a choice to perform all UDAF calculations on the UM. The presence of group_concat() in the query and certain joins can cause the optimizer to make this choice.
|
||||
|
||||
For Window Functions, all aggregation occurs on the UM, and thus the subevaluate step is skipped. There is an optional dropValue() function that may be added.
|
||||
|
||||
* Aggregation on the UM. nextValue()
|
||||
@ -80,17 +82,11 @@ Callback Methods
|
||||
|
||||
.. _init:
|
||||
|
||||
.. c:function:: ReturnCode init(mcsv1Context* context, COL_TYPES& colTypes);
|
||||
.. c:function:: ReturnCode init(mcsv1Context* context, ColumnDatum* colTypes);
|
||||
|
||||
:param context: The context object for this call.
|
||||
|
||||
:param colTypes: A list of the column types of the parameters.
|
||||
|
||||
COL_TYPES is defined as::
|
||||
|
||||
typedef std::vector<std::pair<std::string, CalpontSystemCatalog::ColDataType> >COL_TYPES;
|
||||
|
||||
In Columnstore 1.1, only one column is supported, so colTyoes will be of length one.
|
||||
:param colTypes: A list of ColumnDatum structures. Use this to access the column types of the parameters. colTypes.columnData will be invalid.
|
||||
|
||||
:returns: ReturnCode::ERROR or ReturnCode::SUCCESS
|
||||
|
||||
@ -116,25 +112,23 @@ Callback Methods
|
||||
|
||||
.. _nextvalue:
|
||||
|
||||
.. c:function:: ReturnCode nextValue(mcsv1Context* context, std::vector<ColumnDatum>& valsIn);
|
||||
.. c:function:: ReturnCode nextValue(mcsv1Context* context, ColumnDatum* valsIn);
|
||||
|
||||
:param context: The context object for this call
|
||||
|
||||
:param valsIn: a vector representing the values to be added for each parameter for this row.
|
||||
|
||||
In Columnstore 1.1, this will be a vector of length one.
|
||||
|
||||
:param valsIn: an array representing the values to be added for each parameter for this row.
|
||||
|
||||
:returns: ReturnCode::ERROR or ReturnCode::SUCCESS
|
||||
|
||||
Use context->getUserData() and type cast it to your UserData type or Simple Data Model stuct.
|
||||
|
||||
nextValue() is called for each Window movement that passes the WHERE and HAVING clauses. The context's UserData will contain values that have been sub-aggregated to this point for the group, partition or Window Frame. nextValue is called on the PM for aggregation and on the UM for Window Functions.
|
||||
|
||||
When used in an aggregate, the function may not rely on order or completeness since the sub-aggregation is going on at the PM, it only has access to the data stored on the PM's dbroots.
|
||||
When used in an aggregate, the function should not rely on order or completeness since the sub-aggregation is going on at the PM, it only has access to the data stored on the PM's dbroots.
|
||||
|
||||
When used as a analytic function (Window Function), nextValue is call for each Window movement in the Window. If dropValue is defined, then it may be called for every value leaving the Window, and nextValue called for each new value entering the Window.
|
||||
When used as a analytic function (Window Function), nextValue is called for each Window movement in the Window. If dropValue is defined, then it may be called for every value leaving the Window, and nextValue called for each new value entering the Window.
|
||||
|
||||
Since this is called for every row, it is important that this method be efficient.
|
||||
Since this may called for every row, it is important that this method be efficient.
|
||||
|
||||
.. _subevaluate:
|
||||
|
||||
@ -172,13 +166,11 @@ Callback Methods
|
||||
|
||||
.. _dropvalue:
|
||||
|
||||
.. c:function:: ReturnCode dropValue(mcsv1Context* context, std::vector<ColumnDatum>& valsDropped);
|
||||
.. c:function:: ReturnCode dropValue(mcsv1Context* context, ColumnDatum* valsDropped);
|
||||
|
||||
:param context: The context object for this call
|
||||
|
||||
:param valsDropped: a vector representing the values to be dropped for each parameter for this row.
|
||||
|
||||
In Columnstore 1.1, this will be a vector of length one.
|
||||
:param valsDropped: an array representing the values to be dropped for each parameter for this row.
|
||||
|
||||
:returns: ReturnCode::ERROR or ReturnCode::SUCCESS
|
||||
|
||||
|
Reference in New Issue
Block a user