mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Fix memory like in groupArraySorted
This commit is contained in:
parent
53cef82acd
commit
ddd477afad
@ -53,6 +53,7 @@ enum class GroupArraySortedStrategy
|
||||
sort
|
||||
};
|
||||
|
||||
|
||||
constexpr size_t group_array_sorted_sort_strategy_max_elements_threshold = 1000000;
|
||||
|
||||
template <typename T, GroupArraySortedStrategy strategy>
|
||||
@ -209,6 +210,14 @@ struct GroupArraySortedData
|
||||
result_array_data[result_array_data_insert_begin + i] = values[i];
|
||||
}
|
||||
}
|
||||
|
||||
~GroupArraySortedData()
|
||||
{
|
||||
for (auto & value : values)
|
||||
{
|
||||
value.~T();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
36
tests/queries/0_stateless/03094_grouparraysorted_memory.sql
Normal file
36
tests/queries/0_stateless/03094_grouparraysorted_memory.sql
Normal file
@ -0,0 +1,36 @@
|
||||
CREATE TABLE 03094_grouparrysorted_dest
|
||||
(
|
||||
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
|
||||
-- aggregates
|
||||
SlowSpans AggregateFunction(groupArraySorted(100),
|
||||
Tuple(NegativeDurationNs Int64, Timestamp DateTime64(9), TraceId String, SpanId String)
|
||||
) CODEC(ZSTD(1))
|
||||
)
|
||||
ENGINE = AggregatingMergeTree()
|
||||
ORDER BY (ServiceName);
|
||||
|
||||
CREATE TABLE 03094_grouparrysorted_src
|
||||
(
|
||||
ServiceName String,
|
||||
Duration Int64,
|
||||
Timestamp DateTime64(9),
|
||||
TraceId String,
|
||||
SpanId String
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY ();
|
||||
|
||||
CREATE MATERIALIZED VIEW 03094_grouparrysorted_mv TO 03094_grouparrysorted_dest
|
||||
AS SELECT
|
||||
ServiceName,
|
||||
groupArraySortedState(100)(
|
||||
CAST(
|
||||
tuple(-Duration, Timestamp, TraceId, SpanId),
|
||||
'Tuple(NegativeDurationNs Int64, Timestamp DateTime64(9), TraceId String, SpanId String)'
|
||||
)) as SlowSpans
|
||||
FROM 03094_grouparrysorted_src
|
||||
GROUP BY
|
||||
ServiceName;
|
||||
|
||||
|
||||
INSERT INTO 03094_grouparrysorted_src SELECT * FROM generateRandom() LIMIT 5000000;
|
Loading…
Reference in New Issue
Block a user