@@ -16,6 +16,16 @@ use crate::schema::DataType;
1616use crate :: utils:: require;
1717use crate :: { DeltaResult , Error , StorageHandler } ;
1818
19+ /// Magic number for portable RoaringBitmap serialization format.
20+ /// This is the standard format defined in the RoaringBitmap Specification
21+ /// and is used by Delta for deletion vector storage.
22+ /// See: https://github.com/delta-io/delta/blob/master/PROTOCOL.md#deletion-vector-format
23+ const ROARING_BITMAP_PORTABLE_MAGIC : u32 = 1681511377 ;
24+
25+ /// Magic number for native RoaringBitmap serialization format.
26+ /// This format is reserved for future use and not currently supported.
27+ const ROARING_BITMAP_NATIVE_MAGIC : u32 = 1681511376 ;
28+
1929#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
2030#[ cfg_attr( test, derive( serde:: Serialize , serde:: Deserialize ) ) ]
2131pub enum DeletionVectorStorageType {
@@ -218,9 +228,11 @@ impl DeletionVectorDescriptor {
218228 . map_err ( |_| Error :: deletion_vector ( "Failed to decode DV" ) ) ?;
219229 let magic = slice_to_u32 ( & byte_slice[ 0 ..4 ] , Endian :: Little ) ?;
220230 match magic {
221- 1681511377 => RoaringTreemap :: deserialize_from ( & byte_slice[ 4 ..] )
222- . map_err ( |err| Error :: DeletionVector ( err. to_string ( ) ) ) ,
223- 1681511376 => Err ( Error :: deletion_vector (
231+ ROARING_BITMAP_PORTABLE_MAGIC => {
232+ RoaringTreemap :: deserialize_from ( & byte_slice[ 4 ..] )
233+ . map_err ( |err| Error :: DeletionVector ( err. to_string ( ) ) )
234+ }
235+ ROARING_BITMAP_NATIVE_MAGIC => Err ( Error :: deletion_vector (
224236 "Native serialization in inline bitmaps is not yet supported" ,
225237 ) ) ,
226238 _ => Err ( Error :: DeletionVector ( format ! ( "Invalid magic {magic}" ) ) ) ,
@@ -302,7 +314,7 @@ impl DeletionVectorDescriptor {
302314 ) ;
303315 let magic = read_u32 ( & mut cursor, Endian :: Little ) ?;
304316 require ! (
305- magic == 1681511377 ,
317+ magic == ROARING_BITMAP_PORTABLE_MAGIC ,
306318 Error :: DeletionVector ( format!( "Invalid magic {magic} for {path}" ) )
307319 ) ;
308320
@@ -539,6 +551,12 @@ mod tests {
539551 assert_eq ! ( dv_url, example. absolute_path( & parent) . unwrap( ) . unwrap( ) ) ;
540552 }
541553
554+ #[ test]
555+ fn test_magic_number_constants ( ) {
556+ assert_eq ! ( ROARING_BITMAP_PORTABLE_MAGIC , 1681511377 ) ;
557+ assert_eq ! ( ROARING_BITMAP_NATIVE_MAGIC , 1681511376 ) ;
558+ }
559+
542560 #[ test]
543561 fn test_inline_read ( ) {
544562 let inline = dv_inline ( ) ;
0 commit comments