@@ -5,11 +5,11 @@ use std::ops::Deref;
5
5
use std:: sync:: Arc ;
6
6
7
7
use common:: BinarySerializable ;
8
+ pub use dictionary_encoded:: { BytesColumn , StrColumn } ;
8
9
pub use serialize:: {
9
- open_column_bytes, open_column_u128, open_column_u64, serialize_column_u128 ,
10
+ open_column_bytes, open_column_u128, open_column_u64, serialize_column_mappable_to_u128 ,
10
11
serialize_column_u64,
11
12
} ;
12
- pub use dictionary_encoded:: { BytesColumn , StrColumn } ;
13
13
14
14
use crate :: column_index:: ColumnIndex ;
15
15
use crate :: column_values:: ColumnValues ;
@@ -21,23 +21,31 @@ pub struct Column<T> {
21
21
pub values : Arc < dyn ColumnValues < T > > ,
22
22
}
23
23
24
- use crate :: column_index:: Set ;
25
-
26
24
impl < T : PartialOrd > Column < T > {
27
- pub fn first ( & self , row_id : RowId ) -> Option < T > {
25
+ pub fn num_rows ( & self ) -> RowId {
28
26
match & self . idx {
29
- ColumnIndex :: Full => Some ( self . values . get_val ( row_id) ) ,
30
- ColumnIndex :: Optional ( opt_idx) => {
31
- let value_row_idx = opt_idx. rank_if_exists ( row_id) ?;
32
- Some ( self . values . get_val ( value_row_idx) )
33
- }
34
- ColumnIndex :: Multivalued ( _multivalued_index) => {
35
- todo ! ( ) ;
27
+ ColumnIndex :: Full => self . values . num_vals ( ) as u32 ,
28
+ ColumnIndex :: Optional ( optional_index) => optional_index. num_rows ( ) ,
29
+ ColumnIndex :: Multivalued ( col_index) => {
30
+ // The multivalued index contains all value start row_id,
31
+ // and one extra value at the end with the overall number of rows.
32
+ col_index. num_vals ( ) - 1
36
33
}
37
34
}
38
35
}
39
36
}
40
37
38
+ impl < T : PartialOrd > Column < T > {
39
+ pub fn first ( & self , row_id : RowId ) -> Option < T > {
40
+ self . values ( row_id) . next ( )
41
+ }
42
+
43
+ pub fn values ( & self , row_id : RowId ) -> impl Iterator < Item = T > + ' _ {
44
+ self . value_row_ids ( row_id)
45
+ . map ( |value_row_id : RowId | self . values . get_val ( value_row_id) )
46
+ }
47
+ }
48
+
41
49
impl < T > Deref for Column < T > {
42
50
type Target = ColumnIndex < ' static > ;
43
51
0 commit comments