[Maria-developers] GSOC 2020 - MDEV-11263 Aggregate Window Functions
![](https://secure.gravatar.com/avatar/9df5bccb2dea60150be9f412e067a636.jpg?s=120&d=mm&r=g)
Hi everyone, As part of GSOC 2020, this is one of the two projects I am interested in pursuing. As guided by last years' comments by Varun and Vicențiu, I have set up a debugger and corresponding breakpoints in the Item_sum_sum::add and Item_sum_sp::add for a custom sum aggregate function to understand the code flow. I had a couple of queries regarding the same: 1. In *do_add *from decimal.c, there are three parts with comments - /* part 1 - MY_MAX(frac) ... min (frac) */, /* part 2 - MY_MIN(frac) ... MY_MIN(intg) */. Can someone please elaborate on what do the comments mean ? 2. In *Item_sum_sum::add_helper*, there is an unlikely branch for variable direct_added. Can someone please give an idea about when will direct added be true ? In fact in all the uses for direct_added, it is always in an unlikely branch in Item_sum.cc. Regards Tavneet
![](https://secure.gravatar.com/avatar/39b623a1559cf9c69ac3d9d4fb44e7fe.jpg?s=120&d=mm&r=g)
Hi, Tavneet! On Mar 28, Tavneet Sarna wrote:
Hi everyone,
As part of GSOC 2020, this is one of the two projects I am interested in pursuing. As guided by last years' comments by Varun and Vicențiu, I have set up a debugger and corresponding breakpoints in the Item_sum_sum::add and Item_sum_sp::add for a custom sum aggregate function to understand the code flow.
I had a couple of queries regarding the same:
1. In *do_add *from decimal.c, there are three parts with comments - /* part 1 - MY_MAX(frac) ... min (frac) */, /* part 2 - MY_MIN(frac) ... MY_MIN(intg) */. Can someone please elaborate on what do the comments mean ?
Sure. This is just how addition of two long numbers work. Say, you have 1234.567890 here frac is 6 +998765.234 here frac is 3 you start from the end, the "part 1" is from the longest tail to the shortest tail, from MAX(6,3) to MIN(6,3). This is the tail "890" and it can be simply copied into the result: while (buf1 > stop) *--buf0=*--buf1; second part if where two numbers overlap. do_add works from the end, adding digits and propagating the carry. third part is where one number is longer than the other in most significant digits. That is "99". But this is the level of details that you don't need for your project. You can rely on the fact that there are different data types and some of them (for example, integers, floats, and decimal) can be added, subtracted, etc. For this project you don't need to study at how exactly the addition works internally.
2. In *Item_sum_sum::add_helper*, there is an unlikely branch for variable direct_added. Can someone please give an idea about when will direct added be true ? In fact in all the uses for direct_added, it is always in an unlikely branch in Item_sum.cc.
This was added specifically for and is only used by the spider engine. If you run spider tests you'll probably see it being true. But I suspect you can ignore it too for now. Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
participants (2)
-
Sergei Golubchik
-
Tavneet Sarna