Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python Rocksdb
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
Python Rocksdb
Commits
68c58009
Commit
68c58009
authored
11 years ago
by
hofmockel
Browse files
Options
Downloads
Patches
Plain Diff
Add examples to use the 'table_factory' and 'memtable_factory'
parent
1cb9ec4e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/api/options.rst
+4
-2
4 additions, 2 deletions
docs/api/options.rst
docs/tutorial/index.rst
+55
-0
55 additions, 0 deletions
docs/tutorial/index.rst
with
59 additions
and
2 deletions
docs/api/options.rst
+
4
−
2
View file @
68c58009
...
...
@@ -661,7 +661,7 @@ Options object
Factory for the files forming the persisten data storage.
Sometimes they are also named SST-Files. Right now you can assign
instances of the following classes
instances of the following classes
.
* :py:class:`rocksdb.BlockBasedTableFactory`
* :py:class:`rocksdb.PlainTableFactory`
...
...
@@ -803,6 +803,8 @@ LRUCache
the least-used order. If not enough space is freed, further free the
entries in least used order.
.. _table_factories_label:
TableFactories
==============
...
...
@@ -816,7 +818,7 @@ Instances of this classes can assigned to :py:attr:`rocksdb.Options.table_factor
for low query latency on pure-memory or really low-latency media.
Tutorial of rocksdb table formats is available here:
https://github.com/facebook/rocksdb/wiki/A-Tutorial-of-RocksDB-SST-formats
https://github.com/facebook/rocksdb/wiki/A-Tutorial-of-RocksDB-SST-formats
.. py:class:: rocksdb.BlockBasedTableFactory
...
...
This diff is collapsed.
Click to expand it.
docs/tutorial/index.rst
+
55
−
0
View file @
68c58009
...
...
@@ -270,3 +270,58 @@ The two arguments are the db_dir and wal_dir, which are mostly the same. ::
backup = rocksdb.BackupEngine("test.db/backups")
backup.restore_latest_backup("test.db", "test.db")
Change Memtable or SST implementations
======================================
As noted here :ref:`memtable_factories_label`, RocksDB offers different implementations for the memtable
representation. Per default :py:class:`rocksdb.SkipListMemtableFactory` is used,
but changeing it to a different one is veary easy.
Here is an example for HashSkipList-MemtableFactory.
Keep in mind: To use the hashed based MemtableFactories you must set
:py:attr:`rocksdb.Options.prefix_extractor`.
In this example all keys have a static prefix of len 5. ::
class StaticPrefix(rocksdb.interfaces.SliceTransform):
def name(self):
return b'static'
def transform(self, src):
return (0, 5)
def in_domain(self, src):
return len(src) >= 5
def in_range(self, dst):
return len(dst) == 5
opts = rocksdb.Options()
opts.prefix_extractor = StaticPrefix()
opts.memtable_factory = rocksdb.HashSkipListMemtableFactory()
opts.create_if_missing = True
db = rocksdb.DB("test.db", opts)
db.put(b'00001.x', b'x')
db.put(b'00001.y', b'y')
db.put(b'00002.x', b'x')
For initial bulk loads the Vector-MemtableFactory makes sense. ::
opts = rocksdb.Options()
opts.memtable_factory = rocksdb.VectorMemtableFactory()
opts.create_if_missing = True
db = rocksdb.DB("test.db", opts)
As noted here :ref:`table_factories_label`, it is also possible to change the
representation of the final data files.
Here is an example how to use one of the 'PlainTables'. ::
opts = rocksdb.Options()
opts.table_factory = rocksdb.TotalOrderPlainTableFactory()
opts.create_if_missing = True
db = rocksdb.DB("test.db", opts)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment