Skip to content

Commit

Permalink
enh: limite max # of rows returned by SQLite worker (#3674)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Feb 9, 2024
1 parent 4cc469e commit e8a7d7b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/sqlite_workers/sqlite_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct SqliteDatabase {
interrupt_handle: Option<Arc<tokio::sync::Mutex<InterruptHandle>>>,
}

const MAX_ROWS: usize = 128;

impl SqliteDatabase {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -112,6 +114,8 @@ impl SqliteDatabase {
})
.collect::<Result<serde_json::Value>>()
})?
// Limit to 128 rows.
.take(MAX_ROWS)
.collect::<Result<Vec<_>>>()?
.into_par_iter()
.map(|value| QueryResult { value })
Expand Down

0 comments on commit e8a7d7b

Please sign in to comment.