@@ -14,7 +14,7 @@ pub mod linear;
14
14
15
15
mod column;
16
16
17
- pub use self :: column:: Column ;
17
+ pub use self :: column:: { monotonic_map_column , Column , VecColumn } ;
18
18
19
19
#[ derive( PartialEq , Eq , PartialOrd , Ord , Debug , Clone , Copy ) ]
20
20
#[ repr( u8 ) ]
@@ -56,12 +56,12 @@ impl FastFieldCodecType {
56
56
57
57
/// The FastFieldSerializerEstimate trait is required on all variants
58
58
/// of fast field compressions, to decide which one to choose.
59
- pub trait FastFieldCodec {
59
+ pub trait FastFieldCodec : ' static {
60
60
/// A codex needs to provide a unique name and id, which is
61
61
/// used for debugging and de/serialization.
62
62
const CODEC_TYPE : FastFieldCodecType ;
63
63
64
- type Reader : Column < u64 > ;
64
+ type Reader : Column < u64 > + ' static ;
65
65
66
66
/// Reads the metadata and returns the CodecReader
67
67
fn open_from_bytes ( bytes : OwnedBytes ) -> io:: Result < Self :: Reader > ;
@@ -90,35 +90,6 @@ pub struct FastFieldStats {
90
90
pub num_vals : u64 ,
91
91
}
92
92
93
- struct VecColum < ' a > ( & ' a [ u64 ] ) ;
94
- impl < ' a > Column for VecColum < ' a > {
95
- fn get_val ( & self , position : u64 ) -> u64 {
96
- self . 0 [ position as usize ]
97
- }
98
-
99
- fn iter < ' b > ( & ' b self ) -> Box < dyn Iterator < Item = u64 > + ' b > {
100
- Box :: new ( self . 0 . iter ( ) . cloned ( ) )
101
- }
102
-
103
- fn min_value ( & self ) -> u64 {
104
- self . 0 . iter ( ) . min ( ) . cloned ( ) . unwrap_or ( 0 )
105
- }
106
-
107
- fn max_value ( & self ) -> u64 {
108
- self . 0 . iter ( ) . max ( ) . cloned ( ) . unwrap_or ( 0 )
109
- }
110
-
111
- fn num_vals ( & self ) -> u64 {
112
- self . 0 . len ( ) as u64
113
- }
114
- }
115
-
116
- impl < ' a > From < & ' a [ u64 ] > for VecColum < ' a > {
117
- fn from ( data : & ' a [ u64 ] ) -> Self {
118
- Self ( data)
119
- }
120
- }
121
-
122
93
#[ cfg( test) ]
123
94
mod tests {
124
95
use proptest:: prelude:: * ;
@@ -133,10 +104,10 @@ mod tests {
133
104
data : & [ u64 ] ,
134
105
name : & str ,
135
106
) -> Option < ( f32 , f32 ) > {
136
- let estimation = Codec :: estimate ( & VecColum :: from ( data) ) ?;
107
+ let estimation = Codec :: estimate ( & VecColumn :: from ( data) ) ?;
137
108
138
109
let mut out: Vec < u8 > = Vec :: new ( ) ;
139
- Codec :: serialize ( & mut out, & VecColum :: from ( data) ) . unwrap ( ) ;
110
+ Codec :: serialize ( & mut out, & VecColumn :: from ( data) ) . unwrap ( ) ;
140
111
141
112
let actual_compression = out. len ( ) as f32 / ( data. len ( ) as f32 * 8.0 ) ;
142
113
@@ -233,7 +204,7 @@ mod tests {
233
204
#[ test]
234
205
fn estimation_good_interpolation_case ( ) {
235
206
let data = ( 10 ..=20000_u64 ) . collect :: < Vec < _ > > ( ) ;
236
- let data: VecColum = data. as_slice ( ) . into ( ) ;
207
+ let data: VecColumn = data. as_slice ( ) . into ( ) ;
237
208
238
209
let linear_interpol_estimation = LinearCodec :: estimate ( & data) . unwrap ( ) ;
239
210
assert_le ! ( linear_interpol_estimation, 0.01 ) ;
@@ -249,7 +220,7 @@ mod tests {
249
220
fn estimation_test_bad_interpolation_case ( ) {
250
221
let data: & [ u64 ] = & [ 200 , 10 , 10 , 10 , 10 , 1000 , 20 ] ;
251
222
252
- let data: VecColum = data. into ( ) ;
223
+ let data: VecColumn = data. into ( ) ;
253
224
let linear_interpol_estimation = LinearCodec :: estimate ( & data) . unwrap ( ) ;
254
225
assert_le ! ( linear_interpol_estimation, 0.32 ) ;
255
226
@@ -259,8 +230,8 @@ mod tests {
259
230
#[ test]
260
231
fn estimation_test_bad_interpolation_case_monotonically_increasing ( ) {
261
232
let mut data: Vec < u64 > = ( 200 ..=20000_u64 ) . collect ( ) ;
233
+ let data: VecColumn = data. as_slice ( ) . into ( ) ;
262
234
data. push ( 1_000_000 ) ;
263
- let data: VecColum = data. as_slice ( ) . into ( ) ;
264
235
265
236
// in this case the linear interpolation can't in fact not be worse than bitpacking,
266
237
// but the estimator adds some threshold, which leads to estimated worse behavior
0 commit comments