Skip to content

Commit

Permalink
A basic implementation of the add function is added
Browse files Browse the repository at this point in the history
  • Loading branch information
varunraiko committed Nov 1, 2017
1 parent 18747a4 commit cc046fa
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions sql/item_windowfunc.h
Expand Up @@ -704,8 +704,8 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
class Item_sum_percentile_disc : public Item_sum_cume_dist
{
public:
Item_sum_percentile_disc(THD *thd, Item* arg) : Item_sum_cume_dist(thd, arg)
value(NULL) {}
Item_sum_percentile_disc(THD *thd, Item* arg) : Item_sum_cume_dist(thd, arg),
value(NULL), val_calculated(FALSE) {}

double val_real()
{
Expand All @@ -715,7 +715,18 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist
return 0;
}
null_value= false;
return 0;
return ((Cached_item_int*) value)->get_value();
}

longlong val_int()
{
if (get_row_count() == 0 || get_arg(0)->is_null())
{
null_value= true;
return 0;
}
null_value= false;
return ((Cached_item_int*) value)->get_value();
}

bool add()
Expand All @@ -724,6 +735,19 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist
if (arg->is_null())
return true;
/*implementation to be done*/
Item_sum_cume_dist::add();
double val1= Item_sum_cume_dist::val_real();
/* need to check type and return value accordingly*/
double val2 =arg->val_real_from_decimal();

/* use Cached_item to do the comparision using cmp_read_only() */

if( val1 >= val2 && !val_calculated)
{
val_calculated= true;
value->cmp();
return false;
}
return false;
}

Expand All @@ -734,7 +758,9 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist

void clear()
{
//need to implement
val_calculated= false;
value->clear();
Item_sum_cume_dist::clear();
}

const char*func_name() const
Expand Down Expand Up @@ -770,6 +796,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist

private:
Cached_item *value;
bool val_calculated;
};


Expand Down

0 comments on commit cc046fa

Please sign in to comment.