add write_to_cache to descriptor

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-25 02:06:20 +00:00
parent 3b0195e6b3
commit 29a19ba437
2 changed files with 7 additions and 1 deletions

View file

@ -77,20 +77,24 @@ fn descriptor_cf_options(
fn set_table_options(opts: &mut Options, desc: &Descriptor, cache: Option<&Cache>) -> Result {
let mut table = table_options(desc, cache.is_some());
if let Some(cache) = cache {
table.set_block_cache(cache);
} else {
table.disable_cache();
}
let prepopulate = if desc.write_to_cache { "kFlushOnly" } else { "kDisable" };
let string = format!(
"{{block_based_table_factory={{num_file_reads_for_auto_readahead={0};\
max_auto_readahead_size={1};initial_auto_readahead_size={2};\
enable_index_compression={3}}}}}",
enable_index_compression={3};prepopulate_block_cache={4}}}}}",
desc.auto_readahead_thresh,
desc.auto_readahead_max,
desc.auto_readahead_init,
desc.compressed_index,
prepopulate,
);
opts.set_options_from_string(&string).map_err(map_err)?;

View file

@ -40,6 +40,7 @@ pub(crate) struct Descriptor {
pub(crate) bottommost_level: Option<i32>,
pub(crate) block_index_hashing: Option<bool>,
pub(crate) cache_shards: u32,
pub(crate) write_to_cache: bool,
pub(crate) auto_readahead_thresh: u32,
pub(crate) auto_readahead_init: usize,
pub(crate) auto_readahead_max: usize,
@ -71,6 +72,7 @@ pub(crate) static BASE: Descriptor = Descriptor {
bottommost_level: Some(SENTINEL_COMPRESSION_LEVEL),
block_index_hashing: None,
cache_shards: 64,
write_to_cache: false,
auto_readahead_thresh: 0,
auto_readahead_init: 1024 * 16,
auto_readahead_max: 1024 * 1024 * 2,