Skip to content
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
30 changes: 20 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion kiru-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# kiru/Cargo.toml
[package]
name = "kiru"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
description = "Fast text chunking for Rust"
license = "MIT"
Expand All @@ -25,6 +25,7 @@ glob = { workspace = true }
rayon = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
crossbeam-channel = "0.5.15"

[dev-dependencies]
tempfile = { workspace = true }
Expand Down
15 changes: 4 additions & 11 deletions kiru-core/src/chunker.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crossbeam_channel::bounded;
use glob::glob;
use rayon::prelude::*;
use std::sync::{mpsc, Mutex};
use std::io;
use std::thread;
use std::{io, sync::Arc};
use thiserror::Error;

use crate::{BytesChunker, CharactersChunker, StreamType};
Expand Down Expand Up @@ -249,9 +249,8 @@ impl ChunkerWithStrategy {
StreamType::from_source(source)?; // This validates the source
}

let (sender, receiver) = mpsc::sync_channel(channel_size);
let (sender, receiver) = bounded(channel_size);
let chunker_params = self.chunker_params.clone();
let receiver: Arc<Mutex<mpsc::Receiver<String>>> = Arc::new(Mutex::new(receiver));

thread::spawn({
move || {
Expand All @@ -273,13 +272,7 @@ impl ChunkerWithStrategy {
}
});

let iterator = std::iter::from_fn({
let receiver: Arc<Mutex<mpsc::Receiver<String>>> = Arc::clone(&receiver); // Clone Arc for iterator
move || {
let receiver = receiver.lock().unwrap();
receiver.recv().ok()
}
});
let iterator = std::iter::from_fn(move || receiver.recv().ok());

Ok(Box::new(iterator))
}
Expand Down
4 changes: 2 additions & 2 deletions kiru-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# kiru-py/Cargo.toml
[package]
name = "kiru-py"
version = "0.1.9"
version = "0.1.10"
edition = "2021"
description = "Python bindings for kiru text chunking library"
repository = "https://github.com/bitswired/kiru"
Expand All @@ -17,6 +17,6 @@ pyo3 = { workspace = true }

[dependencies.kiru]
path = "../kiru-core"
version = "0.1.9"
version = "0.1.10"
[build-dependencies]
# None needed for simple bindings
Loading