11use fsst:: { Decompressor , Symbol } ;
2- use vortex_array:: arrays:: VarBinEncoding ;
2+ use vortex_array:: arrays:: VarBinArray ;
33use vortex_array:: stats:: { ArrayStats , StatsSetRef } ;
44use vortex_array:: variants:: { BinaryArrayTrait , Utf8ArrayTrait } ;
5- use vortex_array:: vtable:: { EncodingVTable , VTableRef } ;
5+ use vortex_array:: vtable:: VTableRef ;
66use vortex_array:: {
77 Array , ArrayImpl , ArrayRef , ArrayStatisticsImpl , ArrayValidityImpl , ArrayVariantsImpl ,
88 Encoding , SerdeMetadata ,
99} ;
1010use vortex_buffer:: Buffer ;
1111use vortex_dtype:: DType ;
12- use vortex_error:: { VortexResult , vortex_bail} ;
12+ use vortex_error:: { VortexResult , vortex_bail, vortex_err } ;
1313use vortex_mask:: Mask ;
1414
1515use crate :: serde:: FSSTMetadata ;
@@ -19,7 +19,7 @@ pub struct FSSTArray {
1919 dtype : DType ,
2020 symbols : Buffer < Symbol > ,
2121 symbol_lengths : Buffer < u8 > ,
22- codes : ArrayRef ,
22+ codes : VarBinArray ,
2323 /// Lengths of the original values before compression, can be compressed.
2424 uncompressed_lengths : ArrayRef ,
2525 stats_set : ArrayStats ,
@@ -44,7 +44,7 @@ impl FSSTArray {
4444 dtype : DType ,
4545 symbols : Buffer < Symbol > ,
4646 symbol_lengths : Buffer < u8 > ,
47- codes : ArrayRef ,
47+ codes : VarBinArray ,
4848 uncompressed_lengths : ArrayRef ,
4949 ) -> VortexResult < Self > {
5050 // Check: symbols must not have length > MAX_CODE
@@ -63,13 +63,6 @@ impl FSSTArray {
6363 vortex_bail ! ( InvalidArgument : "uncompressed_lengths must have integer type and cannot be nullable, found {}" , uncompressed_lengths. dtype( ) ) ;
6464 }
6565
66- if codes. encoding ( ) != VarBinEncoding . id ( ) {
67- vortex_bail ! (
68- InvalidArgument : "codes must have varbin encoding, was {}" ,
69- codes. encoding( )
70- ) ;
71- }
72-
7366 // Check: strings must be a Binary array.
7467 if !matches ! ( codes. dtype( ) , DType :: Binary ( _) ) {
7568 vortex_bail ! ( InvalidArgument : "codes array must be DType::Binary type" ) ;
@@ -96,7 +89,7 @@ impl FSSTArray {
9689 }
9790
9891 /// Access the codes array
99- pub fn codes ( & self ) -> & ArrayRef {
92+ pub fn codes ( & self ) -> & VarBinArray {
10093 & self . codes
10194 }
10295
@@ -142,7 +135,11 @@ impl ArrayImpl for FSSTArray {
142135 }
143136
144137 fn _with_children ( & self , children : & [ ArrayRef ] ) -> VortexResult < Self > {
145- let codes = children[ 0 ] . clone ( ) ;
138+ let codes = children[ 0 ]
139+ . as_any ( )
140+ . downcast_ref :: < VarBinArray > ( )
141+ . ok_or_else ( || vortex_err ! ( "FSSTArray codes must be a VarBinArray" ) ) ?
142+ . clone ( ) ;
146143 let uncompressed_lengths = children[ 1 ] . clone ( ) ;
147144
148145 Self :: try_new (
0 commit comments