Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ba9fbc6a
Commit
ba9fbc6a
authored
Jun 27, 2017
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementation of add() function added to the Item_sum_percentile_disc class
parent
c85552f4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
8 deletions
+56
-8
sql/item_windowfunc.h
sql/item_windowfunc.h
+56
-8
No files found.
sql/item_windowfunc.h
View file @
ba9fbc6a
...
...
@@ -24,12 +24,15 @@ class Window_spec;
int
test_if_group_changed
(
List
<
Cached_item
>
&
list
);
/* A wrapper around test_if_group_changed */
class
Group_bound_tracker
{
public:
Group_bound_tracker
(
THD
*
thd
,
SQL_I_List
<
ORDER
>
*
list
)
{
if
(
list
)
{
for
(
ORDER
*
curr
=
list
->
first
;
curr
;
curr
=
curr
->
next
)
{
...
...
@@ -37,6 +40,7 @@ class Group_bound_tracker
group_fields
.
push_back
(
tmp
);
}
}
}
void
init
()
{
...
...
@@ -86,6 +90,19 @@ class Group_bound_tracker
return
0
;
}
bool
compare_with_cache_for_null_values
()
{
List_iterator
<
Cached_item
>
li
(
group_fields
);
Cached_item
*
ptr
;
while
((
ptr
=
li
++
))
{
ptr
->
cmp
();
if
(
ptr
->
null_value
)
return
true
;
}
return
false
;
}
private:
List
<
Cached_item
>
group_fields
;
/*
...
...
@@ -100,6 +117,7 @@ class Group_bound_tracker
bool
first_check
;
};
/*
ROW_NUMBER() OVER (...)
...
...
@@ -707,7 +725,7 @@ 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
),
Type_handler_hybrid_field_type
(
&
type_handler_longlong
),
value
(
NULL
),
val_calculated
(
FALSE
)
{}
value
(
NULL
),
result_value
(
NULL
),
val_calculated
(
FALSE
)
{}
double
val_real
()
{
...
...
@@ -717,7 +735,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
return
0
;
}
null_value
=
false
;
return
((
Cached_item_real
*
)
value
)
->
get_value
();
return
((
Cached_item_real
*
)
result_
value
)
->
get_value
();
}
longlong
val_int
()
...
...
@@ -728,7 +746,18 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
return
0
;
}
null_value
=
false
;
return
((
Cached_item_int
*
)
value
)
->
get_value
();
return
((
Cached_item_int
*
)
result_value
)
->
get_value
();
}
my_decimal
*
val_decimal
(
my_decimal
*
dec
)
{
if
(
get_row_count
()
==
0
||
get_arg
(
0
)
->
is_null
())
{
null_value
=
true
;
return
0
;
}
null_value
=
false
;
return
((
Cached_item_decimal
*
)
result_value
)
->
get_value
();
}
bool
add
()
...
...
@@ -736,7 +765,18 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
Item
*
arg
=
get_arg
(
0
);
if
(
arg
->
is_null
())
return
true
;
/*implementation to be done*/
/*
need to ensure that the Item arg is constant across the entire partition
and its value ranges between [0,1]
*/
value
->
cmp
();
/* for the null values of the row, we dont count take those rows in account for calculating
the CUME_DIST */
if
(
value
->
null_value
)
return
false
;
Item_sum_cume_dist
::
add
();
double
val1
=
Item_sum_cume_dist
::
val_real
();
/* need to check type and return value accordingly*/
...
...
@@ -747,7 +787,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
if
(
val1
>=
val2
&&
!
val_calculated
)
{
val_calculated
=
true
;
value
->
cmp
();
result_
value
->
cmp
();
return
false
;
}
return
false
;
...
...
@@ -762,6 +802,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
{
val_calculated
=
false
;
value
->
clear
();
result_value
->
clear
();
Item_sum_cume_dist
::
clear
();
}
...
...
@@ -787,6 +828,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
void
setup_percentile_func
(
THD
*
thd
,
SQL_I_List
<
ORDER
>
*
list
)
{
value
=
new_Cached_item
(
thd
,
list
->
first
->
item
[
0
],
FALSE
);
result_value
=
new_Cached_item
(
thd
,
list
->
first
->
item
[
0
],
FALSE
);
}
void
cleanup
()
{
...
...
@@ -795,11 +837,17 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
delete
value
;
value
=
NULL
;
}
if
(
result_value
)
{
delete
result_value
;
result_value
=
NULL
;
}
Item_sum_num
::
cleanup
();
}
private:
Cached_item
*
value
;
Cached_item
*
result_value
;
bool
val_calculated
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment