Debian Codegraph @

README.md

raw symbols SCIP
1 <p align="center"><img width="280px" src="https://raw.githubusercontent.com/meilisearch/heed/main/assets/heed-pigeon-logo.png"></a>
2 <h1 align="center" >heed</h1>
3
4 [![License](https://img.shields.io/badge/license-MIT-green)](#LICENSE)
5 [![Crates.io](https://img.shields.io/crates/v/heed)](https://crates.io/crates/heed)
6 [![Docs](https://docs.rs/heed/badge.svg)](https://docs.rs/heed)
7 [![dependency status](https://deps.rs/repo/github/meilisearch/heed/status.svg)](https://deps.rs/repo/github/meilisearch/heed)
8 [![Build](https://github.com/meilisearch/heed/actions/workflows/rust.yml/badge.svg)](https://github.com/meilisearch/heed/actions/workflows/rust.yml)
9
10 A Rust-centric [LMDB](https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database) abstraction with minimal overhead. This library enables the storage of various Rust types within LMDB, extending support to include Serde-compatible types.
11
12 ## Simple Example Usage
13
14 Here is an example on how to store and read entries into LMDB in a safe and ACID way. For usage examples, see [heed/examples/](heed/examples/). To see more advanced usage techniques go check our [Cookbook](https://docs.rs/heed/latest/heed/cookbook/index.html).
15
16 ```rust
17 use std::fs;
18 use std::path::Path;
19 use heed::{EnvOpenOptions, Database};
20 use heed::types::*;
21
22 fn main() -> Result<(), Box<dyn std::error::Error>> {
23 let env = unsafe { EnvOpenOptions::new().open("my-first-db")? };
24
25 // We open the default unnamed database
26 let mut wtxn = env.write_txn()?;
27 let db: Database<Str, U32<byteorder::NativeEndian>> = env.create_database(&mut wtxn, None)?;
28
29 // We open a write transaction
30 db.put(&mut wtxn, "seven", &7)?;
31 db.put(&mut wtxn, "zero", &0)?;
32 db.put(&mut wtxn, "five", &5)?;
33 db.put(&mut wtxn, "three", &3)?;
34 wtxn.commit()?;
35
36 // We open a read transaction to check if those values are now available
37 let mut rtxn = env.read_txn()?;
38
39 let ret = db.get(&rtxn, "zero")?;
40 assert_eq!(ret, Some(0));
41
42 let ret = db.get(&rtxn, "five")?;
43 assert_eq!(ret, Some(5));
44
45 Ok(())
46 }
47 ```
48
49 ## Building from Source
50
51 You can use this command to clone the repository:
52
53 ```bash
54 git clone --recursive https://github.com/meilisearch/heed.git
55 cd heed
56 cargo build
57 ```
58
59 However, if you already cloned it and forgot to initialize the submodules, execute the following command:
60
61 ```bash
62 git submodule update --init
63 ```