-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reuse buffers in parallel parquet reader
- Loading branch information
Showing
7 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use parking_lot::Mutex; | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
|
||
pub struct LowContentionPool<T> { | ||
stack: Vec<Mutex<T>>, | ||
size: AtomicUsize, | ||
} | ||
|
||
impl<T: Default> LowContentionPool<T> { | ||
pub fn new(size: usize) -> Self { | ||
let mut stack = Vec::with_capacity(size); | ||
for _ in 0..size { | ||
stack.push(Mutex::new(T::default())) | ||
} | ||
let size = AtomicUsize::new(size); | ||
|
||
Self { stack, size } | ||
} | ||
|
||
pub fn get(&self) -> T { | ||
let size = self.size.fetch_sub(1, Ordering::AcqRel); | ||
// implementation error if this fails | ||
assert!(size <= self.stack.len()); | ||
let mut locked = self.stack[size - 1].lock(); | ||
std::mem::take(&mut *locked) | ||
} | ||
|
||
pub fn set(&self, value: T) { | ||
let size = self.size.fetch_add(1, Ordering::AcqRel); | ||
// implementation error if this fails | ||
assert!(size <= self.stack.len()); | ||
let mut locked = self.stack[size - 1].lock(); | ||
*locked = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod arena; | ||
pub mod contention_pool; | ||
mod error; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.