{"id":22072530,"url":"https://github.com/broxus/weedb","last_synced_at":"2025-07-24T11:30:39.258Z","repository":{"id":66355168,"uuid":"421183241","full_name":"broxus/weedb","owner":"broxus","description":"A thin wrapper around RocksDB","archived":false,"fork":false,"pushed_at":"2024-11-29T13:44:02.000Z","size":93,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-29T14:40:39.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/broxus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-25T21:00:53.000Z","updated_at":"2024-11-27T16:37:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed5e45a1-daad-4286-b266-4636077468b8","html_url":"https://github.com/broxus/weedb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fweedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fweedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fweedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broxus%2Fweedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/broxus","download_url":"https://codeload.github.com/broxus/weedb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227150603,"owners_count":17738310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T21:13:33.204Z","updated_at":"2024-11-30T21:13:35.832Z","avatar_url":"https://github.com/broxus.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## WeeDB \u0026emsp; [![crates-io-batch]][crates-io-link] [![docs-badge]][docs-url] [![rust-version-badge]][rust-version-link]\n\n[crates-io-batch]: https://img.shields.io/crates/v/weedb.svg\n\n[crates-io-link]: https://crates.io/crates/weedb\n\n[docs-badge]: https://docs.rs/weedb/badge.svg\n\n[docs-url]: https://docs.rs/weedb\n\n[rust-version-badge]: https://img.shields.io/badge/rustc-1.65+-lightgray.svg\n\n[rust-version-link]: https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html\n\n\nA thin wrapper around RocksDB.\n\n### Example\n\n```rust\nuse weedb::{rocksdb, Caches, ColumnFamily, ColumnFamilyOptions, Migrations, WeeDb};\n\n// Describe tables group via macros.\n//\n// A group is parametrized with a table creation context.\nweedb::tables! {\n    pub struct MyTables\u003cCaches\u003e {\n        pub my_table: MyTable,\n        // ..and some other tables as fields...\n    }\n}\n\n// Describe a column family.\nstruct MyTable;\n\nimpl ColumnFamily for MyTable {\n    // Column family name\n    const NAME: \u0026'static str = \"my_table\";\n\n    // Modify read options\n    fn read_options(opts: \u0026mut rocksdb::ReadOptions) {\n        opts.set_verify_checksums(false);\n    }\n\n    // Modify write options\n    fn write_options(opts: \u0026mut rocksdb::WriteOptions) {\n        // ...\n    }\n}\n\n// Implement cf options setup for some specific context.\nimpl ColumnFamilyOptions\u003cCaches\u003e for MyTable {\n    // Modify general options\n    fn options(opts: \u0026mut rocksdb::Options, caches: \u0026mut Caches) {\n        opts.set_write_buffer_size(128 * 1024 * 1024);\n\n        // Use cache from the context\n        let mut block_factory = rocksdb::BlockBasedOptions::default();\n        block_factory.set_block_cache(\u0026caches.block_cache);\n        block_factory.set_data_block_index_type(rocksdb::DataBlockIndexType::BinaryAndHash);\n\n        opts.set_block_based_table_factory(\u0026block_factory);\n\n        opts.set_optimize_filters_for_hits(true);\n    }\n}\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let tempdir = tempfile::tempdir()?;\n\n    // Prepare caches\n    let caches = Caches::with_capacity(10 \u003c\u003c 23);\n\n    // Prepare db\n    let db = WeeDb::\u003cMyTables\u003e::builder(\u0026tempdir, caches)\n        .with_name(\"test\")\n        .with_metrics_enabled(true)\n        .with_options(|opts, _ctx| {\n            // Example configuration:\n\n            opts.set_level_compaction_dynamic_level_bytes(true);\n\n            // Compression opts\n            opts.set_zstd_max_train_bytes(32 * 1024 * 1024);\n            opts.set_compression_type(rocksdb::DBCompressionType::Zstd);\n\n            // Logging\n            opts.set_log_level(rocksdb::LogLevel::Error);\n            opts.set_keep_log_file_num(2);\n            opts.set_recycle_log_file_num(2);\n\n            // Cfs\n            opts.create_if_missing(true);\n            opts.create_missing_column_families(true);\n        })\n        .build()?;\n\n    // Prepare and apply migration\n    let mut migrations = Migrations::with_target_version([0, 1, 0]);\n    migrations.register([0, 0, 0], [0, 1, 0], |db| {\n        // do some migration stuff\n        Ok(())\n    })?;\n\n    db.apply(migrations)?;\n\n    // Table usage example\n    let my_table = \u0026db.tables().my_table;\n    my_table.insert(b\"asd\", b\"123\")?;\n    assert!(my_table.get(b\"asd\")?.is_some());\n\n    Ok(())\n}\n```\n\n# How to generate grafana dashboard\n\n```bash\ncd scripts\npython3 -m venv venv\n# activate venv according to your shell (source venv/bin/activate)\npip install -r requirements.txt\npython rocksdb_metrics.py dashboard.json\n```\n\n## Contributing\n\nWe welcome contributions to the project! If you notice any issues or errors,\nfeel free to open an issue or submit a pull request.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)\n  or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n* MIT license ([LICENSE-MIT](LICENSE-MIT)\n  or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroxus%2Fweedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroxus%2Fweedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroxus%2Fweedb/lists"}