@@ -344,13 +344,21 @@ enum StringInputArray<'a> {
344344 Utf8View ( & ' a StringViewArray ) ,
345345}
346346
347+ macro_rules! dispatch_string_input_array {
348+ ( $self: expr, $array: ident => $expr: expr) => {
349+ match $self {
350+ Self :: Utf8 ( $array) => $expr,
351+ Self :: LargeUtf8 ( $array) => $expr,
352+ Self :: Utf8View ( $array) => $expr,
353+ }
354+ } ;
355+ }
356+
347357impl < ' a > StringInputArray < ' a > {
348358 fn sample_non_null_len ( & self ) -> Option < usize > {
349- match self {
350- Self :: Utf8 ( array) => array. iter ( ) . flatten ( ) . next ( ) . map ( str:: len) ,
351- Self :: LargeUtf8 ( array) => array. iter ( ) . flatten ( ) . next ( ) . map ( str:: len) ,
352- Self :: Utf8View ( array) => array. iter ( ) . flatten ( ) . next ( ) . map ( str:: len) ,
353- }
359+ dispatch_string_input_array ! ( self , array => {
360+ array. iter( ) . flatten( ) . next( ) . map( str :: len)
361+ } )
354362 }
355363
356364 fn try_new ( array : & ' a ArrayRef ) -> Result < Self > {
@@ -363,17 +371,9 @@ impl<'a> StringInputArray<'a> {
363371 }
364372
365373 fn append_rows ( & self , group_indices : & [ usize ] ) -> Vec < ( u32 , u32 ) > {
366- match self {
367- Self :: Utf8 ( array) => {
368- StringAggGroupsAccumulator :: append_rows_typed ( array, group_indices)
369- }
370- Self :: LargeUtf8 ( array) => {
371- StringAggGroupsAccumulator :: append_rows_typed ( array, group_indices)
372- }
373- Self :: Utf8View ( array) => {
374- StringAggGroupsAccumulator :: append_rows_typed ( array, group_indices)
375- }
376- }
374+ dispatch_string_input_array ! ( self , array => {
375+ StringAggGroupsAccumulator :: append_rows_typed( array, group_indices)
376+ } )
377377 }
378378
379379 fn append_materialized (
@@ -382,26 +382,14 @@ impl<'a> StringInputArray<'a> {
382382 group_indices : & [ usize ] ,
383383 delimiter : & str ,
384384 ) -> usize {
385- match self {
386- Self :: Utf8 ( array) => StringAggGroupsAccumulator :: append_batch_typed (
387- values,
388- array. iter ( ) ,
389- group_indices,
390- delimiter,
391- ) ,
392- Self :: LargeUtf8 ( array) => StringAggGroupsAccumulator :: append_batch_typed (
393- values,
394- array. iter ( ) ,
395- group_indices,
396- delimiter,
397- ) ,
398- Self :: Utf8View ( array) => StringAggGroupsAccumulator :: append_batch_typed (
385+ dispatch_string_input_array ! ( self , array => {
386+ StringAggGroupsAccumulator :: append_batch_typed(
399387 values,
400388 array. iter( ) ,
401389 group_indices,
402390 delimiter,
403- ) ,
404- }
391+ )
392+ } )
405393 }
406394
407395 fn append_batch_values (
@@ -411,33 +399,15 @@ impl<'a> StringInputArray<'a> {
411399 delimiter : & str ,
412400 emit_groups : usize ,
413401 ) {
414- match self {
415- Self :: Utf8 ( array ) => StringAggGroupsAccumulator :: append_batch_values_typed (
402+ dispatch_string_input_array ! ( self , array => {
403+ StringAggGroupsAccumulator :: append_batch_values_typed(
416404 values,
417405 entries,
418406 array,
419407 delimiter,
420408 emit_groups,
421- ) ,
422- Self :: LargeUtf8 ( array) => {
423- StringAggGroupsAccumulator :: append_batch_values_typed (
424- values,
425- entries,
426- array,
427- delimiter,
428- emit_groups,
429- )
430- }
431- Self :: Utf8View ( array) => {
432- StringAggGroupsAccumulator :: append_batch_values_typed (
433- values,
434- entries,
435- array,
436- delimiter,
437- emit_groups,
438- )
439- }
440- }
409+ )
410+ } )
441411 }
442412}
443413
0 commit comments