> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# BulkInserterOptions

> BulkInserterOptions — Kinetica Rust API

[gpudb\_api](https://docs.kinetica.com/content/api/rust/index.md)::<wbr />[bulk\_inserter](https://docs.kinetica.com/content/api/rust/bulk_inserter/index.md)
[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L462-L496)&#x20;

<pre>`pub struct BulkInserterOptions {    pub insert_options: Option<HashMap<String, String>>,    pub flush_options: FlushOptions,    pub max_retries: usize,    pub worker_list: Option<WorkerList>,    pub max_in_flight_batches: usize,    pub batch_listener: Option<Arc<dyn BatchInsertionListener>>,}`</pre>

Options for configuring the BulkInserter.The insert options map is passed directly to `insert_records` calls and supports the same options as the `/insert/records` endpoint.

Fields
`insert_options: Option<HashMap<String, String>>`

Optional parameters to pass to GPUdb while inserting. These are passed directly to the `insert_records` API call. See `insert_records_options` module for available option keys.

`flush_options: FlushOptions`

Options for controlling automatic/timed flush behavior.

`max_retries: usize`

Maximum number of retries for failed insertions. Default is 3.This counts retries after the first attempt (0 means one attempt), only connection failures are retried, and the count starts again on another cluster after an HA failover.

`worker_list: Option<WorkerList>`

Optional worker list for multi-head ingest. If None, the worker list will be automatically configured from the server. Pass an empty WorkerList to disable multi-head ingest.

`max_in_flight_batches: usize`

Maximum number of concurrent in-flight batch requests. Limits memory usage by blocking when this limit is reached. Default is 100.

`batch_listener: Option<Arc<dyn BatchInsertionListener>>`

Optional batch insertion listener for callbacks. Called when each batch completes (success or failure).

## Implementations

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L527-L677)
impl [BulkInserterOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.BulkInserterOptions.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L529-L531)
pub fn [new](#method.new)() -> Self

Creates a new BulkInserterOptions with default values.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L534-L543)
pub fn [set\_update\_on\_existing\_pk](#method.set_update_on_existing_pk)(\&mut self, value: [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)) -> \&mut Self

Sets whether to update existing records on primary key collision.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L546-L555)
pub fn [set\_ignore\_existing\_pk](#method.set_ignore_existing_pk)(\&mut self, value: [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)) -> \&mut Self

Sets whether to ignore existing primary key collisions (suppress errors).

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L558-L567)
pub fn [set\_return\_individual\_errors](#method.set_return_individual_errors)(\&mut self, value: [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)) -> \&mut Self

Sets whether to return individual errors for each record.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L570-L579)
pub fn [set\_allow\_partial\_batch](#method.set_allow_partial_batch)(\&mut self, value: [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)) -> \&mut Self

Sets whether to allow partial batch insertions.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L582-L591)
pub fn [set\_truncate\_strings](#method.set_truncate_strings)(\&mut self, value: [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)) -> \&mut Self

Sets whether to truncate strings to fit the column width.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L594-L597)
pub fn [set\_flush\_options](#method.set_flush_options)(\&mut self, flush\_options: [FlushOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.FlushOptions.md)) -> \&mut Self

Sets the flush options for automatic/timed flush.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L600-L603)
pub fn [set\_max\_retries](#method.set_max_retries)(\&mut self, max\_retries: [usize](https://doc.rust-lang.org/1.98.1/std/primitive.usize.html)) -> \&mut Self

Sets the maximum number of retries for failed insertions.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L606-L609)
pub fn [set\_worker\_list](#method.set_worker_list)(\&mut self, worker\_list: [Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<[WorkerList](https://docs.kinetica.com/content/api/rust/worker_list/struct.WorkerList.md)>) -> \&mut Self

Sets the worker list for multi-head ingest.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L612-L618)
pub fn [set\_option](#method.set_option)(\&mut self, key: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), value: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html)) -> \&mut Self

Adds a custom option to the insert options map.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L622-L625)
pub fn [set\_max\_in\_flight\_batches](#method.set_max_in_flight_batches)(\&mut self, max\_batches: [usize](https://doc.rust-lang.org/1.98.1/std/primitive.usize.html)) -> \&mut Self

Sets the maximum number of concurrent in-flight batch requests. This limits memory usage by blocking when the limit is reached.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L646-L649)
pub fn [set\_batch\_listener](#method.set_batch_listener)( \&mut self, listener: [Arc](https://doc.rust-lang.org/1.98.1/alloc/sync/struct.Arc.html)\<dyn [BatchInsertionListener](https://docs.kinetica.com/content/api/rust/bulk_inserter/trait.BatchInsertionListener.md)>, ) -> \&mut Self

Sets the batch insertion listener for callbacks. The listener will be called when each batch completes (success or failure).

##### Example

```rust theme={null}
use gpudb_api::{BatchInsertionListener, BatchInsertionResult, BulkInserterOptions};
use std::sync::Arc;

struct MyListener;
impl BatchInsertionListener for MyListener {
    fn on_batch_inserted(&self, result: &BatchInsertionResult) {
        println!("Batch completed: {} records", result.batch_size);
    }
}

let mut options = BulkInserterOptions::new();
options.set_batch_listener(Arc::new(MyListener));
```

## Trait Implementations

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L461)
impl [Clone](https://doc.rust-lang.org/1.98.1/core/clone/trait.Clone.html) for [BulkInserterOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.BulkInserterOptions.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L461)
fn [clone](https://doc.rust-lang.org/1.98.1/core/clone/trait.Clone.html#tymethod.clone)(\&self) -> [BulkInserterOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.BulkInserterOptions.md)

Returns a duplicate of the value. [Read more](https://doc.rust-lang.org/1.98.1/core/clone/trait.Clone.html#tymethod.clone)

1.0.0 (const: [unstable](https://github.com/rust-lang/rust/issues/142757)) · [Source](https://doc.rust-lang.org/1.98.1/src/core/clone.rs.html#245-247)
fn [clone\_from](https://doc.rust-lang.org/1.98.1/core/clone/trait.Clone.html#method.clone_from)(\&mut self, source: \&Self)

Performs copy-assignment from `source`. [Read more](https://doc.rust-lang.org/1.98.1/core/clone/trait.Clone.html#method.clone_from)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L501-L512)
impl [Debug](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html) for [BulkInserterOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.BulkInserterOptions.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L502-L511)
fn [fmt](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html#tymethod.fmt)(\&self, f: \&mut [Formatter](https://doc.rust-lang.org/1.98.1/core/fmt/struct.Formatter.html)\<'\_>) -> [Result](https://doc.rust-lang.org/1.98.1/core/fmt/type.Result.html)

Formats the value using the given formatter. [Read more](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html#tymethod.fmt)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L514-L525)
impl [Default](https://doc.rust-lang.org/1.98.1/core/default/trait.Default.html) for [BulkInserterOptions](https://docs.kinetica.com/content/api/rust/bulk_inserter/struct.BulkInserterOptions.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/bulk_inserter.rs#L515-L524)
fn [default](https://doc.rust-lang.org/1.98.1/core/default/trait.Default.html#tymethod.default)() -> Self

Returns the “default value” for a type. [Read more](https://doc.rust-lang.org/1.98.1/core/default/trait.Default.html#tymethod.default)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.