Skip to content

Commit

Permalink
iter_prefixes_upto_delimiter => iter_prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crepererum authored and fmarczin committed Jul 26, 2019
1 parent 3c4ba59 commit c05ea19
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion simplekv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def iter_keys(self, prefix=u""):
"""
raise NotImplementedError

def iter_prefixes_upto_delimiter(self, delimiter, prefix=u""):
def iter_prefixes(self, delimiter, prefix=u""):
"""Returns an Iterator over all prefixes currently in the store, in any order. The
prefixes are listed up to the given delimiter.
Expand Down
2 changes: 1 addition & 1 deletion simplekv/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def iter_keys(self, prefix=u""):
return (self._unmap_key(k) for k in self._dstore.iter_keys(self._map_key_prefix(prefix))
if self._filter(k))

def iter_prefixes_upto_delimiter(self, delimiter, prefix=u""):
def iter_prefixes(self, delimiter, prefix=u""):
dlen = len(delimiter)
plen = len(prefix)
memory = set()
Expand Down
8 changes: 4 additions & 4 deletions simplekv/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ def keys(self, prefix=u""):
def iter_keys(self, prefix=u""):
return iter(self.keys(prefix))

def iter_prefixes_upto_delimiter(self, delimiter, prefix=u""):
def iter_prefixes(self, delimiter, prefix=u""):
if delimiter != os.sep:
return super(FilesystemStore, self).iter_prefixes_upto_delimiter(
return super(FilesystemStore, self).iter_prefixes(
delimiter,
prefix,
)
return self._iter_prefixes_upto_delimiter_efficient(delimiter, prefix)
return self._iter_prefixes_efficient(delimiter, prefix)

def _iter_prefixes_upto_delimiter_efficient(self, delimiter, prefix=u""):
def _iter_prefixes_efficient(self, delimiter, prefix=u""):
if delimiter in prefix:
pos = prefix.rfind(delimiter)
search_prefix = prefix[:pos]
Expand Down
2 changes: 1 addition & 1 deletion simplekv/net/azurestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def iter_keys(self, prefix=u""):
return (blob.decode('utf-8') if isinstance(blob, binary_type)
else blob for blob in blobs)

def iter_prefixes_upto_delimiter(self, delimiter, prefix=u""):
def iter_prefixes(self, delimiter, prefix=u""):
if prefix == "":
prefix = None
with map_azure_exceptions():
Expand Down
8 changes: 4 additions & 4 deletions tests/basic_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_key_iterator_with_prefix(self, store, key, key2, value):
l.sort()
assert l == sorted([key_prefix_1, key_prefix_2])

def test_prefix_iterator_upto_delimiter(self, store, value):
def test_prefix_iterator(self, store, value):
delimiter = u"X"
for k in [
u"X",
Expand All @@ -237,13 +237,13 @@ def test_prefix_iterator_upto_delimiter(self, store, value):
]:
store.put(k, value)

l = sorted(store.iter_prefixes_upto_delimiter(u"X"))
l = sorted(store.iter_prefixes(u"X"))
assert l == [u"X", u"a1X", u"a2X", u"a3", u"a4X"]

l = sorted(store.iter_prefixes_upto_delimiter(u"X", prefix=u"a4X"))
l = sorted(store.iter_prefixes(u"X", prefix=u"a4X"))
assert l == [u"a4Xb1X", u"a4Xb2X", u"a4Xb3"]

l = sorted(store.iter_prefixes_upto_delimiter(u"X", prefix=u"foo"))
l = sorted(store.iter_prefixes(u"X", prefix=u"foo"))
assert l == []

def test_keys(self, store, key, key2, value, value2):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_filesystem_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ExtendedKeyspaceStore(ExtendedKeyspaceMixin, FilesystemStore):
pass
return ExtendedKeyspaceStore(tmpdir)

def test_prefix_iterator_upto_delimiter_ossep(self, store, value):
def test_prefix_iterator_ossep(self, store, value):
delimiter = u"X"
for k in [
u"a1" + os.sep + u"b1",
Expand All @@ -188,15 +188,15 @@ def test_prefix_iterator_upto_delimiter_ossep(self, store, value):
]:
store.put(k, value)

l = sorted(store.iter_prefixes_upto_delimiter(os.sep))
l = sorted(store.iter_prefixes(os.sep))
assert l == [
u"a1" + os.sep,
u"a2" + os.sep,
u"a3",
u"a4" + os.sep,
]

l = sorted(store.iter_prefixes_upto_delimiter(
l = sorted(store.iter_prefixes(
os.sep,
prefix=u"a4" + os.sep,
))
Expand All @@ -206,7 +206,7 @@ def test_prefix_iterator_upto_delimiter_ossep(self, store, value):
u"a4" + os.sep + "b3",
]

l = sorted(store.iter_prefixes_upto_delimiter(
l = sorted(store.iter_prefixes(
os.sep,
prefix=u"foo" + os.sep,
))
Expand Down

0 comments on commit c05ea19

Please sign in to comment.