@@ -1148,6 +1148,86 @@ pub mod primitive {
11481148 }
11491149 }
11501150
1151+ pub use chars:: { Chars } ;
1152+ /// Columnar store for `char`, stored as a `u32`.
1153+ mod chars {
1154+
1155+ use crate :: { Clear , Columnar , Container , Len , Index , IndexAs , Push , HeapSize } ;
1156+ use crate :: common:: PushIndexAs ;
1157+
1158+ type Encoded = u32 ;
1159+
1160+ #[ derive( Copy , Clone , Default ) ]
1161+ pub struct Chars < CV = Vec < Encoded > > { pub values : CV }
1162+
1163+ impl Columnar for char {
1164+ fn into_owned < ' a > ( other : crate :: Ref < ' a , Self > ) -> Self { other }
1165+ type Container = Chars ;
1166+ }
1167+
1168+ impl < CV : PushIndexAs < Encoded > > Container for Chars < CV > {
1169+ type Ref < ' a > = char ;
1170+ type Borrowed < ' a > = Chars < CV :: Borrowed < ' a > > where CV : ' a ;
1171+ fn borrow < ' a > ( & ' a self ) -> Self :: Borrowed < ' a > {
1172+ Chars { values : self . values . borrow ( ) }
1173+ }
1174+ #[ inline( always) ]
1175+ fn reborrow < ' b , ' a : ' b > ( thing : Self :: Borrowed < ' a > ) -> Self :: Borrowed < ' b > where CV : ' a {
1176+ Chars { values : CV :: reborrow ( thing. values ) }
1177+ }
1178+ #[ inline( always) ]
1179+ fn reborrow_ref < ' b , ' a : ' b > ( thing : Self :: Ref < ' a > ) -> Self :: Ref < ' b > where Self : ' a { thing }
1180+
1181+ #[ inline( always) ]
1182+ fn extend_from_self ( & mut self , other : Self :: Borrowed < ' _ > , range : std:: ops:: Range < usize > ) {
1183+ self . values . extend_from_self ( other. values , range)
1184+ }
1185+
1186+ fn reserve_for < ' a , I > ( & mut self , selves : I ) where Self : ' a , I : Iterator < Item = Self :: Borrowed < ' a > > + Clone {
1187+ self . values . reserve_for ( selves. map ( |x| x. values ) )
1188+ }
1189+ }
1190+
1191+ impl < CV : Len > Len for Chars < CV > { fn len ( & self ) -> usize { self . values . len ( ) } }
1192+ impl < CV : IndexAs < Encoded > > Index for Chars < CV > {
1193+ type Ref = char ;
1194+ #[ inline( always) ] fn get ( & self , index : usize ) -> Self :: Ref { char:: from_u32 ( self . values . index_as ( index) ) . unwrap ( ) }
1195+ }
1196+ impl < CV : IndexAs < Encoded > > Index for & Chars < CV > {
1197+ type Ref = char ;
1198+ #[ inline( always) ] fn get ( & self , index : usize ) -> Self :: Ref { char:: from_u32 ( self . values . index_as ( index) ) . unwrap ( ) }
1199+ }
1200+ impl < CV : for < ' a > Push < & ' a Encoded > > Push < char > for Chars < CV > {
1201+ #[ inline]
1202+ fn push ( & mut self , item : char ) { self . values . push ( & u32:: from ( item) ) }
1203+ }
1204+ impl Push < & char > for Chars {
1205+ #[ inline]
1206+ fn push ( & mut self , item : & char ) { self . values . push ( u32:: from ( * item) ) }
1207+ }
1208+ impl < CV : Clear > Clear for Chars < CV > { fn clear ( & mut self ) { self . values . clear ( ) } }
1209+
1210+ impl < CV : HeapSize > HeapSize for Chars < CV > {
1211+ fn heap_size ( & self ) -> ( usize , usize ) {
1212+ self . values . heap_size ( )
1213+ }
1214+ }
1215+
1216+ impl < ' a , CV : crate :: AsBytes < ' a > > crate :: AsBytes < ' a > for Chars < CV > {
1217+ #[ inline( always) ]
1218+ fn as_bytes ( & self ) -> impl Iterator < Item =( u64 , & ' a [ u8 ] ) > {
1219+ self . values . as_bytes ( )
1220+ }
1221+ }
1222+
1223+ impl < ' a , CV : crate :: FromBytes < ' a > > crate :: FromBytes < ' a > for Chars < CV > {
1224+ #[ inline( always) ]
1225+ fn from_bytes ( bytes : & mut impl Iterator < Item =& ' a [ u8 ] > ) -> Self {
1226+ Self { values : CV :: from_bytes ( bytes) }
1227+ }
1228+ }
1229+ }
1230+
11511231 pub use larges:: { U128s , I128s } ;
11521232 /// Columnar stores for `u128` and `i128`, stored as [u8; 16] bits.
11531233 mod larges {
0 commit comments