mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Implemented the implementation of percentile functions using Item_cache instead of Cache_Item
This commit is contained in:
@ -319,10 +319,6 @@ setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
|
||||
while ((win_func_item= li++))
|
||||
{
|
||||
win_func_item->update_used_tables();
|
||||
if (win_func_item->only_single_element_order_list())
|
||||
{
|
||||
((Item_sum_percentile_disc*)win_func_item)->set_type_handler(win_func_item->window_spec);
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_RETURN(0);
|
||||
@ -908,14 +904,13 @@ private:
|
||||
class Partition_read_cursor : public Table_read_cursor
|
||||
{
|
||||
public:
|
||||
Partition_read_cursor(THD *thd, SQL_I_List<ORDER> *partition_list, SQL_I_List<ORDER> *order_list) :
|
||||
bound_tracker(thd, partition_list), order_tracker(thd, order_list) {}
|
||||
Partition_read_cursor(THD *thd, SQL_I_List<ORDER> *partition_list) :
|
||||
bound_tracker(thd, partition_list){}
|
||||
|
||||
void init(READ_RECORD *info)
|
||||
{
|
||||
Table_read_cursor::init(info);
|
||||
bound_tracker.init();
|
||||
order_tracker.init();
|
||||
end_of_partition= false;
|
||||
}
|
||||
|
||||
@ -967,42 +962,18 @@ public:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bool next_func(ha_rows *counter)
|
||||
bool check_for_end_of_partition()
|
||||
{
|
||||
if (next())
|
||||
return true;
|
||||
if (!check_for_null_row())
|
||||
{
|
||||
(*counter)++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool fetch_func(ha_rows *counter)
|
||||
{
|
||||
if (fetch())
|
||||
return true;
|
||||
if (!check_for_null_row())
|
||||
{
|
||||
(*counter)++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool check_for_null_row()
|
||||
{
|
||||
if (!end_of_partition)
|
||||
{
|
||||
if (order_tracker.compare_with_cache_for_null_values())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return end_of_partition;
|
||||
}
|
||||
|
||||
private:
|
||||
Group_bound_tracker bound_tracker;
|
||||
Group_bound_tracker order_tracker;
|
||||
bool end_of_partition;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
@ -1178,7 +1149,7 @@ public:
|
||||
Frame_cursor *cursor;
|
||||
while ((cursor= iter++))
|
||||
cursor->pre_next_row();
|
||||
|
||||
|
||||
iter.rewind();
|
||||
while ((cursor= iter++))
|
||||
cursor->next_row();
|
||||
@ -1231,7 +1202,7 @@ public:
|
||||
SQL_I_List<ORDER> *partition_list,
|
||||
SQL_I_List<ORDER> *order_list,
|
||||
bool is_preceding_arg, Item *n_val_arg) :
|
||||
cursor(thd, partition_list, NULL), n_val(n_val_arg), item_add(NULL),
|
||||
cursor(thd, partition_list), n_val(n_val_arg), item_add(NULL),
|
||||
is_preceding(is_preceding_arg)
|
||||
{
|
||||
DBUG_ASSERT(order_list->elements == 1);
|
||||
@ -1370,7 +1341,7 @@ public:
|
||||
SQL_I_List<ORDER> *partition_list,
|
||||
SQL_I_List<ORDER> *order_list,
|
||||
bool is_preceding_arg, Item *n_val_arg) :
|
||||
cursor(thd, partition_list, NULL), n_val(n_val_arg), item_add(NULL),
|
||||
cursor(thd, partition_list), n_val(n_val_arg), item_add(NULL),
|
||||
is_preceding(is_preceding_arg), added_values(false)
|
||||
{
|
||||
DBUG_ASSERT(order_list->elements == 1);
|
||||
@ -1500,7 +1471,7 @@ public:
|
||||
Frame_range_current_row_bottom(THD *thd,
|
||||
SQL_I_List<ORDER> *partition_list,
|
||||
SQL_I_List<ORDER> *order_list) :
|
||||
cursor(thd, partition_list, NULL), peer_tracker(thd, order_list)
|
||||
cursor(thd, partition_list), peer_tracker(thd, order_list)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1715,7 +1686,7 @@ public:
|
||||
Frame_unbounded_following(THD *thd,
|
||||
SQL_I_List<ORDER> *partition_list,
|
||||
SQL_I_List<ORDER> *order_list) :
|
||||
cursor(thd, partition_list, order_list){}
|
||||
cursor(thd, partition_list){}
|
||||
|
||||
void init(READ_RECORD *info)
|
||||
{
|
||||
@ -1758,7 +1729,7 @@ public:
|
||||
Frame_unbounded_following_set_count(
|
||||
THD *thd,
|
||||
SQL_I_List<ORDER> *partition_list, SQL_I_List<ORDER> *order_list) :
|
||||
Frame_unbounded_following(thd, partition_list, order_list) {}
|
||||
Frame_unbounded_following(thd, partition_list, order_list){}
|
||||
|
||||
void next_partition(ha_rows rownum)
|
||||
{
|
||||
@ -1769,7 +1740,9 @@ public:
|
||||
|
||||
/* Walk to the end of the partition, find how many rows there are. */
|
||||
while (!cursor.next())
|
||||
{
|
||||
num_rows_in_partition++;
|
||||
}
|
||||
|
||||
List_iterator_fast<Item_sum> it(sum_functions);
|
||||
Item_sum* item;
|
||||
@ -1787,23 +1760,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Frame_unbounded_following_set_count_special : public Frame_unbounded_following_set_count
|
||||
class Frame_unbounded_following_set_count_special: public Frame_unbounded_following_set_count
|
||||
{
|
||||
public:
|
||||
Frame_unbounded_following_set_count_special(
|
||||
THD *thd,
|
||||
SQL_I_List<ORDER> *partition_list, SQL_I_List<ORDER> *order_list) :
|
||||
Frame_unbounded_following_set_count(thd, partition_list, order_list)
|
||||
{}
|
||||
|
||||
public:
|
||||
Frame_unbounded_following_set_count_special(THD *thd,
|
||||
SQL_I_List<ORDER> *partition_list,
|
||||
SQL_I_List<ORDER> *order_list, Item* arg) :
|
||||
Frame_unbounded_following_set_count(thd,partition_list, order_list)
|
||||
{
|
||||
order_item= order_list->first->item[0];
|
||||
}
|
||||
void next_partition(ha_rows rownum)
|
||||
{
|
||||
ha_rows num_rows_in_partition= 0;
|
||||
if (cursor.fetch_func(&num_rows_in_partition))
|
||||
if (cursor.fetch())
|
||||
return;
|
||||
|
||||
/* Walk to the end of the partition, find how many rows there are. */
|
||||
while (!cursor.next_func(&num_rows_in_partition));
|
||||
do
|
||||
{
|
||||
if (!order_item->is_null())
|
||||
num_rows_in_partition++;
|
||||
}while (!cursor.next());
|
||||
|
||||
List_iterator_fast<Item_sum> it(sum_functions);
|
||||
Item_sum* item;
|
||||
@ -1814,6 +1793,13 @@ public:
|
||||
item_with_row_count->set_row_count(num_rows_in_partition);
|
||||
}
|
||||
}
|
||||
|
||||
ha_rows get_curr_rownum() const
|
||||
{
|
||||
return cursor.get_rownum();
|
||||
}
|
||||
private:
|
||||
Item* order_item;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -2013,7 +1999,7 @@ public:
|
||||
SQL_I_List<ORDER> *order_list,
|
||||
bool is_top_bound_arg, ha_rows n_rows_arg) :
|
||||
is_top_bound(is_top_bound_arg), n_rows(n_rows_arg),
|
||||
cursor(thd, partition_list, NULL)
|
||||
cursor(thd, partition_list)
|
||||
{
|
||||
}
|
||||
|
||||
@ -2628,7 +2614,7 @@ void get_window_functions_required_cursors(
|
||||
{
|
||||
fc= new Frame_unbounded_following_set_count_special(thd,
|
||||
item_win_func->window_spec->partition_list,
|
||||
item_win_func->window_spec->order_list);
|
||||
item_win_func->window_spec->order_list, item_win_func->window_func()->get_arg(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user