@@ -445,7 +445,9 @@ impl ByteGroupValueViewBuilder {
445
445
let value: & [ u8 ] = arr. value ( row) . as_ref ( ) ;
446
446
447
447
let value_len = value. len ( ) ;
448
- let view = if value_len > 12 {
448
+ let view = if value_len <= 12 {
449
+ make_view ( value, 0 , 0 )
450
+ } else {
449
451
// Ensure big enough block to hold the value firstly
450
452
self . ensure_in_progress_big_enough ( value_len) ;
451
453
@@ -455,8 +457,6 @@ impl ByteGroupValueViewBuilder {
455
457
self . in_progress . extend_from_slice ( value) ;
456
458
457
459
make_view ( value, block_id, offset)
458
- } else {
459
- make_view ( value, 0 , 0 )
460
460
} ;
461
461
462
462
// Append view
@@ -477,6 +477,48 @@ impl ByteGroupValueViewBuilder {
477
477
self . completed . push ( buffer) ;
478
478
}
479
479
}
480
+
481
+ fn equal_to_inner < B > ( & self , lhs_row : usize , array : & ArrayRef , rhs_row : usize ) -> bool
482
+ where
483
+ B : ByteViewType ,
484
+ {
485
+ let array = array. as_byte_view :: < B > ( ) ;
486
+
487
+ // Check if nulls equal firstly
488
+ let exist_null = self . nulls . is_null ( lhs_row) ;
489
+ let input_null = array. is_null ( rhs_row) ;
490
+ if let Some ( result) = nulls_equal_to ( exist_null, input_null) {
491
+ return result;
492
+ }
493
+
494
+ // Otherwise, we need to check their values
495
+ let exist_view = self . views [ lhs_row] ;
496
+ let exist_view_len = exist_view as u32 ;
497
+
498
+ let input_view = array. views ( ) [ rhs_row] ;
499
+ let input_view_len = exist_view as u32 ;
500
+
501
+ // The check logic
502
+ // - Check len equality
503
+ // - If non-inlined, check prefix and then check value in buffer
504
+ // when needed
505
+ // - If inlined, check inlined value
506
+ if exist_view_len != input_view_len {
507
+ return false ;
508
+ }
509
+
510
+ if exist_view_len > 12 {
511
+ let exist_prefix = unsafe { GenericByteViewArray :: < B > :: inline_value ( & exist_view, 4 ) } ;
512
+ let input_prefix = unsafe { GenericByteViewArray :: < B > :: inline_value ( & input_view, 4 ) } ;
513
+
514
+ if exist_prefix != input_prefix {
515
+ return false ;
516
+ }
517
+
518
+ let exist_full: & [ u8 ] = unsafe { array. value_unchecked ( lhs_row) . as_ref ( ) } ;
519
+ let input_full: & [ u8 ] = unsafe { right. value_unchecked ( right_idx) . as_ref ( ) } ;
520
+ }
521
+ }
480
522
}
481
523
482
524
/// Determines if the nullability of the existing and new input array can be used
0 commit comments