Rocksdb Python Binding
Project description
RocksDict / SpeeDict
Key-value storage for Python & Wrapper of Rocksdb and Speedb
Installation
Wheels available for macOS amd64/arm64, linux amd64/arm64, and windows amd64.
pip install rocksdict
for rocksdb backend, thenfrom rocksdict import Rdict
pip install speedict
for speedb backend, thenfrom speedict import Rdict
Introduction
This library has two purposes.
- As an on-disk key-value storage solution for Python.
- As a RocksDB / Speedict interface.
These two purposes operate in different modes:
-
Default mode, which allows storing
int
,float
,bool
,str
,bytes
, and other python objects (withPickle
). -
Raw mode (
options=Options(raw_mode=True)
), which allows storing onlybytes
.
Examples
A minimal example
from rocksdict import Rdict
import numpy as np
import pandas as pd
path = str("./test_dict")
# create a Rdict with default options at `path`
db = Rdict(path)
db[1.0] = 1
db["huge integer"] = 2343546543243564534233536434567543
db["good"] = True
db["bytes"] = b"bytes"
db["this is a list"] = [1, 2, 3]
db["store a dict"] = {0: 1}
db[b"numpy"] = np.array([1, 2, 3])
db["a table"] = pd.DataFrame({"a": [1, 2], "b": [2, 1]})
# reopen Rdict from disk
db.close()
db = Rdict(path)
assert db[1.0] == 1
assert db["huge integer"] == 2343546543243564534233536434567543
assert db["good"] == True
assert db["bytes"] == b"bytes"
assert db["this is a list"] == [1, 2, 3]
assert db["store a dict"] == {0: 1}
assert np.all(db[b"numpy"] == np.array([1, 2, 3]))
assert np.all(db["a table"] == pd.DataFrame({"a": [1, 2], "b": [2, 1]}))
# iterate through all elements
for k, v in db.items():
print(f"{k} -> {v}")
# batch get:
print(db[["good", "bad", 1.0]])
# [True, False, 1]
# delete Rdict from dict
db.close()
Rdict.destroy(path)
An Example of Raw Mode
This mode allows only bytes as keys and values.
from rocksdict import Rdict, Options
PATH_TO_ROCKSDB = str("path")
# open raw_mode, which allows only bytes
db = Rdict(path=PATH_TO_ROCKSDB, options=Options(raw_mode=True))
db[b'a'] = b'a'
db[b'b'] = b'b'
db[b'c'] = b'c'
db[b'd'] = b'd'
for k, v in db.items():
print(f"{k} -> {v}")
# close and delete
db.close()
Rdict.destroy(PATH_TO_ROCKSDB)
New Feature Since v0.3.3
Loading Options from RocksDict Path.
Load Options and add A New ColumnFamily
from rocksdict import Options, Rdict
path = str("./rocksdict_path")
opts, cols = Options.load_latest(path)
opts.create_missing_column_families(True)
cols["bytes"] = Options()
self.test_dict = Rdict(path, options=opts, column_families=cols)
Reopening RocksDB Reads DB Options Automatically
import shutil
from rocksdict import Rdict, Options, SliceTransform, PlainTableFactoryOptions
import os
def db_options():
opt = Options()
# create table
opt.create_if_missing(True)
# config to more jobs
opt.set_max_background_jobs(os.cpu_count())
# configure mem-table to a large value (256 MB)
opt.set_write_buffer_size(0x10000000)
opt.set_level_zero_file_num_compaction_trigger(4)
# configure l0 and l1 size, let them have the same size (1 GB)
opt.set_max_bytes_for_level_base(0x40000000)
# 256 MB file size
opt.set_target_file_size_base(0x10000000)
# use a smaller compaction multiplier
opt.set_max_bytes_for_level_multiplier(4.0)
# use 8-byte prefix (2 ^ 64 is far enough for transaction counts)
opt.set_prefix_extractor(SliceTransform.create_max_len_prefix(8))
# set to plain-table
opt.set_plain_table_factory(PlainTableFactoryOptions())
return opt
# create DB
db = Rdict("./some_path", db_options())
db[0] = 1
db.close()
# automatic reloading all options on reopening
db = Rdict("./some_path")
assert db[0] == 1
# destroy
db.close()
Rdict.destroy("./some_path")
More Examples on BatchWrite, SstFileWrite, Snapshot, RocksDB Options, and etc.
Go to example folder.
Limitations
Currently, do not support merge operation and custom comparator.
Full Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for rocksdict-0.3.22-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0faa62396f1fd051c02c0c73515090310f34745164b509ebe8a05ff15ff3953b |
|
MD5 | 554679ec7ffdb63c3623702347a53f5f |
|
BLAKE2b-256 | baa6ac805a4cc03cc51a044f128b1ef9e7d1dad5037ac07242d72e2085658d63 |
Close
Hashes for rocksdict-0.3.22-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc677277b07e0657ffccef8e0523c75d387a68a83dcf377894ec379677e0db13 |
|
MD5 | 03cbdeeaff080e98d616d6657db18f54 |
|
BLAKE2b-256 | bf079fb4faa901d5ea7005d111af2e921fa44d0f1e4476d926f9b0299e7338ff |
Close
Hashes for rocksdict-0.3.22-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ceb7bddb4dd1a8434b70e812275a1390df133415aaa85a1c776931db610256 |
|
MD5 | 1feb116ff01f18008ca39e748d6d122d |
|
BLAKE2b-256 | 1a6eee848e5516216eebb0fbf9c5409f07c5afc6d366373279f6e7c8b8e94eb6 |
Close
Hashes for rocksdict-0.3.22-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acfc915954ab65a754f9015c3a1f656827f09265f0280b4ccb35c2c545db6b29 |
|
MD5 | 02b519da056f798942be98d52b6553e8 |
|
BLAKE2b-256 | 291a505ec70f5ee705f276e03fb8de1222689121e9d151e6b44a3ad1ff62654e |
Close
Hashes for rocksdict-0.3.22-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f8238075251cc1f4985048cb3868c81c0e2cb5372bf2dd6274680d98095d2a4 |
|
MD5 | 6acb2c2bcd2cfa5145a8bc450eab3acc |
|
BLAKE2b-256 | b27458b029ceebaef06e42280a1f4d8ec47d0f679c399e3e32de20bb63074eb2 |
Close
Hashes for rocksdict-0.3.22-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb07ed58ea2117da09c062e09a1f74eeb55f27b2378c0e726f4b62373ab423c |
|
MD5 | 158f68b2670584281d96afb29c8095f4 |
|
BLAKE2b-256 | ba801f638008583fd4795078aeb8dd4cf6ba1ef1365f2c5d20505b4a2b96ad64 |
Close
Hashes for rocksdict-0.3.22-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37554823f72af1b9ce4503e413a38fd226391a5f212d08a33e5f1000eaa876f2 |
|
MD5 | bf28b37e6645ad2632c957e1760ee3d2 |
|
BLAKE2b-256 | 120690eb4b6f090c6f7d6e7c02694afca176f3c7fd726ac498dda3b0b473e4d4 |
Close
Hashes for rocksdict-0.3.22-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe1896f405ab801ba30b1f76adca5455b6324f7fb476438c8edb65097cd4aca7 |
|
MD5 | f897f2f0123b834b0a55759839e0a72a |
|
BLAKE2b-256 | 88d08faa46cabe3e287b5bfa0792be11500b3ea42f40d59f1877aa3b6b7fb48f |
Close
Hashes for rocksdict-0.3.22-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ae1822e13b26f527b1c957ac948d76be5bea77c8c6a4ef302da92ab196f1d3d |
|
MD5 | 4f296057a63671d2eedfa9b572ae6d72 |
|
BLAKE2b-256 | b35c64f6ac7a6e797c45770f94a4f345cfee38bff628f7b5742fb9c4e8f8ba72 |
Close
Hashes for rocksdict-0.3.22-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b076ce9330846e5dfc594c32a16c960cf74ca5bd8368dac4645961ec5a686039 |
|
MD5 | b6d8cd37ea7b224ae3a52428c218f540 |
|
BLAKE2b-256 | 3002b1ea83ace6bb26eec45ca63523b70276b19512436c7513605973023f8766 |
Close
Hashes for rocksdict-0.3.22-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a453c97c1593d42932da486f1cd7f0dd5fcd872ba2cda2d28fa57182f38f332 |
|
MD5 | 63a75b18e29fa79f09120e57073ccdb0 |
|
BLAKE2b-256 | f115d4bfc390c64decec088d53778156d0becd6614fc282cea6b0f841d0c376c |
Close
Hashes for rocksdict-0.3.22-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69af50c73795bcb3f0237b86d3fd77e8c63bca7ad742428598eef6db39cb0d51 |
|
MD5 | 03cea7f0e185d0af15be5c2ae9372f67 |
|
BLAKE2b-256 | f5cfc66b673ebbdf93cc4261f872188f05863b1876235df206ac5c5a74f3edd3 |
Close
Hashes for rocksdict-0.3.22-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e54ec7e880882a3b6522ec1a3d6169a12352189ad9a99a6271e83efcf9fe4a4 |
|
MD5 | 6fdac38fbf942895951815e15f36df4c |
|
BLAKE2b-256 | fe1ba13b7d27695819f80590cf6aad9484d4dd4192876820f64e8793364c88ed |
Close
Hashes for rocksdict-0.3.22-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ce8d77d819134f8a0437fbb0e820ed981cac991ef7af53a7884c45c192a94f |
|
MD5 | c3a9fea630679d147bd2e78b42ba59de |
|
BLAKE2b-256 | e651e61054141c89cc6f41fa156eb0e542436e54d0033ced9d0eea2c3abafae1 |
Close
Hashes for rocksdict-0.3.22-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45279d1e550d3835a55b6120553723eb0c567966b3cbff333553c833a088f1f4 |
|
MD5 | ae43fd55726d6b26b6ec878ba2c760cb |
|
BLAKE2b-256 | 4e9cc9a25e8b5dc219af7d55c7dc278de258c59be1dec952c0d64b5fe75b8d80 |
Close
Hashes for rocksdict-0.3.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf841f2ab59a43f07bc64f8f5eacc6c9395d29ff819c4274d1dfc3255702a793 |
|
MD5 | 914a055b698ef70c0b638dc7fe59760d |
|
BLAKE2b-256 | e46b242c3aa9de8f8bf5ad46f53a1393de520e1c4199e49d25bc82b283e8f6d1 |
Close
Hashes for rocksdict-0.3.22-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350d2742d1fe059d159d2a21122efaa9e37bb3f41ff6c6736b3433a6f8cbea30 |
|
MD5 | b9e27b2f92c3b8f49616799ddad93c0f |
|
BLAKE2b-256 | 3f32ee4db7b007d3bf79b5c45695ffb1d7088cf9447a4be4ff45628d02ce5df1 |
Close
Hashes for rocksdict-0.3.22-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad34c5b31212546cf8428126594b29c365a345462ba214c7014d63a0a79333ba |
|
MD5 | 1c084b2d53263d28d68e25bc7ba9e69c |
|
BLAKE2b-256 | ef82e9f7cc79042c42f9267ad1f6b4ebb184d22bced1811cd811a053e238d551 |
Close
Hashes for rocksdict-0.3.22-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a3e686bc38a79e36c8e4f958202edfdfb3c7a185966ff152c7cd19ed1a6cc38 |
|
MD5 | 7c7a1ae91445035e165231e110d265b5 |
|
BLAKE2b-256 | 2814745b6bef888a72955508187fdcf1ba501f874a09bf93dfe082f7a083aa54 |
Close
Hashes for rocksdict-0.3.22-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 748821070b1e97220c8282ca3210104158acfbf676f28f627c1f4676db9a78c8 |
|
MD5 | 96aa7865e564972a3db848b4c5d7ebce |
|
BLAKE2b-256 | fbcb271890289b3624edf0dd6b05594a60b0ffad098db3206adb455b68ef570e |
Close
Hashes for rocksdict-0.3.22-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92363ce43511642fc775739d049d5f879f00771d9d2e0a6ff733cef65b4c1f4a |
|
MD5 | 7c34c233c9e41a343ec941d286a2503e |
|
BLAKE2b-256 | 25b828bde179bf80aa4c092e540e869f00c9c119884d6872b838f4e76be1d3bd |
Close
Hashes for rocksdict-0.3.22-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6c028c6f119f5a963d369fa5ae62d2e02237d8bc2c329f77bd18af49e4da668 |
|
MD5 | d2172e7712731d971ff0d99f9128dc8b |
|
BLAKE2b-256 | d6f87d439166587756cb059ecd9976614998689e71ad30b5af8881efa8c9e828 |
Close
Hashes for rocksdict-0.3.22-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5faa7df76d9acf8cce1c0df98baa6c9899e4ee0271df302318389abc12cd17e |
|
MD5 | 917480cd06dea510904ad48f57755e4a |
|
BLAKE2b-256 | 5dcc49ea617e91ca72c593e3a390ea3d41da2609faba50ef92b597294c395fc8 |
Close
Hashes for rocksdict-0.3.22-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe4c4bd51b41daee5377af38acee4f87b032042f3f232aa979beedcb4f6bb2cf |
|
MD5 | 7aacfe1c6db9c444766d79b9b642f77c |
|
BLAKE2b-256 | 8762bab7559637e2d7d5f361ca5b8a6f6e2513ea641361c1a2f6ac8cdf12c9c0 |
Close
Hashes for rocksdict-0.3.22-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1cb8b0f68ff9c4c6b74716251a4c66707d4adb3168566102bed520f58c44046 |
|
MD5 | 02b67169441305477942dcb83ba3b760 |
|
BLAKE2b-256 | cc1d5ea18d7d401b91eccc82b5e926785ffa413bdb6948d9610438dece9efb8e |
Close
Hashes for rocksdict-0.3.22-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4688ebda88dbfd86a2fb79b44c6607cf4f31be8475204d8f08a2ddf5e41a72c4 |
|
MD5 | b968b645c5f2b5c16dce6515053d4a7a |
|
BLAKE2b-256 | ca9f016178c42b24e160e2ea95d9d37c4e4643ebfd8e179393239835331153ad |
Close
Hashes for rocksdict-0.3.22-cp38-cp38-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed497d1979305ef73ef4b470e87a025d80939cafb679069cb10c3e0b6b2a726c |
|
MD5 | a001c6f848f5d02e062a8f9641707169 |
|
BLAKE2b-256 | fba524e2da45fa80dcd59e3f44bd0d6379b13a86bfe3716fd169932bb024cfc9 |
Close
Hashes for rocksdict-0.3.22-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7d845cf5eb320647d4b4f67ed8496f5e4ce53c6413826ec3fc62645a11e6248 |
|
MD5 | 0f0a2f2b2a046ff17af81cc81486c1ad |
|
BLAKE2b-256 | 2001350e91de27f60c0fe1899013cd9e53eab46b42ae712c126be0c9afc3ea7c |
Close
Hashes for rocksdict-0.3.22-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 976f188294ba31c786ea1e446556606d7f14438e0bfe566519e4caca28dc82e8 |
|
MD5 | 05d6b6e518fd91b9efe429e0e92abd69 |
|
BLAKE2b-256 | 728facda06700471ad0b41a57b20cad90620ffd23320c3cecaa1b12af1b03953 |
Close
Hashes for rocksdict-0.3.22-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0f3d103f005763df2ee8a0757866f4a4c4bf20de467698bb4680ff1da5172a |
|
MD5 | 9c578deae742381c4078391b386b87e0 |
|
BLAKE2b-256 | 5f929bfa69e271ed76b5ba653ead0409058cc067a8d0c7f4126aaecef05cdf45 |
Close
Hashes for rocksdict-0.3.22-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd1d50e166b30645b47b42432a4e12dc2677d2673554670001ce302e83183ea1 |
|
MD5 | da7de4afaca9fa52e849f620d5244eec |
|
BLAKE2b-256 | 2107074b026d7877cc17428d600975f5242e6b3e2a50576ac2c13bde928c5eed |
Close
Hashes for rocksdict-0.3.22-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab3531703a1b41b0b77aa68eb360e6ae6505a081d22216f51e78e2e065a1b0d |
|
MD5 | 90c110d5ddb2beb7abbff14c13d4aaa4 |
|
BLAKE2b-256 | 359a7d7baf0c4fae0b1222e6da680c96d354a94d6fdae8f955f81427520fcfb3 |
Close
Hashes for rocksdict-0.3.22-cp37-cp37m-manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745028fa5af88e79e5c1352858451d913ea1e585b3dbc9b097167fb23b60bc92 |
|
MD5 | e2106a290f452047ae8ff56972ce5b36 |
|
BLAKE2b-256 | 351da33e8a580e717fb98cb3e44e4d78cb8196f871561e889bc283a69918cbc7 |
Close
Hashes for rocksdict-0.3.22-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c175f06785ea9a63221b9fcca31e99eae9d4b909dcbe9e9dab0c0cb5d5b6aa67 |
|
MD5 | 87c472b4d23be1d878d8a6bddca94650 |
|
BLAKE2b-256 | 0c5e94ef9f986c428ebb6db452fcdae2094ffc995f130518785be3d97ba8db39 |
Close
Hashes for rocksdict-0.3.22-cp37-cp37m-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ddf7efff438c9d80389eea47647b761bebc795b6e78f18e967963b890258d3a |
|
MD5 | e4923a3b1bb8cf5cc695e24efc9224dd |
|
BLAKE2b-256 | e8c0059371e1ef57519bb242996926ffdbcf98d33d3d0cf404955cef12a9fa6a |
Close
Hashes for rocksdict-0.3.22-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05afa054803abd9d42206d5fdbea6288d060e674cb5e40aafa25a8984ef2eecb |
|
MD5 | 91b49d81d347aa6fcf08d6d5dbf18c1f |
|
BLAKE2b-256 | 0091ae6788091e950a09f451d0d4738e553e29a6bb842bb8edb932a3a47382c4 |