@@ -76,28 +76,31 @@ impl TopKSorter {
76
76
77
77
// Push the column into this sorted and update the selection
78
78
// The selection could be used in filter
79
- pub fn push_column_with_selection (
79
+ pub fn push_column_with_selection < const SELECT_ALL : bool > (
80
80
& mut self ,
81
81
col : & Column ,
82
82
selection : & mut [ u32 ] ,
83
83
count : usize ,
84
84
) -> usize {
85
85
with_number_mapped_type ! ( |NUM_TYPE | match col. data_type( ) {
86
86
DataType :: Number ( NumberDataType :: NUM_TYPE ) => self
87
- . push_column_with_selection_internal:: <NumberType :: <NUM_TYPE >>(
87
+ . push_column_with_selection_internal:: <NumberType :: <NUM_TYPE >, SELECT_ALL >(
88
88
col, selection, count
89
89
) ,
90
- DataType :: String =>
91
- self . push_column_with_selection_internal:: <StringType >( col, selection, count) ,
92
- DataType :: Timestamp =>
93
- self . push_column_with_selection_internal:: <TimestampType >( col, selection, count) ,
94
- DataType :: Date =>
95
- self . push_column_with_selection_internal:: <DateType >( col, selection, count) ,
90
+ DataType :: String => self . push_column_with_selection_internal:: <StringType , SELECT_ALL >(
91
+ col, selection, count
92
+ ) ,
93
+ DataType :: Timestamp => self
94
+ . push_column_with_selection_internal:: <TimestampType , SELECT_ALL >(
95
+ col, selection, count
96
+ ) ,
97
+ DataType :: Date => self
98
+ . push_column_with_selection_internal:: <DateType , SELECT_ALL >( col, selection, count) ,
96
99
_ => count,
97
100
} )
98
101
}
99
102
100
- fn push_column_with_selection_internal < T : ValueType > (
103
+ fn push_column_with_selection_internal < T : ValueType , const SELECT_ALL : bool > (
101
104
& mut self ,
102
105
col : & Column ,
103
106
selection : & mut [ u32 ] ,
@@ -109,7 +112,7 @@ impl TopKSorter {
109
112
let col = T :: try_downcast_column ( col) . unwrap ( ) ;
110
113
let mut result_count = 0 ;
111
114
for i in 0 ..count {
112
- let idx = selection[ i] ;
115
+ let idx = if SELECT_ALL { i as u32 } else { selection[ i] } ;
113
116
let value = unsafe { T :: index_column_unchecked ( & col, idx as usize ) } ;
114
117
if self . data . len ( ) < self . limit {
115
118
self . data . push ( T :: upcast_scalar ( T :: to_owned_scalar ( value) ) ) ;
0 commit comments