Skip to content

Commit

Permalink
bump version; some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
oberstet committed Feb 14, 2019
1 parent eeaa05d commit 1a16bd9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning
ignore::DeprecationWarning
norecursedirs =
flatbuffers
2 changes: 1 addition & 1 deletion zlmdb/_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def maxsize(self):
return self._maxsize

@property
def sync(self):
def is_sync(self):
return self._sync

@property
Expand Down
18 changes: 18 additions & 0 deletions zlmdb/_pmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@


class PersistentMapIterator(object):
"""
Iterator that walks over zLMDB database records.
"""
def __init__(self,
txn,
pmap,
Expand All @@ -60,6 +63,17 @@ def __init__(self,
return_values=True,
reverse=False,
limit=None):
"""
:param txn:
:param pmap:
:param from_key:
:param to_key:
:param return_keys:
:param return_values:
:param reverse:
:param limit:
"""
self._txn = txn
self._pmap = pmap

Expand Down Expand Up @@ -224,6 +238,10 @@ def __init__(self, slot, compress=None):
self._indexes = {}

def indexes(self):
"""
:return:
"""
return sorted(self._indexes.keys())

def attach_index(self, name, pmap, fkey):
Expand Down
39 changes: 39 additions & 0 deletions zlmdb/_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,47 @@


class TransactionStats(object):
"""
Value class for holding transaction statistics.
"""
def __init__(self):
self.puts = 0
self.dels = 0
self._started = walltime()

@property
def started(self):
"""
:return:
"""
return self._started

@property
def duration(self):
"""
:return:
"""
if self._started:
return walltime() - self._started
else:
return 0

def reset(self):
"""
:return:
"""
self.puts = 0
self.dels = 0
self._started = walltime()


class Transaction(object):
"""
Transactions in zLMDB are always run under an instance of this class.
"""

PUT = 1
DEL = 2
Expand Down Expand Up @@ -120,16 +138,32 @@ def __exit__(self, exc_type, exc_value, traceback):
self._txn = None

def id(self):
"""
:return:
"""
assert (self._txn is not None)

return self._txn.id()

def get(self, key):
"""
:param key:
:return:
"""
assert (self._txn is not None)

return self._txn.get(key)

def put(self, key, data, overwrite=True):
"""
:param key:
:param data:
:param overwrite:
:return:
"""
assert (self._txn is not None)

# store the record, returning True if it was written, or False to indicate the key
Expand All @@ -143,6 +177,11 @@ def put(self, key, data, overwrite=True):
return was_written

def delete(self, key):
"""
:param key:
:return:
"""
assert (self._txn is not None)

was_deleted = self._txn.delete(key)
Expand Down
2 changes: 1 addition & 1 deletion zlmdb/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

from __future__ import absolute_import

__version__ = u'19.1.1'
__version__ = u'19.2.1'

0 comments on commit 1a16bd9

Please sign in to comment.