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 primitive;
29pub mod validation;
30
31/// Result of a bulk insert operation
32#[derive(Debug, Clone, Default)]
33pub struct BulkInsertResult {
34 pub tables: Vec<TableInsertResult>,
35 pub ringbuffers: Vec<RingBufferInsertResult>,
36}
37
38/// Result of inserting into a specific table
39#[derive(Debug, Clone)]
40pub struct TableInsertResult {
41 pub namespace: String,
42 pub table: String,
43 pub inserted: u64,
44}
45
46/// Result of inserting into a specific ring buffer
47#[derive(Debug, Clone)]
48pub struct RingBufferInsertResult {
49 pub namespace: String,
50 pub ringbuffer: String,
51 pub inserted: u64,
52}