diff --git a/ffi/cffi-test.c b/ffi/cffi-test.c index 1415614c8..712a4cb21 100644 --- a/ffi/cffi-test.c +++ b/ffi/cffi-test.c @@ -7,9 +7,15 @@ void visit_callback(void* engine_context, KernelStringSlice path, int64_t size, + const Stats* stats, const DvInfo* dv_info, const CStringMap* partition_values) { - printf("file: %.*s\n", (int)path.len, path.ptr); + printf("file: %.*s (size: %" PRId64 ", num_records:", (int)path.len, path.ptr, size); + if (stats) { + printf("%" PRId64 ")\n", stats->num_records); + } else { + printf(" [no stats])\n"); + } } void visit_data(void* engine_context, diff --git a/ffi/src/scan.rs b/ffi/src/scan.rs index 243945efb..c9fad1770 100644 --- a/ffi/src/scan.rs +++ b/ffi/src/scan.rs @@ -271,10 +271,17 @@ pub unsafe extern "C" fn kernel_scan_data_free(data: Handle, dv_info: &DvInfo, partition_map: &CStringMap, ); @@ -336,16 +343,22 @@ fn rust_callback( context: &mut ContextWrapper, path: &str, size: i64, + kernel_stats: Option, dv_info: DvInfo, partition_values: HashMap, ) { let partition_map = CStringMap { values: partition_values, }; + let stats = kernel_stats.map(|ks| Stats { + num_records: ks.num_records, + tight_bounds: ks.tight_bounds, + }); (context.callback)( context.engine_context, path.into(), size, + stats.as_ref(), &dv_info, &partition_map, ); diff --git a/kernel/src/scan/state.rs b/kernel/src/scan/state.rs index 4c97ab294..93fd9deb2 100644 --- a/kernel/src/scan/state.rs +++ b/kernel/src/scan/state.rs @@ -33,11 +33,16 @@ pub struct DvInfo { deletion_vector: Option, } +fn default_false() -> bool { + false +} + /// Give engines an easy way to consume stats #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct Stats { pub num_records: u64, + #[serde(default = "default_false")] pub tight_bounds: bool, }