Skip to content

Commit 315543e

Browse files
vlsNightTsarina
authored andcommitted
update WriteOptions to WriteOptions.low_pri version
1 parent 5f68a35 commit 315543e

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

docs/api/database.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Database object
1616
Exception.
1717

1818

19-
.. py:method:: put(key, value, sync=False, disable_wal=False)
19+
.. py:method:: put(key, value, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False)
2020
2121
Set the database entry for "key" to "value".
2222

@@ -42,16 +42,35 @@ Database object
4242
If ``True``, writes will not first go to the write ahead log,
4343
and the write may got lost after a crash.
4444

45-
.. py:method:: delete(key, sync=False, disable_wal=False)
45+
:param bool ignore_missing_column_families:
46+
If ``True`` and if user is trying to write to column families that don't exist
47+
(they were dropped), ignore the write (don't return an error). If there
48+
are multiple writes in a WriteBatch, other writes will succeed.
49+
50+
:param bool no_slowdown:
51+
If ``True`` and we need to wait or sleep for the write request, fails
52+
immediately with Status::Incomplete().
53+
54+
:param bool low_pri:
55+
If ``True``, this write request is of lower priority if compaction is
56+
behind. In this case, no_slowdown = true, the request will be cancelled
57+
immediately with Status::Incomplete() returned. Otherwise, it will be
58+
slowed down. The slowdown value is determined by RocksDB to guarantee
59+
it introduces minimum impacts to high priority writes.
60+
61+
.. py:method:: delete(key, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False)
4662
4763
Remove the database entry for "key".
4864

4965
:param bytes key: Name to delete
5066
:param sync: See :py:meth:`rocksdb.DB.put`
5167
:param disable_wal: See :py:meth:`rocksdb.DB.put`
68+
:param ignore_missing_column_families: See :py:meth:`rocksdb.DB.put`
69+
:param no_slowdown: See :py:meth:`rocksdb.DB.put`
70+
:param low_pri: See :py:meth:`rocksdb.DB.put`
5271
:raises rocksdb.errors.NotFound: If the key did not exists
5372

54-
.. py:method:: merge(key, value, sync=False, disable_wal=False)
73+
.. py:method:: merge(key, value, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False)
5574
5675
Merge the database entry for "key" with "value".
5776
The semantics of this operation is determined by the user provided
@@ -64,13 +83,16 @@ Database object
6483
no :py:attr:`rocksdb.Options.merge_operator` was set at creation
6584

6685

67-
.. py:method:: write(batch, sync=False, disable_wal=False)
86+
.. py:method:: write(batch, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False)
6887
6988
Apply the specified updates to the database.
7089

7190
:param rocksdb.WriteBatch batch: Batch to apply
7291
:param sync: See :py:meth:`rocksdb.DB.put`
7392
:param disable_wal: See :py:meth:`rocksdb.DB.put`
93+
:param ignore_missing_column_families: See :py:meth:`rocksdb.DB.put`
94+
:param no_slowdown: See :py:meth:`rocksdb.DB.put`
95+
:param low_pri: See :py:meth:`rocksdb.DB.put`
7496

7597
.. py:method:: get(key, verify_checksums=False, fill_cache=True, snapshot=None, read_tier="all")
7698

rocksdb/_rocksdb.pyx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,11 +1762,14 @@ cdef class DB(object):
17621762
if handle.name == name:
17631763
return handle.weakref
17641764

1765-
def put(self, key, value, sync=False, disable_wal=False):
1765+
def put(self, key, value, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False):
17661766
cdef Status st
17671767
cdef options.WriteOptions opts
17681768
opts.sync = sync
17691769
opts.disableWAL = disable_wal
1770+
opts.ignore_missing_column_families = ignore_missing_column_families
1771+
opts.no_slowdown = no_slowdown
1772+
opts.low_pri = low_pri
17701773

17711774
if isinstance(key, tuple):
17721775
column_family, key = key
@@ -1783,11 +1786,14 @@ cdef class DB(object):
17831786
st = self.db.Put(opts, cf_handle, c_key, c_value)
17841787
check_status(st)
17851788

1786-
def delete(self, key, sync=False, disable_wal=False):
1789+
def delete(self, key, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False):
17871790
cdef Status st
17881791
cdef options.WriteOptions opts
17891792
opts.sync = sync
17901793
opts.disableWAL = disable_wal
1794+
opts.ignore_missing_column_families = ignore_missing_column_families
1795+
opts.no_slowdown = no_slowdown
1796+
opts.low_pri = low_pri
17911797

17921798
if isinstance(key, tuple):
17931799
column_family, key = key
@@ -1803,11 +1809,14 @@ cdef class DB(object):
18031809
st = self.db.Delete(opts, cf_handle, c_key)
18041810
check_status(st)
18051811

1806-
def merge(self, key, value, sync=False, disable_wal=False):
1812+
def merge(self, key, value, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False):
18071813
cdef Status st
18081814
cdef options.WriteOptions opts
18091815
opts.sync = sync
18101816
opts.disableWAL = disable_wal
1817+
opts.ignore_missing_column_families = ignore_missing_column_families
1818+
opts.no_slowdown = no_slowdown
1819+
opts.low_pri = low_pri
18111820

18121821
if isinstance(key, tuple):
18131822
column_family, key = key
@@ -1824,11 +1833,14 @@ cdef class DB(object):
18241833
st = self.db.Merge(opts, cf_handle, c_key, c_value)
18251834
check_status(st)
18261835

1827-
def write(self, WriteBatch batch, sync=False, disable_wal=False):
1836+
def write(self, WriteBatch batch, sync=False, disable_wal=False, ignore_missing_column_families=False, no_slowdown=False, low_pri=False):
18281837
cdef Status st
18291838
cdef options.WriteOptions opts
18301839
opts.sync = sync
18311840
opts.disableWAL = disable_wal
1841+
opts.ignore_missing_column_families = ignore_missing_column_families
1842+
opts.no_slowdown = no_slowdown
1843+
opts.low_pri = low_pri
18321844

18331845
with nogil:
18341846
st = self.db.Write(opts, batch.batch)

rocksdb/options.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
164164
cdef cppclass WriteOptions:
165165
cpp_bool sync
166166
cpp_bool disableWAL
167+
cpp_bool ignore_missing_column_families
168+
cpp_bool no_slowdown
169+
cpp_bool low_pri
167170

168171
cdef cppclass ReadOptions:
169172
cpp_bool verify_checksums

rocksdb/tests/test_db.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ def test_compact_range(self):
274274

275275
self.db.compact_range()
276276

277+
def test_write_ignore_missing_column_families(self):
278+
self.db.put(b"a", b"1", ignore_missing_column_families=True)
279+
280+
def test_write_no_slowdown(self):
281+
self.db.put(b"a", b"1", no_slowdown=True)
282+
283+
def test_write_low_pri(self):
284+
self.db.put(b"a", b"1", low_pri=True)
277285

278286
class AssocCounter(rocksdb.interfaces.AssociativeMergeOperator):
279287
def merge(self, key, existing_value, value):

0 commit comments

Comments
 (0)