Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Message cache can be mutated with a shared reference #1781

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vortex-file/src/read/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ pub struct LayoutMessageCache {
}

impl LayoutMessageCache {
pub fn remove(&mut self, path: &[LayoutPartId]) -> Option<Bytes> {
pub fn remove(&self, path: &[LayoutPartId]) -> Option<Bytes> {
self.cache
.write()
.map_err(|_| vortex_err!("Poisoned cache"))
.vortex_expect("poisoned")
.remove(path)
}

pub fn set(&mut self, path: MessageId, value: Bytes) {
pub fn set(&self, path: MessageId, value: Bytes) {
self.cache
.write()
.map_err(|_| vortex_err!("Poisoned cache"))
.vortex_expect("poisoned")
.insert(path, value);
}

pub fn set_many<I: IntoIterator<Item = (MessageId, Bytes)>>(&mut self, iter: I) {
pub fn set_many<I: IntoIterator<Item = (MessageId, Bytes)>>(&self, iter: I) {
let mut guard = self
.cache
.write()
Expand Down
4 changes: 2 additions & 2 deletions vortex-file/src/read/layouts/test_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn read_layout_data(
layout: &dyn LayoutReader,
buf: &Bytes,
selector: &RowMask,
mut msgs: LayoutMessageCache,
msgs: LayoutMessageCache,
) -> Option<ArrayData> {
while let Some(rr) = layout.poll_read(selector, &msgs).unwrap() {
match rr {
Expand All @@ -45,7 +45,7 @@ pub fn read_filters(
layout: &dyn LayoutReader,
buf: &Bytes,
selector: &RowMask,
mut msgs: LayoutMessageCache,
msgs: LayoutMessageCache,
) -> Option<RowMask> {
while let Some(rr) = layout.poll_read(selector, &msgs).unwrap() {
match rr {
Expand Down
Loading