Add decrease interface for aggregation#9737
Conversation
| saved_values.erase(iter); | ||
| } | ||
|
|
||
| void changeIfLess(const IColumn & column, size_t row_num, Arena *) |
There was a problem hiding this comment.
I think you can define an add method, both changeIfLess and changeIfGreater can call add
There was a problem hiding this comment.
I think you can define an
addmethod, bothchangeIfLessandchangeIfGreatercan calladd
done
| if constexpr (is_min) | ||
| iter = saved_values.begin(); | ||
| else | ||
| iter = std::prev(saved_values.end()); |
There was a problem hiding this comment.
why not just use iter = saved_values.rbegin()?
There was a problem hiding this comment.
why not just use iter = saved_values.rbegin()?
done
| {} | ||
|
|
||
| // TODO use std::string is inefficient | ||
| std::string value; |
There was a problem hiding this comment.
why not use StringRef or std::string_view
There was a problem hiding this comment.
why not use StringRef or std::string_view
Using StringRef now.
|
|
||
| public: | ||
| explicit AggregateFunctionNullBase(AggregateFunctionPtr nested_function_) | ||
| explicit AggregateFunctionNullBase(AggregateFunctionPtr nested_function_, bool need_counter = false) |
There was a problem hiding this comment.
why need_counter is still needed?
There was a problem hiding this comment.
why need_counter is still needed?
deleted
| , collator(collator_) | ||
| {} | ||
|
|
||
| // TODO use StringRef is inefficient |
There was a problem hiding this comment.
what is the todo mean, is there any more efficient implement here?
There was a problem hiding this comment.
what is the todo mean, is there any more efficient implement here?
It can be deleted now.
| mutable multiset saved_values; | ||
| TiDB::TiDBCollatorPtr collator{}; | ||
|
|
||
| void saveValue(StringRef value) { saved_values.insert(StringWithCollator(value, collator)); } |
There was a problem hiding this comment.
| void saveValue(StringRef value) { saved_values.insert(StringWithCollator(value, collator)); } | |
| void saveValue(StringRef & value) { saved_values.insert(StringWithCollator(value, collator)); } |
|
|
||
| switch (prefix_size) | ||
| { | ||
| case 1: |
There was a problem hiding this comment.
why not just use an array like [sizeof(uint64), sizeof(uint64), sizeof(uint64), 9, sizeof(uint64), 10, 12, 14], so the result_prefix_size = array[prefix_size], or use a static array so it can be init at runtime without assuming sizeof(uint64) == 8
There was a problem hiding this comment.
why not just use an array like [sizeof(uint64), sizeof(uint64), sizeof(uint64), 9, sizeof(uint64), 10, 12, 14], so the result_prefix_size = array[prefix_size], or use a static array so it can be init at runtime without assuming sizeof(uint64) == 8
done
| }; | ||
|
|
||
| // Make the prefix_size >= sizeof(UInt64) and could fit the align size | ||
| inline size_t enlarge_prefix_size(size_t prefix_size) noexcept |
There was a problem hiding this comment.
Looks like as the function name, it should be enlargePrefixSize
There was a problem hiding this comment.
Looks like as the function name, it should be
enlargePrefixSize
done
| fmt::format("Cannot allocate memory (posix_memalign), size: {}, alignment: {}.", size, alignment), | ||
| ErrorCodes::CANNOT_ALLOCATE_MEMORY, | ||
| res); | ||
| buf = new_buf; |
There was a problem hiding this comment.
The buf is always nullptr when this function is called?
There was a problem hiding this comment.
The
bufis always nullptr when this function is called?
yes
dbms/src/Common/AlignedBuffer.h
Outdated
| public: | ||
| AlignedBuffer() = default; | ||
| AlignedBuffer(size_t size, size_t alignment); | ||
| AlignedBuffer(AlignedBuffer && old) noexcept { std::swap(buf, old.buf); } |
There was a problem hiding this comment.
This function seems useless, because there is no guarantee that the alignment is the same?
There was a problem hiding this comment.
This function seems useless, because there is no guarantee that the alignment is the same?
deleted
| inline size_t enlargePrefixSize(size_t prefix_size) noexcept | ||
| { | ||
| assert(prefix_size != 0); | ||
| static_assert((sizeof(prefix_size_look_up_table) / sizeof(UInt64)) == 7); |
There was a problem hiding this comment.
asdd another static_assert to make sure sizeof(UInt64) == 8?
There was a problem hiding this comment.
asdd another static_assert to make sure sizeof(UInt64) == 8?
done
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: guo-shaoge, windtalker The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/cherrypick release-8.5-20250310-v8.5.1 |
ref pingcap#7376 In order to support aggregation in window function, we need to add some interfaces for aggregation. In this pr, we add `decrease` interface for aggregation. Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
|
@xzhangxian1008: new pull request created to branch DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: ref #7376
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note