Skip to content

Commit

Permalink
index: add wrapper functions to DefaultReadonlyIndex to remove pub(su…
Browse files Browse the repository at this point in the history
…per) field
  • Loading branch information
yuja committed Dec 12, 2023
1 parent c0a12a7 commit 2abbb63
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/default_index/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,6 @@ impl MutableIndex for DefaultMutableIndex {
.as_any()
.downcast_ref::<DefaultReadonlyIndex>()
.expect("index to merge in must be a DefaultReadonlyIndex");
self.0.merge_in(other.0.clone());
self.0.merge_in(other.as_segment().clone());
}
}
10 changes: 9 additions & 1 deletion lib/src/default_index/readonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,17 @@ impl IndexSegment for ReadonlyIndexSegment {

/// Commit index backend which stores data on local disk.
#[derive(Debug)]
pub struct DefaultReadonlyIndex(pub(super) Arc<ReadonlyIndexSegment>);
pub struct DefaultReadonlyIndex(Arc<ReadonlyIndexSegment>);

impl DefaultReadonlyIndex {
pub(super) fn from_segment(segment: Arc<ReadonlyIndexSegment>) -> Self {
DefaultReadonlyIndex(segment)
}

pub(super) fn as_segment(&self) -> &Arc<ReadonlyIndexSegment> {
&self.0
}

pub fn as_composite(&self) -> CompositeIndex {
self.0.as_composite()
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/default_index/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl IndexStore for DefaultIndexStore {
} else {
self.index_at_operation(store, op).unwrap()
};
Box::new(DefaultReadonlyIndex(index_segment))
Box::new(DefaultReadonlyIndex::from_segment(index_segment))
}

fn write_index(
Expand All @@ -257,6 +257,6 @@ impl IndexStore for DefaultIndexStore {
"Failed to associate commit index file with a operation {op_id:?}: {err}"
))
})?;
Ok(Box::new(DefaultReadonlyIndex(index_segment)))
Ok(Box::new(DefaultReadonlyIndex::from_segment(index_segment)))
}
}

0 comments on commit 2abbb63

Please sign in to comment.