# `Arcadic.Bulk`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/bulk.ex#L5)

Bulk-creates vertices and edges already held by the client. HTTP uses
ArcadeDB's NDJSON batch endpoint. gRPC uses its GraphBatchLoad stream.

Each record is a caller map with ArcadeDB's structural keys — `"@type" => "vertex" | "edge"`,
`"@class" => <TypeName>`, arbitrary properties, and, on a **vertex**, an `"@id"` temporary-id
string that edges reference. An **edge** carries `"@from"`/`"@to"` holding those vertex `"@id"`
values (or an existing vertex's real `#bucket:pos` RID). Vertices must appear before the edges
that reference them. Property values travel as structured records. The
result's `:id_mapping` maps temporary IDs to assigned RIDs.

    Arcadic.Bulk.ingest(conn, [
      %{"@type" => "vertex", "@class" => "Person", "@id" => "p1", "name" => "Alice"},
      %{"@type" => "vertex", "@class" => "Person", "@id" => "p2", "name" => "Bob"},
      %{"@type" => "edge", "@class" => "Knows", "@from" => "p1", "@to" => "p2"}
    ])
    #=> {:ok, %{vertices_created: 2, edges_created: 1, elapsed_ms: 7,
    #=>        id_mapping: %{"p1" => "#1:0", "p2" => "#1:1"}}}

## Commit behavior

ArcadeDB commits batches in chunks. HTTP and gRPC reject batch writes on
session-scoped connections with `:transaction_unsupported`. Use statements
on the session connection for writes that must share its transaction.

HTTP and gRPC batch errors expose server-reported counts and the partial-commit flag
in the `batch_progress` field of `Arcadic.Error` when ArcadeDB supplies them. Reconcile
against the database before retrying a failed or interrupted batch.

Replaying a batch creates fresh records. See [Load data](load-data.html)
for replayable upserts and server-side imports.

# `ingest`

```elixir
@spec ingest(Arcadic.Conn.t(), [map()], keyword()) ::
  {:ok,
   %{
     vertices_created: non_neg_integer(),
     edges_created: non_neg_integer(),
     elapsed_ms: non_neg_integer(),
     id_mapping: %{optional(String.t()) =&gt; String.t()}
   }}
  | {:error, :invalid_record | atom() | Exception.t()}
```

Bulk-create `records` (a list of caller vertex/edge maps). `opts`: `:light_edges` (bool),
`:commit_every` (pos_integer), `:timeout` (ms). Returns
`{:ok, %{vertices_created, edges_created, elapsed_ms, id_mapping}}` — where `id_mapping` maps each
vertex `"@id"` temporary handle to its assigned real RID — or `{:error, …}` (`:invalid_record`
on an unencodable record, or an `Arcadic.Error`/`Arcadic.TransportError`).

# `ingest!`

```elixir
@spec ingest!(Arcadic.Conn.t(), [map()], keyword()) :: map()
```

Bulk-create `records`, returning the counts map or raising.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
