@@ -83,7 +83,7 @@ use num_derive::FromPrimitive;
8383use num_traits:: FromPrimitive ;
8484use size_of:: SizeOf ;
8585
86- /// Increment this on each incompatible change .
86+ /// Increment this when the base file format itself changes incompatibly .
8787///
8888/// Increment this on each incompatible change.
8989///
@@ -93,11 +93,17 @@ use size_of::SizeOf;
9393/// - v4: Tup None optimizations.
9494/// - v5: Change in representation for Timestamp, ShortInterval
9595///
96- /// When a new version is created, make sure to generate new golden
97- /// files for it in crate `storage-test-compat` to check for
98- /// backwards compatibility.
96+ /// Roaring bitmap filters are gated by
97+ /// [`INCOMPATIBLE_FEATURE_ROARING_FILTERS`] instead of a version bump, so
98+ /// Bloom-only files remain readable by older binaries that support v5.
99+ ///
100+ /// When a new version is created, make sure to generate new golden files for
101+ /// it in crate `storage-test-compat` to check for backwards compatibility.
99102pub const VERSION_NUMBER : u32 = 5 ;
100103
104+ /// Oldest layer file format version this binary can read.
105+ pub const MIN_SUPPORTED_VERSION : u32 = 5 ;
106+
101107/// Magic number for data blocks.
102108pub const DATA_BLOCK_MAGIC : [ u8 ; 4 ] = * b"LFDB" ;
103109
@@ -204,8 +210,8 @@ pub struct FileTrailer {
204210 ///
205211 /// If any of these bits are set, the version number must be at least 3.
206212 ///
207- /// No incompatible features are currently defined. This bitmap is for
208- /// future expansion .
213+ /// One incompatible feature is set:
214+ /// [`INCOMPATIBLE_FEATURE_ROARING_FILTERS`] .
209215 pub incompatible_features : u64 ,
210216
211217 /// File offset in bytes of the filter block.
@@ -246,6 +252,17 @@ impl FileTrailer {
246252 ( self . compatible_features & feature) != 0
247253 }
248254
255+ /// Returns the unknown incompatible features, if any.
256+ pub fn unknown_incompatible_features ( & self ) -> Option < u64 > {
257+ let unknown_incompatible_features =
258+ self . incompatible_features & !INCOMPATIBLE_FEATURE_ROARING_FILTERS ;
259+ if unknown_incompatible_features != 0 {
260+ Some ( unknown_incompatible_features)
261+ } else {
262+ None
263+ }
264+ }
265+
249266 /// Returns true if this file trailer has a 64-bit filter.
250267 pub fn has_filter64 ( & self ) -> bool {
251268 self . has_compatible_feature ( COMPATIBLE_FEATURE_FILTER64 )
@@ -262,6 +279,10 @@ pub const COMPATIBLE_FEATURE_FILTER64: u64 = 1 << 0;
262279/// deserialized as if its value is 0. Conversely, old readers will simply ignore the field.
263280pub const COMPATIBLE_FEATURE_NEGATIVE_WEIGHT_COUNT : u64 = 1 << 1 ;
264281
282+ /// Bit set to 1 in [FileTrailer::incompatible_features] if the file contains
283+ /// roaring bitmap membership filter blocks.
284+ pub const INCOMPATIBLE_FEATURE_ROARING_FILTERS : u64 = 1 << 0 ;
285+
265286/// Information about a column.
266287///
267288/// Embedded inside the [`FileTrailer`] block.
0 commit comments