1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Bindings to Lbug: an in-process property graph database management system built for query speed and scalability.
//!
//! ## Example Usage
//! ```
//! use lbug::{Database, SystemConfig, Connection};
//! # use anyhow::Error;
//!
//! # fn main() -> Result<(), Error> {
//! # let temp_dir = tempfile::tempdir()?;
//! # let path = temp_dir.path().join("testdb");
//! let db = Database::new(path, SystemConfig::default())?;
//! let conn = Connection::new(&db)?;
//! conn.query("CREATE NODE TABLE Person(name STRING, age INT64, PRIMARY KEY(name));")?;
//! conn.query("CREATE (:Person {name: 'Alice', age: 25});")?;
//! conn.query("CREATE (:Person {name: 'Bob', age: 30});")?;
//!
//! let mut result = conn.query("MATCH (a:Person) RETURN a.name AS NAME, a.age AS AGE;")?;
//! println!("{}", result);
//! # temp_dir.close()?;
//! # Ok(())
//! # }
//! ```
//! ## Building
//!
//! By default, the build downloads a precompiled static `liblbug` archive and links it into this
//! crate. If a precompiled archive is unavailable, the Lbug C++ library will be compiled from
//! source and statically linked.
//!
//! If you want to instead link against a pre-built version of the library, the following environment
//! variables can be used to configure the build process:
//!
//! - `LBUG_SHARED`: If set, link dynamically instead of statically
//! - `LBUG_SOURCE_DIR`: Directory of a Lbug source checkout to use when falling back to a source
//! build. Defaults to `../ladybug` when present.
//! - `LBUG_INCLUDE_DIR`: Directory of Lbug's headers
//! - `LBUG_LIBRARY_DIR`: Directory containing Lbug's pre-built libraries.
//! - `LBUG_BUILD_FROM_SOURCE` or `LBUG_RUST_BUILD_FROM_SOURCE`: If set, skip downloading a
//! precompiled `liblbug` and build from source.
//!
//! Example:
//! ```bash
//! lbug_prebuilt_dir=/tmp/lbug # pre-built Lbug from https://docs.ladybugdb.com/installation/#cc
//! lbug_prebuilt_dir=/path_to_lbug_source/build/release/src # Lbug built from source
//! export LBUG_LIBRARY_DIR="lbug_prebuilt_dir"
//! export LBUG_INCLUDE_DIR="lbug_prebuilt_dir"
//! export LBUG_SHARED=1
//! ```
//! On macOS:
//! ```bash
//! brew install lbug
//! export LBUG_LIBRARY_DIR=/opt/homebrew/lib
//! export LBUG_INCLUDE_DIR=/opt/homebrew/include
//! export LBUG_SHARED=1
//! ```
//!
//! - `LBUG_PREBUILT_CACHE_DIR`: Directory to keep downloaded prebuilt archives in, shared across
//! builds. By default they live under the build's `OUT_DIR`.
//! - `LBUG_LOCALIZE_BUNDLED_SYMBOLS`: On Linux static builds, set to `1` to hide the C symbols of
//! the libraries bundled in the prebuilt archive (zstd, lz4, brotli, simsimd, yyjson, CRoaring)
//! so they cannot collide with the Rust crates for the same libraries (`zstd-sys`, `lz4-sys`,
//! `simsimd`, `croaring-sys`, …) at link time. Needs GNU binutils. Leave it unset when the binary
//! loads extensions that resolve those symbols from the host.
//!
//! ## Bulk loading
//!
//! One `CREATE` or `MERGE` per row costs a full statement each: planning, execution and, outside
//! an explicit transaction, a commit. Measured through this crate on a 4-vCPU host, a single-row
//! relationship `MERGE … SET` costs tens of milliseconds of CPU, so loading a few hundred thousand
//! rows that way takes hours. Load in bulk instead:
//!
//! - From files: `COPY Person FROM 'people.csv'` / `COPY Knows FROM 'knows.parquet'`.
//! - From memory, with the `arrow` feature: register Arrow record batches as tables with
//! [`Connection::create_arrow_table`] and [`Connection::create_arrow_rel_table`], then
//! `COPY … FROM` them, or query them directly.
//! - Point lookups by primary key cost about a millisecond of planning each through
//! [`Connection::prepare`] + [`Connection::execute`]; fetch a neighbourhood with one
//! `MATCH (a)-[r]->(b) WHERE a.id = $id RETURN …` rather than one lookup per neighbour.
//!
//! ## Memory
//!
//! [`SystemConfig::default`] leaves `buffer_pool_size` at 0, which the engine resolves from the
//! host's physical memory, so an embedding process reserves a large share of RAM regardless of
//! the database's size (about 6 GB resident on a 15 GiB host for a 200,000-edge graph). Set
//! [`SystemConfig::buffer_pool_size`] explicitly when the process shares the machine.
//!
//! ## Using Extensions
//! By default, binaries created using this library will not work with Lbug's
//! [extensions](https://docs.ladybugdb.com/extensions/) (except on Windows/MSVC, where the linker works differently).
//!
//! If you want to use extensions in binaries (binary crates or tests) using this
//! library, you will need to add the following (or a similar command; see
//! [build-scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-arg))
//! to your build.rs (or create one) so that the binary
//! produced acts like a library that the extension can link with. Not doing this will produce
//! undefined symbol errors when the extension is loaded:
//!
//! ```ignore
//! println!("cargo:rustc-link-arg=-rdynamic");
//! ```
pub use ;
pub use ;
pub use Error;
pub use LogicalType;
pub use ;
pub use ;
pub use ;
pub use ;
/// The version of the Lbug crate as reported by Cargo's `CARGO_PKG_VERSION` environment variable
pub const VERSION: &str = env!;
/// The source of the linked Lbug library selected by the build script.
///
/// This is `external` when `LBUG_LIBRARY_DIR`/`LBUG_INCLUDE_DIR` were supplied, `source` when the
/// bundled C++ source was built, or a value such as `run:LadybugDB/ladybug/25646256977` or
/// `release:LadybugDB/ladybug/v0.17.0` when a precompiled archive was downloaded.
pub const LBUG_LIBRARY_SOURCE: &str = env!;
/// The directory containing the linked precompiled Lbug library, if one was used.
pub const LBUG_LIBRARY_DIR: &str = env!;
/// Returns the storage version of the Lbug library
/// Returns the source of the linked Lbug library selected by the build script.
/// Returns the directory containing the linked precompiled Lbug library.
///
/// This returns `None` when Lbug was built from source as part of this crate build.