Skip to content

Commit

Permalink
feat!(inserter): don't set limits by default
Browse files Browse the repository at this point in the history
  • Loading branch information
loyd committed Dec 7, 2023
1 parent 2f87d21 commit 6a60dc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- insert: apply options set on the client ([#90]).

### Changed
- **BREAKING** inserter: there is no default limits anymore.
- **BREAKING** inserter: `Inserter::write` is synchronous now.
- **BREAKING** inserter: rename `entries` to `rows`.
- **BREAKING** drop the `wa-37420` feature.
Expand Down
14 changes: 6 additions & 8 deletions src/inserter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ use tokio::time::Duration;

use crate::{error::Result, insert::Insert, row::Row, ticks::Ticks, Client};

const DEFAULT_MAX_ROWS: u64 = 500_000;

/// Performs multiple consecutive `INSERT`s.
///
/// By default, it ends the current active `INSERT` every 500_000 rows.
/// Use `with_max_bytes`,`with_max_rows` and `with_period` to modify this behaviour.
/// By default, it doesn't end the current active `INSERT` automatically.
/// Use `with_max_bytes`,`with_max_rows` and `with_period` to set limits.
///
/// Rows are being sent progressively to spread network load.
///
Expand Down Expand Up @@ -59,7 +57,7 @@ where
client: client.clone(),
table: table.into(),
max_bytes: u64::MAX,
max_rows: DEFAULT_MAX_ROWS,
max_rows: u64::MAX,
send_timeout: None,
end_timeout: None,
insert: None,
Expand Down Expand Up @@ -87,7 +85,7 @@ where
/// Note: ClickHouse inserts batches atomically only if all rows fit in the same partition
/// and their number is less [`max_insert_block_size`](https://clickhouse.tech/docs/en/operations/settings/settings/#settings-max_insert_block_size).
///
/// Unlimited by default.
/// Unlimited (`u64::MAX`) by default.
pub fn with_max_bytes(mut self, threshold: u64) -> Self {
self.set_max_bytes(threshold);
self
Expand All @@ -98,7 +96,7 @@ where
/// Note: ClickHouse inserts batches atomically only if all rows fit in the same partition
/// and their number is less [`max_insert_block_size`](https://clickhouse.tech/docs/en/operations/settings/settings/#settings-max_insert_block_size).
///
/// `500_000` by default.
/// Unlimited (`u64::MAX`) by default.
pub fn with_max_rows(mut self, threshold: u64) -> Self {
self.set_max_rows(threshold);
self
Expand All @@ -117,7 +115,7 @@ where
/// Actual ticks: | work -----| delay | work ---| work -----| work -----|
/// ```
///
/// `None` by default.
/// Unlimited (`None`) by default.
pub fn with_period(mut self, period: Option<Duration>) -> Self {
self.set_period(period);
self
Expand Down

0 comments on commit 6a60dc2

Please sign in to comment.