reifydb_engine/bulk_insert/mod.rs
1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4//! Fluent API for fast bulk inserts into sources.
5//!
6//! This module provides a builder pattern API that bypasses RQL parsing
7//! for maximum insert performance. All inserts within a single builder
8//! execute in one transaction (one request = one transaction).
9//!
10//! # Example
11//!
12//! ```ignore
13//! use reifydb_type::params;
14//!
15//! engine.bulk_insert(&identity)
16//! .table("namespace.users")
17//! .row(params!{ id: 1, name: "Alice" })
18//! .row(params!{ id: 2, name: "Bob" })
19//! .done()
20//! .ringbuffer("namespace.events")
21//! .row(params!{ timestamp: 12345, event_type: "login" })
22//! .done()
23//! .execute()?;
24//! ```
25
26mod builder;
27mod coerce;
28mod error;
29mod source;
30mod validation;
31
32pub use builder::{BulkInsertBuilder, Trusted, Validated, ValidationMode};
33pub use error::BulkInsertError;
34
35/// Result of a bulk insert operation
36#[derive(Debug, Clone, Default)]
37pub struct BulkInsertResult {
38 pub tables: Vec<TableInsertResult>,
39 pub ringbuffers: Vec<RingBufferInsertResult>,
40}
41
42/// Result of inserting into a specific table
43#[derive(Debug, Clone)]
44pub struct TableInsertResult {
45 pub namespace: String,
46 pub table: String,
47 pub inserted: u64,
48}
49
50/// Result of inserting into a specific ring buffer
51#[derive(Debug, Clone)]
52pub struct RingBufferInsertResult {
53 pub namespace: String,
54 pub ringbuffer: String,
55 pub inserted: u64,
56}