Skip to content

RocksDB wrapper for Go. Support 9.x, 8.x, 7.x, 6.x, etc

License

Notifications You must be signed in to change notification settings

linxGnu/grocksdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c81ab26 · Oct 21, 2024
Aug 29, 2023
May 26, 2023
Jan 30, 2020
Oct 9, 2019
Jan 30, 2024
Oct 7, 2024
Nov 9, 2023
Sep 4, 2023
Jan 30, 2024
Oct 21, 2024
Oct 21, 2024
Oct 21, 2024
Sep 3, 2023
Sep 4, 2023
Jan 20, 2023
Jan 11, 2024
Oct 21, 2024
Oct 21, 2024
Sep 26, 2022
Sep 4, 2023
Nov 9, 2023
Sep 4, 2023
Nov 9, 2023
Sep 4, 2023
Sep 4, 2023
Oct 14, 2020
Sep 4, 2023
Oct 17, 2019
Sep 7, 2024
Sep 4, 2023
Oct 21, 2024
Oct 21, 2024
Sep 25, 2022
Oct 17, 2019
Sep 25, 2022
Sep 4, 2023
Sep 25, 2022
Sep 4, 2023
Mar 21, 2024
Mar 21, 2024
Aug 8, 2022
Aug 8, 2022
Sep 7, 2024
Sep 7, 2024
Sep 4, 2023
Aug 27, 2022
Sep 4, 2023
May 21, 2024
Jul 13, 2021
Oct 9, 2019
Sep 4, 2023
Nov 9, 2023
Oct 21, 2024
Feb 21, 2023
Feb 21, 2023
Sep 25, 2022
Oct 21, 2024
Mar 15, 2022
Sep 4, 2023
Sep 4, 2023
Aug 21, 2024
Aug 21, 2024
Nov 9, 2023
Sep 4, 2023
Oct 14, 2020
Sep 25, 2022
Sep 4, 2023
Sep 4, 2023
Sep 4, 2023
May 26, 2023
Oct 12, 2024
Dec 12, 2023
Oct 15, 2020
Sep 4, 2023
Oct 21, 2024
Sep 25, 2022
Sep 25, 2022
Jan 11, 2024
Dec 12, 2023
Sep 25, 2022
Sep 4, 2023
Aug 27, 2022
Oct 14, 2019
May 21, 2024
Nov 9, 2023
Nov 9, 2023
Sep 4, 2023
May 21, 2024
Nov 9, 2023
Dec 12, 2023
Mar 22, 2023
Aug 27, 2022
Mar 14, 2023
Dec 14, 2023
Dec 14, 2023
Oct 21, 2024
Nov 9, 2023
Sep 25, 2022
Sep 7, 2024
Oct 21, 2024
Oct 21, 2024
Sep 7, 2024
Oct 21, 2024
Jan 11, 2024
Jan 11, 2024

Repository files navigation

grocksdb, RocksDB wrapper for Go

Go Report Card Coverage Status godoc

This is a Fork from tecbot/gorocksdb. I respect the author work and community contribution. The LICENSE still remains as upstream.

Why I made a patched clone instead of PR:

  • Supports almost C API (unlike upstream). Catching up with latest version of Rocksdb as promise.
  • This fork contains no defer in codebase (my side project requires as less overhead as possible). This introduces loose convention of how/when to free c-mem, thus break the rule of tecbot/gorocksdb.

Install

Prerequisite

  • librocksdb
  • libsnappy
  • libz
  • liblz4
  • libzstd
  • libbz2 (optional)

Please follow this guide: https://github.com/facebook/rocksdb/blob/master/INSTALL.md to build above libs.

Build

After installing both rocksdb and grocksdb, you can build your app using the following commands:

CGO_CFLAGS="-I/path/to/rocksdb/include" \
CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd" \
  go build

Or just:

go build // if prerequisites are in linker paths

If your rocksdb was linked with bz2:

CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lsnappy -llz4 -lzstd -lbz2" \
  go build

Customize the build flags

Currently, the default build flags without specifying CGO_LDFLAGS or the corresponding environment variables are -lrocksdb -pthread -lstdc++ -ldl -lm -lzstd -llz4 -lz -lsnappy

If you want to customize the build flags:

  1. Use -tags grocksdb_clean_link to create a cleaner set of flags and build it based on the cleaner flag. The base build flags after using the tag are -lrocksdb -pthread -lstdc++ -ldl.
CGO_LDFLAGS="-L/path/to/rocksdb -lzstd" go build -tags grocksdb_clean_link
  1. Use -tags grocksdb_no_link to ignore the build flags provided by the library and build it fully based on the custom flags.
CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lzstd -llz4" go build -tags grocksdb_clean_link

Usage

See also: doc

API Support

Almost C API, excepts:

  • get_db_identity
  • putv/mergev/deletev/delete_rangev
  • compaction_filter/compaction_filter_factory/compaction_filter_context
  • transactiondb_property_value/transactiondb_property_int
  • optimistictransactiondb_property_value/optimistictransactiondb_property_int
  • writebatch_update_timestamps/writebatch_wi_update_timestamps/writebatch_iterate_cf
  • approximate_sizes_cf_with_flags
  • logger_create_callback_logger