Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
Classes | Typedefs | Functions
gini.cc File Reference

Gini coefficient. More...

#include "sqlstat.h"
#include <set>
Include dependency graph for gini.cc:

Go to the source code of this file.

Classes

struct  sqlstat::Item
 
struct  sqlstat::ItemComperator
 
struct  sqlstat::gini_storage
 

Typedefs

typedef std::multiset< Item,
ItemComperator > 
sqlstat::ItemSet
 

Functions

my_bool gini_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Called before first usage of function. More...
 
void gini_reset (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Reset function and add first group member Calls clear and add. More...
 
void gini_clear (UDF_INIT *initid, char *is_null, char *error)
 Called at start of group. More...
 
void gini_add (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Add a member of the group. More...
 
double gini (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Retrieve gini. Called at end of group. More...
 
void gini_deinit (UDF_INIT *initid)
 Called after last access to function. More...
 

Detailed Description

Gini coefficient.

CREATE AGGREGATE FUNCTION gini RETURNS REAL SONAME 'libsqlstat.so';
SELECT gini(x, w) FROM mytab;
DROP FUNCTION gini;

Definition in file gini.cc.

Function Documentation

double gini ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Retrieve gini. Called at end of group.

Parameters
initidfunction description
argsargument values
is_nullresult is NULL
errorerror occured
Returns
gini

Definition at line 176 of file gini.cc.

void gini_add ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Add a member of the group.

The counter and sums are updated

Parameters
initidfunction description
argsargument values
is_null
errorerror occured

Definition at line 146 of file gini.cc.

Here is the caller graph for this function:

void gini_clear ( UDF_INIT *  initid,
char *  is_null,
char *  error 
)

Called at start of group.

The counter and sums are cleared.

Parameters
initidfunction description
is_null
errorerror message

Definition at line 129 of file gini.cc.

Here is the caller graph for this function:

gini_deinit ( UDF_INIT *  initid)

Called after last access to function.

Deallocate memory for counter and sums.

Parameters
initid

Definition at line 209 of file gini.cc.

my_bool gini_init ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  message 
)

Called before first usage of function.

Check parameters.
Indicate type of return value.
Allocate memory for counter and sums.

Parameters
initidfunction description
argsparameters
messageerror message
Returns
success = 0

Definition at line 76 of file gini.cc.

void gini_reset ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Reset function and add first group member Calls clear and add.

Parameters
initidfunction description
argsargument values
is_null
errorerror message
Deprecated:
Reset is only called by MySQL 4.0 and below. It is implemented for backwards compatibility.

Definition at line 115 of file gini.cc.

Here is the call graph for this function: