implement missing getExtremes() functions [#CLICKHOUSE-3000]

This commit is contained in:
Alexey Zatelepin 2017-09-07 16:22:25 +03:00 committed by alexey-milovidov
parent 68cb592277
commit ceddecbc10
5 changed files with 79 additions and 16 deletions

View File

@ -341,6 +341,25 @@ void ColumnArray::getExtremes(Field & min, Field & max) const
{
min = Array();
max = Array();
size_t col_size = size();
if (col_size == 0)
return;
size_t min_idx = 0;
size_t max_idx = 0;
for (size_t i = 1; i < col_size; ++i)
{
if (compareAt(i, min_idx, *this, /* nan_direction_hint = */ 1) < 0)
min_idx = i;
if (compareAt(i, max_idx, *this, /* nan_direction_hint = */ -1) > 0)
max_idx = i;
}
get(min_idx, min);
get(max_idx, max);
}

View File

@ -289,6 +289,27 @@ void ColumnFixedString::getExtremes(Field & min, Field & max) const
{
min = String();
max = String();
size_t col_size = size();
if (col_size == 0)
return;
size_t min_idx = 0;
size_t max_idx = 0;
less<true> less_op(*this);
for (size_t i = 1; i < col_size; ++i)
{
if (less_op(i, min_idx))
min_idx = i;
if (less_op(max_idx, i))
max_idx = i;
}
get(min_idx, min);
get(max_idx, max);
}
}

View File

@ -265,6 +265,27 @@ void ColumnString::getExtremes(Field & min, Field & max) const
{
min = String();
max = String();
size_t col_size = size();
if (col_size == 0)
return;
size_t min_idx = 0;
size_t max_idx = 0;
less<true> less_op(*this);
for (size_t i = 1; i < col_size; ++i)
{
if (less_op(i, min_idx))
min_idx = i;
if (less_op(max_idx, i))
max_idx = i;
}
get(min_idx, min);
get(max_idx, max);
}

View File

@ -36,18 +36,20 @@
</data>
<extremes>
<min>
<s></s>
<field></field>
<s>Hello &amp; world</s>
<field>Hello
&lt;World></field>
<time>2001-02-03 04:05:06</time>
<arr><array></array></arr>
<tpl><tuple><elem></elem><elem>2001-02-03 04:05:06</elem></tuple></tpl>
<arr><array><elem>0</elem><elem>1</elem><elem>2</elem><elem>3</elem><elem>4</elem><elem>5</elem><elem>6</elem><elem>7</elem><elem>8</elem><elem>9</elem></array></arr>
<tpl><tuple><elem>Hello &amp; world</elem><elem>2001-02-03 04:05:06</elem></tuple></tpl>
</min>
<max>
<s></s>
<field></field>
<s>Hello &amp; world</s>
<field>Hello
&lt;World></field>
<time>2001-02-03 04:05:06</time>
<arr><array></array></arr>
<tpl><tuple><elem></elem><elem>2001-02-03 04:05:06</elem></tuple></tpl>
<arr><array><elem>0</elem><elem>1</elem><elem>2</elem><elem>3</elem><elem>4</elem><elem>5</elem><elem>6</elem><elem>7</elem><elem>8</elem><elem>9</elem></array></arr>
<tpl><tuple><elem>Hello &amp; world</elem><elem>2001-02-03 04:05:06</elem></tuple></tpl>
</max>
</extremes>
<rows>1</rows>

View File

@ -64,7 +64,7 @@
"ip": "9223372036854775807",
"in": "-9223372036854775808",
"up": "18446744073709551615",
"arr": [],
"arr": ["0"],
"tuple": ["0","0"]
},
"max":
@ -74,7 +74,7 @@
"ip": "9223372036854775807",
"in": "-9223372036854775808",
"up": "18446744073709551615",
"arr": [],
"arr": ["0"],
"tuple": ["0","0"]
}
},
@ -123,8 +123,8 @@
"extremes":
{
"min": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",[],["0","0"]],
"max": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",[],["0","0"]]
"min": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",["0"],["0","0"]],
"max": ["0","0","9223372036854775807","-9223372036854775808","18446744073709551615",["0"],["0","0"]]
},
"rows": 1
@ -196,7 +196,7 @@
"ip": 9223372036854775807,
"in": -9223372036854775808,
"up": 18446744073709551615,
"arr": [],
"arr": [0],
"tuple": [0,0]
},
"max":
@ -206,7 +206,7 @@
"ip": 9223372036854775807,
"in": -9223372036854775808,
"up": 18446744073709551615,
"arr": [],
"arr": [0],
"tuple": [0,0]
}
},
@ -255,8 +255,8 @@
"extremes":
{
"min": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[],[0,0]],
"max": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[],[0,0]]
"min": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[0],[0,0]],
"max": [0,0,9223372036854775807,-9223372036854775808,18446744073709551615,[0],[0,0]]
},
"rows": 1