Crates.io | swapvec |
lib.rs | swapvec |
version | 0.4.2 |
source | src |
created_at | 2023-04-14 08:44:06.817847 |
updated_at | 2023-11-29 16:47:46.343539 |
description | A Vector swapping to disk after exceeding a given length |
homepage | |
repository | https://github.com/julianbuettner/swapvec |
max_upload_size | |
id | 839032 |
size | 37,941 |
A vector which swaps to disk when exceeding a certain length.
Useful if you do not want to use a queue, but first collecting all data and then consuming it.
Imagine multiple threads slowly producing giant vectors of data, passing it to a single consumer later on.
Or a CSV upload of multiple gigabytes to an HTTP server, in which you want to validate every line while uploading, without directly starting a Database transaction or keeping everything in memory.
T: Serialize + Deserialize + Clone
Result
String
)Compression
currently does not compress. It is there to keep the API stable.use swapvec::SwapVec;
let iterator = (0..9).into_iter();
let mut much_data = SwapVec::default();
// Starts using disk for big iterators
much_data.consume(iterator).unwrap();
for value in much_data.into_iter() {
println!("Read back: {}", value.unwrap());
}
Currently there is only one simple example, doing some basic operations and getting metrics like getting the batches/bytes written to file. . Run it with
cargo run --example demo