Skip to content

Commit

Permalink
refactor: renamed Config::index_cached_segments to num_cached_indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
arindas committed Sep 2, 2023
1 parent 475c32b commit b2b5141
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions benches/commit_log_append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const IN_MEMORY_SEGMENTED_LOG_CONFIG: Config<u32, usize> = Config {
max_index_size: 1048576,
},
initial_index: 0,
index_cached_segments: None,
num_cached_indexes: None,
};

const PERSISTENT_SEGMENTED_LOG_CONFIG: Config<u32, u64> = Config {
Expand All @@ -73,7 +73,7 @@ const PERSISTENT_SEGMENTED_LOG_CONFIG: Config<u32, u64> = Config {
max_index_size: 10000000,
},
initial_index: 0,
index_cached_segments: None,
num_cached_indexes: None,
};

fn increase_rlimit_nofile_soft_limit_to_hard_limit() -> std::io::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions benches/segmented_log_read_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const IN_MEMORY_SEGMENTED_LOG_CONFIG: Config<u32, usize> = Config {
max_index_size: 1048576,
},
initial_index: 0,
index_cached_segments: None,
num_cached_indexes: None,
};

const PERSISTENT_SEGMENTED_LOG_CONFIG: Config<u32, u64> = Config {
Expand All @@ -73,7 +73,7 @@ const PERSISTENT_SEGMENTED_LOG_CONFIG: Config<u32, u64> = Config {
max_index_size: 10000000,
},
initial_index: 0,
index_cached_segments: None,
num_cached_indexes: None,
};

fn increase_rlimit_nofile_soft_limit_to_hard_limit() -> std::io::Result<()> {
Expand Down
16 changes: 8 additions & 8 deletions src/storage/commit_log/segmented_log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ where
pub struct Config<Idx, Size> {
pub segment_config: segment::Config<Size>,
pub initial_index: Idx,
pub index_cached_segments: Option<usize>,
pub num_cached_indexes: Option<usize>,
}

pub struct SegmentedLog<S, M, H, Idx, Size, SERP, SSP> {
Expand Down Expand Up @@ -158,7 +158,7 @@ where
// Cache read segments on init only if index_cached_segments is *not* configured.
// If index_cached_segments is configured, read_segments are to be index_cached
// only when they are inserted into the index cached segments lru cache.
config.index_cached_segments.is_none(),
config.num_cached_indexes.is_none(),
)
.await
.map_err(SegmentedLogError::SegmentError)?,
Expand All @@ -179,7 +179,7 @@ where
read_segments,
config,
segments_with_cached_index: lru_cache_with_capacity(
config.index_cached_segments.unwrap_or(0),
config.num_cached_indexes.unwrap_or(0),
),
segment_storage_provider,
})
Expand Down Expand Up @@ -297,7 +297,7 @@ where
M: Serialize + DeserializeOwned,
{
async fn probe_segment(&mut self, segment_id: Option<usize>) -> Result<(), LogError<S, SERP>> {
if self.config.index_cached_segments.is_none() {
if self.config.num_cached_indexes.is_none() {
return Ok(());
}

Expand Down Expand Up @@ -585,7 +585,7 @@ where
let mut write_segment = take_write_segment!(self)?;
let next_index = write_segment.highest_index();

if let Some(0) = self.config.index_cached_segments {
if let Some(0) = self.config.num_cached_indexes {
drop(write_segment.take_cached_index_records());
}

Expand Down Expand Up @@ -886,7 +886,7 @@ pub(crate) mod test {
)
.unwrap(),
initial_index,
index_cached_segments: None,
num_cached_indexes: None,
};

let mut segmented_log = SegmentedLog::<S, M, H, Idx, S::Size, SERP, SSP>::new(
Expand Down Expand Up @@ -1121,7 +1121,7 @@ pub(crate) mod test {
)
.unwrap(),
initial_index,
index_cached_segments: None,
num_cached_indexes: None,
};

let mut segmented_log = SegmentedLog::<S, M, H, Idx, S::Size, SERP, SSP>::new(
Expand Down Expand Up @@ -1235,7 +1235,7 @@ pub(crate) mod test {
)
.unwrap(),
initial_index,
index_cached_segments: Some(NUM_INDEX_CACHED_SEGMENTS),
num_cached_indexes: Some(NUM_INDEX_CACHED_SEGMENTS),
};

let mut segmented_log =
Expand Down

0 comments on commit b2b5141

Please sign in to comment.