Crates.io | sendable-swapvec |
lib.rs | sendable-swapvec |
version | 0.4.3 |
source | src |
created_at | 2024-11-09 04:44:56.432713 |
updated_at | 2024-11-09 04:44:56.432713 |
description | A Vector swapping to disk after exceeding a given length |
homepage | |
repository | https://github.com/julianbuettner/swapvec |
max_upload_size | |
id | 1441819 |
size | 38,657 |
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