yiguolei commented on code in PR #16850:
URL: https://github.com/apache/doris/pull/16850#discussion_r1111365388
##########
be/src/vec/columns/column_decimal.cpp:
##########
@@ -325,6 +325,61 @@ ColumnPtr ColumnDecimal<T>::filter(const IColumn::Filter&
filt, ssize_t result_s
return res;
}
+template <typename T>
+size_t ColumnDecimal<T>::filter(const IColumn::Filter& filter) {
+ size_t size = data.size();
+ if (size != filter.size()) {
+ LOG(FATAL) << "Size of filter doesn't match size of column.";
+ }
+
+ const UInt8* filter_pos = filter.data();
+ const UInt8* filter_end = filter_pos + size;
+ const T* data_pos = data.data();
+ T* result_data = data.data();
+
+ /** A slightly more optimized version.
+ * Based on the assumption that often pieces of consecutive values
+ * completely pass or do not pass the filter.
+ * Therefore, we will optimistically check the parts of `SIMD_BYTES`
values.
+ */
+ static constexpr size_t SIMD_BYTES = 32;
+ const UInt8* filter_end_sse = filter_pos + size / SIMD_BYTES * SIMD_BYTES;
+
+ while (filter_pos < filter_end_sse) {
+ uint32_t mask = simd::bytes32_mask_to_bits32_mask(filter_pos);
+
+ if (0xFFFFFFFF == mask) {
+ memmove(result_data, data_pos, sizeof(T) * SIMD_BYTES);
+ result_data += SIMD_BYTES;
+ } else {
+ while (mask) {
+ const size_t idx = __builtin_ctzll(mask);
+ *result_data = data_pos[idx];
+ ++result_data;
+ mask = mask & (mask - 1);
+ }
+ }
+
+ filter_pos += SIMD_BYTES;
+ data_pos += SIMD_BYTES;
+ }
+
+ while (filter_pos < filter_end) {
+ if (*filter_pos) {
+ *result_data = *data_pos;
+ ++result_data;
+ }
+
+ ++filter_pos;
+ ++data_pos;
+ }
+
+ const auto result_size = result_data - data.data();
+ data.set_end_ptr(result_data);
+
+ return result_size;
Review Comment:
not call resize? Not change size?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]