Skip to main content

reifydb_engine/bulk_insert/
mod.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
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
26pub mod builder;
27pub mod coerce;
28pub mod error;
29pub mod primitive;
30pub mod validation;
31
32/// Result of a bulk insert operation
33#[derive(Debug, Clone, Default)]
34pub struct BulkInsertResult {
35	pub tables: Vec<TableInsertResult>,
36	pub ringbuffers: Vec<RingBufferInsertResult>,
37}
38
39/// Result of inserting into a specific table
40#[derive(Debug, Clone)]
41pub struct TableInsertResult {
42	pub namespace: String,
43	pub table: String,
44	pub inserted: u64,
45}
46
47/// Result of inserting into a specific ring buffer
48#[derive(Debug, Clone)]
49pub struct RingBufferInsertResult {
50	pub namespace: String,
51	pub ringbuffer: String,
52	pub inserted: u64,
53}