@@ -28,12 +28,13 @@ use crate::error::Error::IllegalArgument;
2828use crate :: error:: Result ;
2929use crate :: metadata:: { DataType , RowType } ;
3030use crate :: row:: Decimal ;
31- use crate :: row:: InternalRow ;
3231use crate :: row:: binary:: { BinaryRowFormat , ValueWriter } ;
3332use crate :: row:: binary_map:: FlussMap ;
3433use crate :: row:: compacted:: { CompactedRow , CompactedRowWriter , calculate_bit_set_width_in_bytes} ;
3534use crate :: row:: datum:: { Date , Time , TimestampLtz , TimestampNtz } ;
3635use crate :: row:: field_getter:: FieldGetter ;
36+ use crate :: row:: view:: ArrayView ;
37+ use crate :: row:: { DataGetters , InternalArray , InternalRow } ;
3738use bytes:: Bytes ;
3839use serde:: Serialize ;
3940use std:: fmt;
@@ -768,80 +769,79 @@ impl InternalRow for FlussArray {
768769 fn get_field_count ( & self ) -> usize {
769770 self . size ( )
770771 }
772+ }
771773
774+ impl InternalArray for FlussArray {
775+ fn size ( & self ) -> usize {
776+ FlussArray :: size ( self )
777+ }
778+ }
779+
780+ impl DataGetters for FlussArray {
772781 fn is_null_at ( & self , pos : usize ) -> Result < bool > {
773- Ok ( self . is_null_at ( pos) )
782+ Ok ( FlussArray :: is_null_at ( self , pos) )
774783 }
775784
776785 fn get_boolean ( & self , pos : usize ) -> Result < bool > {
777- self . get_boolean ( pos)
786+ FlussArray :: get_boolean ( self , pos)
778787 }
779788 fn get_byte ( & self , pos : usize ) -> Result < i8 > {
780- self . get_byte ( pos)
789+ FlussArray :: get_byte ( self , pos)
781790 }
782791 fn get_short ( & self , pos : usize ) -> Result < i16 > {
783- self . get_short ( pos)
792+ FlussArray :: get_short ( self , pos)
784793 }
785794 fn get_int ( & self , pos : usize ) -> Result < i32 > {
786- self . get_int ( pos)
795+ FlussArray :: get_int ( self , pos)
787796 }
788797 fn get_long ( & self , pos : usize ) -> Result < i64 > {
789- self . get_long ( pos)
798+ FlussArray :: get_long ( self , pos)
790799 }
791800 fn get_float ( & self , pos : usize ) -> Result < f32 > {
792- self . get_float ( pos)
801+ FlussArray :: get_float ( self , pos)
793802 }
794803 fn get_double ( & self , pos : usize ) -> Result < f64 > {
795- self . get_double ( pos)
804+ FlussArray :: get_double ( self , pos)
796805 }
797806
798807 fn get_char ( & self , pos : usize , _length : usize ) -> Result < & str > {
799- self . get_string ( pos)
808+ FlussArray :: get_string ( self , pos)
800809 }
801-
802810 fn get_string ( & self , pos : usize ) -> Result < & str > {
803- self . get_string ( pos)
811+ FlussArray :: get_string ( self , pos)
804812 }
805813
806814 fn get_decimal ( & self , pos : usize , precision : usize , scale : usize ) -> Result < Decimal > {
807- self . get_decimal ( pos, precision as u32 , scale as u32 )
815+ FlussArray :: get_decimal ( self , pos, precision as u32 , scale as u32 )
808816 }
809817
810818 fn get_date ( & self , pos : usize ) -> Result < Date > {
811- self . get_date ( pos)
819+ FlussArray :: get_date ( self , pos)
812820 }
813821 fn get_time ( & self , pos : usize ) -> Result < Time > {
814- self . get_time ( pos)
822+ FlussArray :: get_time ( self , pos)
815823 }
816824 fn get_timestamp_ntz ( & self , pos : usize , precision : u32 ) -> Result < TimestampNtz > {
817- self . get_timestamp_ntz ( pos, precision)
825+ FlussArray :: get_timestamp_ntz ( self , pos, precision)
818826 }
819827 fn get_timestamp_ltz ( & self , pos : usize , precision : u32 ) -> Result < TimestampLtz > {
820- self . get_timestamp_ltz ( pos, precision)
828+ FlussArray :: get_timestamp_ltz ( self , pos, precision)
821829 }
822830
823831 fn get_binary ( & self , pos : usize , _length : usize ) -> Result < & [ u8 ] > {
824- self . get_binary ( pos)
832+ FlussArray :: get_binary ( self , pos)
825833 }
826-
827834 fn get_bytes ( & self , pos : usize ) -> Result < & [ u8 ] > {
828- self . get_binary ( pos)
835+ FlussArray :: get_binary ( self , pos)
829836 }
830837
831- fn get_array ( & self , pos : usize ) -> Result < FlussArray > {
832- self . get_array ( pos)
833- }
834-
835- fn get_map ( & self , pos : usize ) -> Result < FlussMap > {
836- // FlussArray carries no schema; nested map reads must go through the
837- // inherent FlussArray::get_map(pos, key_type, value_type).
838- Err ( IllegalArgument {
839- message : format ! (
840- "InternalRow::get_map is not supported on FlussArray (pos {pos}); \
841- use FlussArray::get_map(pos, key_type, value_type) directly"
842- ) ,
843- } )
838+ fn get_array ( & self , pos : usize ) -> Result < ArrayView < ' _ > > {
839+ Ok ( ArrayView :: Binary ( FlussArray :: get_array ( self , pos) ?) )
844840 }
841+ // get_map and get_row keep the trait default (error) — `FlussArray`
842+ // carries no schema, so trait-style schema-free reads can't construct
843+ // a binary `FlussMap`/`CompactedRow`. Use the inherent
844+ // `FlussArray::get_map` / `FlussArray::get_row` with explicit types.
845845}
846846
847847#[ cfg( test) ]
@@ -852,6 +852,23 @@ mod tests {
852852 use crate :: row:: compacted:: CompactedRowWriter ;
853853 use crate :: row:: { Datum , GenericRow } ;
854854
855+ #[ test]
856+ fn fluss_array_dispatches_through_internal_array_trait ( ) {
857+ let mut writer = FlussArrayWriter :: new ( 3 , & DataTypes :: int ( ) ) ;
858+ writer. write_int ( 0 , 10 ) ;
859+ writer. set_null_at ( 1 ) ;
860+ writer. write_int ( 2 , 30 ) ;
861+ let arr = writer. complete ( ) . unwrap ( ) ;
862+
863+ let view: & dyn InternalArray = & arr;
864+ assert_eq ! ( view. size( ) , 3 ) ;
865+ assert ! ( !view. is_null_at( 0 ) . unwrap( ) ) ;
866+ assert ! ( view. is_null_at( 1 ) . unwrap( ) ) ;
867+ assert ! ( !view. is_null_at( 2 ) . unwrap( ) ) ;
868+ assert_eq ! ( view. get_int( 0 ) . unwrap( ) , 10 ) ;
869+ assert_eq ! ( view. get_int( 2 ) . unwrap( ) , 30 ) ;
870+ }
871+
855872 #[ test]
856873 fn test_header_calculation ( ) {
857874 assert_eq ! ( calculate_header_in_bytes( 0 ) , 4 ) ;
@@ -1169,7 +1186,7 @@ mod tests {
11691186 let r1_tags = r1. get_array ( 0 ) . unwrap ( ) ;
11701187 assert_eq ! ( r1_tags. size( ) , 3 ) ;
11711188 assert_eq ! ( r1_tags. get_string( 0 ) . unwrap( ) , "x" ) ;
1172- assert ! ( r1_tags. is_null_at( 1 ) ) ;
1189+ assert ! ( r1_tags. is_null_at( 1 ) . unwrap ( ) ) ;
11731190 assert_eq ! ( r1_tags. get_string( 2 ) . unwrap( ) , "z" ) ;
11741191 }
11751192
@@ -1207,7 +1224,7 @@ mod tests {
12071224 let bytes = writer. to_bytes ( ) ;
12081225
12091226 let outer_compacted = CompactedRow :: from_bytes ( outer_row_type, & bytes) ;
1210- let recovered_arr = outer_compacted. get_array ( 0 ) . unwrap ( ) ;
1227+ let recovered_arr = outer_compacted. get_array ( 0 ) . unwrap ( ) . expect_binary ( ) ;
12111228 assert_eq ! ( recovered_arr. size( ) , 2 ) ;
12121229
12131230 let recovered_r0 = recovered_arr. get_row ( 0 , inner_row_type) . unwrap ( ) ;
0 commit comments