Skip to content

Commit

Permalink
fix: filtering missing keys accounts for values (#1694)
Browse files Browse the repository at this point in the history
* fix: missing keys indices
  • Loading branch information
cristianmtr committed Jan 15, 2021
1 parent 8410137 commit 321a890
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions jina/executors/indexers/__init__.py
Expand Up @@ -165,6 +165,8 @@ def flush(self):
def _filter_nonexistent_keys_values(self, keys: Iterator, values: Iterator, existent_keys: Iterator, check_path: str) -> Tuple[List, List]:
keys = list(keys)
values = list(values)
if len(keys) != len(values):
raise ValueError(f'Keys of length {len(keys)} did not match values of lenth {len(values)}')
indices_to_drop = self._get_indices_to_drop(keys, existent_keys, check_path)
keys = [keys[i] for i in range(len(keys)) if i not in indices_to_drop]
values = [values[i] for i in range(len(values)) if i not in indices_to_drop]
Expand Down
2 changes: 1 addition & 1 deletion jina/executors/indexers/keyvalue.py
Expand Up @@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs):
self._page_size = mmap.ALLOCATIONGRANULARITY

def add(self, keys: Iterator[int], values: Iterator[bytes], *args, **kwargs):
if len(keys) != len(values):
if len(list(keys)) != len(list(values)):
raise ValueError(f'Len of keys {len(keys)} did not match len of values {len(values)}')
for key, value in zip(keys, values):
l = len(value) #: the length
Expand Down

0 comments on commit 321a890

Please sign in to comment.