33
44use std:: fmt:: Debug ;
55use std:: hash:: Hash ;
6+ use std:: hash:: Hasher ;
67
78use itertools:: Itertools ;
89use prost:: Message ;
@@ -63,6 +64,25 @@ pub struct ALPRDMetadata {
6364 patches : Option < PatchesMetadata > ,
6465}
6566
67+ impl ArrayHash for ALPRDData {
68+ fn array_hash < H : Hasher > ( & self , state : & mut H , precision : Precision ) {
69+ self . left_parts_dictionary . array_hash ( state, precision) ;
70+ self . right_bit_width . hash ( state) ;
71+ self . patch_offset . hash ( state) ;
72+ self . patch_offset_within_chunk . hash ( state) ;
73+ }
74+ }
75+
76+ impl ArrayEq for ALPRDData {
77+ fn array_eq ( & self , other : & Self , precision : Precision ) -> bool {
78+ self . left_parts_dictionary
79+ . array_eq ( & other. left_parts_dictionary , precision)
80+ && self . right_bit_width == other. right_bit_width
81+ && self . patch_offset == other. patch_offset
82+ && self . patch_offset_within_chunk == other. patch_offset_within_chunk
83+ }
84+ }
85+
6686impl VTable for ALPRD {
6787 type ArrayData = ALPRDData ;
6888
@@ -83,21 +103,6 @@ impl VTable for ALPRD {
83103 data. validate_against_outer ( dtype, len, slots)
84104 }
85105
86- fn array_hash < H : std:: hash:: Hasher > ( data : & ALPRDData , state : & mut H , precision : Precision ) {
87- data. left_parts_dictionary . array_hash ( state, precision) ;
88- data. right_bit_width . hash ( state) ;
89- data. patch_offset . hash ( state) ;
90- data. patch_offset_within_chunk . hash ( state) ;
91- }
92-
93- fn array_eq ( data : & ALPRDData , other : & ALPRDData , precision : Precision ) -> bool {
94- data. left_parts_dictionary
95- . array_eq ( & other. left_parts_dictionary , precision)
96- && data. right_bit_width == other. right_bit_width
97- && data. patch_offset == other. patch_offset
98- && data. patch_offset_within_chunk == other. patch_offset_within_chunk
99- }
100-
101106 fn nbuffers ( _array : ArrayView < ' _ , Self > ) -> usize {
102107 0
103108 }
@@ -531,14 +536,12 @@ impl ALPRDData {
531536 /// it constructs it from parts.
532537 pub ( crate ) unsafe fn new_unchecked (
533538 _dtype : DType ,
534- left_parts : ArrayRef ,
539+ _left_parts : ArrayRef ,
535540 left_parts_dictionary : Buffer < u16 > ,
536- right_parts : ArrayRef ,
541+ _right_parts : ArrayRef ,
537542 right_bit_width : u8 ,
538543 left_parts_patches : Option < Patches > ,
539544 ) -> Self {
540- drop ( left_parts) ;
541- drop ( right_parts) ;
542545 Self {
543546 patch_offset : left_parts_patches. as_ref ( ) . map ( Patches :: offset) ,
544547 patch_offset_within_chunk : left_parts_patches
@@ -631,11 +634,11 @@ fn patches_from_slots(
631634
632635pub trait ALPRDArrayExt : TypedArrayRef < ALPRD > {
633636 fn left_parts ( & self ) -> & ArrayRef {
634- left_parts_from_slots ( self . slots_ref ( ) )
637+ left_parts_from_slots ( self . as_ref ( ) . slots ( ) )
635638 }
636639
637640 fn right_parts ( & self ) -> & ArrayRef {
638- right_parts_from_slots ( self . slots_ref ( ) )
641+ right_parts_from_slots ( self . as_ref ( ) . slots ( ) )
639642 }
640643
641644 fn right_bit_width ( & self ) -> u8 {
@@ -644,7 +647,7 @@ pub trait ALPRDArrayExt: TypedArrayRef<ALPRD> {
644647
645648 fn left_parts_patches ( & self ) -> Option < Patches > {
646649 patches_from_slots (
647- self . slots_ref ( ) ,
650+ self . as_ref ( ) . slots ( ) ,
648651 self . patch_offset ,
649652 self . patch_offset_within_chunk ,
650653 self . as_ref ( ) . len ( ) ,
0 commit comments