|
37 | 37 |
|
38 | 38 | from numcodecs.compat import (
|
39 | 39 | ensure_bytes,
|
| 40 | + ensure_text, |
40 | 41 | ensure_contiguous_ndarray
|
41 | 42 | )
|
42 | 43 | from numcodecs.registry import codec_registry
|
@@ -1770,16 +1771,6 @@ def __contains__(self, key):
|
1770 | 1771 | return key in self.db
|
1771 | 1772 |
|
1772 | 1773 |
|
1773 |
| -def _lmdb_decode_key_buffer(key): |
1774 |
| - # assume buffers=True |
1775 |
| - return key.tobytes().decode('ascii') |
1776 |
| - |
1777 |
| - |
1778 |
| -def _lmdb_decode_key_bytes(key): |
1779 |
| - # assume buffers=False |
1780 |
| - return key.decode('ascii') |
1781 |
| - |
1782 |
| - |
1783 | 1774 | class LMDBStore(MutableMapping):
|
1784 | 1775 | """Storage class using LMDB. Requires the `lmdb <http://lmdb.readthedocs.io/>`_
|
1785 | 1776 | package to be installed.
|
@@ -1869,10 +1860,6 @@ def __init__(self, path, buffers=True, **kwargs):
|
1869 | 1860 | self.db = lmdb.open(path, **kwargs)
|
1870 | 1861 |
|
1871 | 1862 | # store properties
|
1872 |
| - if buffers: |
1873 |
| - self.decode_key = _lmdb_decode_key_buffer |
1874 |
| - else: |
1875 |
| - self.decode_key = _lmdb_decode_key_bytes |
1876 | 1863 | self.buffers = buffers
|
1877 | 1864 | self.path = path
|
1878 | 1865 | self.kwargs = kwargs
|
@@ -1933,13 +1920,13 @@ def items(self):
|
1933 | 1920 | with self.db.begin(buffers=self.buffers) as txn:
|
1934 | 1921 | with txn.cursor() as cursor:
|
1935 | 1922 | for k, v in cursor.iternext(keys=True, values=True):
|
1936 |
| - yield self.decode_key(k), v |
| 1923 | + yield ensure_text(k, "ascii"), v |
1937 | 1924 |
|
1938 | 1925 | def keys(self):
|
1939 | 1926 | with self.db.begin(buffers=self.buffers) as txn:
|
1940 | 1927 | with txn.cursor() as cursor:
|
1941 | 1928 | for k in cursor.iternext(keys=True, values=False):
|
1942 |
| - yield self.decode_key(k) |
| 1929 | + yield ensure_text(k, "ascii") |
1943 | 1930 |
|
1944 | 1931 | def values(self):
|
1945 | 1932 | with self.db.begin(buffers=self.buffers) as txn:
|
|
0 commit comments