MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Aggregator_distinct Class Reference

#include <item_sum.h>

Inheritance diagram for Aggregator_distinct:
Collaboration diagram for Aggregator_distinct:

Public Member Functions

 Aggregator_distinct (Item_sum *sum)
Aggregator_type Aggrtype ()
bool setup (THD *)
void clear ()
bool add ()
void endup ()
virtual my_decimalarg_val_decimal (my_decimal *value)
virtual double arg_val_real ()
virtual bool arg_is_null ()
bool unique_walk_function (void *element)
- Public Member Functions inherited from Aggregator
 Aggregator (Item_sum *arg)

Static Public Member Functions

static int composite_key_cmp (void *arg, uchar *key1, uchar *key2)

Friends

class Item_sum_sum

Additional Inherited Members

- Public Types inherited from Aggregator
enum  Aggregator_type { SIMPLE_AGGREGATOR, DISTINCT_AGGREGATOR }
- Protected Attributes inherited from Aggregator
Item_sumitem_sum
bool use_distinct_values

Detailed Description

The distinct aggregator. Implements AGGFN (DISTINCT ..) Collects all the data into an Unique (similarly to what Item_sum_distinct does currently) and then (if applicable) iterates over the list of unique values and pumps them back into its object

Definition at line 541 of file item_sum.h.

Member Function Documentation

bool Aggregator_distinct::add ( )
virtual

Process incoming row.

Add it to Unique/temp hash table if it's unique. Skip the row if not unique. Prepare Aggregator_distinct to process the incoming stream. Create the temporary table and the Unique class if needed. Called by Item_sum::aggregator_add(). To actually get the result value in item_sum's buffers Aggregator_distinct::endup() must be called.

Returns
status
Return values
FALSEsuccess
TRUEfailure

Implements Aggregator.

Definition at line 1006 of file item_sum.cc.

Here is the call graph for this function:

bool Aggregator_distinct::arg_is_null ( )
virtual

NULLness of being-aggregated argument; can be called only after arg_val_decimal() or arg_val_real().

Implements Aggregator.

Definition at line 1520 of file item_sum.cc.

my_decimal * Aggregator_distinct::arg_val_decimal ( my_decimal value)
virtual

Decimal value of being-aggregated argument

Implements Aggregator.

Definition at line 1506 of file item_sum.cc.

double Aggregator_distinct::arg_val_real ( )
virtual

Floating point value of being-aggregated argument

Implements Aggregator.

Definition at line 1513 of file item_sum.cc.

void Aggregator_distinct::clear ( )
virtual

Invalidate calculated value and clear the distinct rows.

Frees space used by the internal data structures. Removes the accumulated distinct rows. Invalidates the calculated result.

Implements Aggregator.

Definition at line 966 of file item_sum.cc.

Here is the call graph for this function:

int Aggregator_distinct::composite_key_cmp ( void *  arg,
uchar *  key1,
uchar *  key2 
)
static

Correctly compare composite keys.

Used by the Unique class to compare keys. Will do correct comparisons for composite keys with various field types.

Parameters
argPointer to the relevant Aggregator_distinct instance
key1left key image
key2right key image
Returns
comparison result
Return values
<0if key1 < key2
=0if key1 = key2
>0if key1 > key2

Definition at line 682 of file item_sum.cc.

Here is the caller graph for this function:

void Aggregator_distinct::endup ( )
virtual

Calculate the aggregate function value.

Since Distinct_aggregator::add() just collects the distinct rows, we must go over the distinct rows and feed them to the aggregation function before returning its value. This is what endup () does. It also sets the result validity flag endup_done to TRUE so it will not recalculate the aggregate value again if the Item_sum hasn't been reset.

Implements Aggregator.

Definition at line 1065 of file item_sum.cc.

C_MODE_END bool Aggregator_distinct::setup ( THD *  thd)
virtual

Called before feeding the first row. Used to allocate/setup the internal structures used for aggregation.

Parameters
thdThread descriptor
Returns
status
Return values
FALSEsuccess
TRUEfaliure

Prepares Aggregator_distinct to process the incoming stream. Creates the temporary table and the Unique class if needed. Called by Item_sum::aggregator_setup()

Implements Aggregator.

Definition at line 764 of file item_sum.cc.

Here is the call graph for this function:

bool Aggregator_distinct::unique_walk_function ( void *  element)

Aggregate a distinct row from the distinct hash table.

Called for each row into the hash table 'Aggregator_distinct::table'. Includes the current distinct row into the calculation of the aggregate value. Uses the Field classes to get the value from the row. This function is used for AVG/SUM(DISTINCT). For COUNT(DISTINCT) it's called only when there are no blob arguments and the data don't fit into memory (so Unique makes persisted trees on disk).

Parameters
elementpointer to the row data.
Returns
status
Return values
FALSEsuccess
TRUEfailure

Definition at line 1460 of file item_sum.cc.


The documentation for this class was generated from the following files: