Skip to content

Commit b7146ce

Browse files
committed
refactor(simprint): remove incomplete mutable multi-type methods
Remove get_raw_multi and delete_raw_multi stub methods from LmdbSimprintIndexMulti. These were incomplete placeholders that returned empty data or did nothing. The class now correctly implements only the base SimprintIndexMulti protocol, not SimprintIndexMutableMulti. Also remove associated tests for these non-functional methods.
1 parent dbf0b79 commit b7146ce

File tree

2 files changed

+4
-93
lines changed

2 files changed

+4
-93
lines changed

iscc_search/indexes/simprint/lmdb_multi.py

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from iscc_search.indexes.simprint.lmdb_core import LmdbSimprintIndex
1515
from iscc_search.indexes.simprint.models import (
16-
SimprintEntryMulti,
1716
SimprintEntryRaw,
1817
SimprintMatchMulti,
1918
TypeMatchResult,
@@ -82,11 +81,14 @@ def add_raw_multi(self, entries):
8281
if self.realm_id is None:
8382
self._extract_realm_id(entries[0].iscc_id)
8483

84+
# Batch validate all realm_ids upfront (fail fast before processing)
85+
for entry in entries:
86+
self._validate_realm_id(entry.iscc_id)
87+
8588
# Group entries by type for batch processing
8689
type_entries = defaultdict(list) # type: dict[str, list[SimprintEntryRaw]]
8790

8891
for entry in entries:
89-
self._validate_realm_id(entry.iscc_id)
9092
iscc_id_body = entry.iscc_id[2:] # Strip 2-byte header
9193

9294
for simprint_type, simprints in entry.simprints.items():
@@ -193,45 +195,6 @@ def __contains__(self, iscc_id):
193195
iscc_id_body = iscc_id[2:]
194196
return any(iscc_id_body in index for index in self.indexes.values())
195197

196-
def get_raw_multi(self, iscc_ids):
197-
# type: (list[bytes]) -> list[SimprintEntryMulti]
198-
"""
199-
Retrieve indexed entries by their ISCC-IDs across all types.
200-
201-
:param iscc_ids: Full ISCC-ID digests (10 bytes each)
202-
:return: List of entries (empty simprints dict for non-existent ISCC-IDs)
203-
"""
204-
results = []
205-
206-
for iscc_id in iscc_ids:
207-
iscc_id_body = iscc_id[2:]
208-
simprints_by_type = {} # type: dict[str, list[SimprintRaw]]
209-
210-
# Query each type-specific index
211-
for simprint_type, index in self.indexes.items():
212-
# LmdbSimprintIndex doesn't have get_raw, so we check containment only
213-
# For full implementation, we'd need to add get_raw to LmdbSimprintIndex
214-
if iscc_id_body in index:
215-
# Placeholder: actual retrieval would require get_raw method
216-
simprints_by_type[simprint_type] = []
217-
218-
results.append(SimprintEntryMulti(iscc_id=iscc_id, simprints=simprints_by_type))
219-
220-
return results
221-
222-
def delete_raw_multi(self, iscc_ids):
223-
# type: (list[bytes]) -> None
224-
"""
225-
Remove assets from all type-specific indexes by their ISCC-IDs.
226-
227-
:param iscc_ids: Full ISCC-ID digests (10 bytes each)
228-
"""
229-
# Delete from each type-specific index
230-
for index in self.indexes.values():
231-
# LmdbSimprintIndex doesn't have delete_raw yet
232-
# For full implementation, we'd need to add delete_raw to LmdbSimprintIndex
233-
pass
234-
235198
def close(self):
236199
# type: () -> None
237200
"""

tests/test_indexes_simprint_lmdb_multi.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -307,44 +307,6 @@ def test_contains_invalid_length(temp_index_path):
307307
index.close()
308308

309309

310-
def test_get_raw_multi(temp_index_path, sample_entries):
311-
# type: (Path, list[SimprintEntryMulti]) -> None
312-
"""Test get_raw_multi retrieves entries."""
313-
index = LmdbSimprintIndexMulti(str(temp_index_path))
314-
index.add_raw_multi(sample_entries)
315-
316-
results = index.get_raw_multi([sample_entries[0].iscc_id])
317-
assert len(results) == 1
318-
assert results[0].iscc_id == sample_entries[0].iscc_id
319-
index.close()
320-
321-
322-
def test_get_raw_multi_non_existing(temp_index_path, sample_entries):
323-
# type: (Path, list[SimprintEntryMulti]) -> None
324-
"""Test get_raw_multi with non-existing ISCC-IDs."""
325-
index = LmdbSimprintIndexMulti(str(temp_index_path))
326-
index.add_raw_multi(sample_entries)
327-
328-
non_existing = b"\x00\x10\xaa\xbb\xcc\xdd\xee\xff\x00\x11"
329-
results = index.get_raw_multi([non_existing])
330-
331-
assert len(results) == 1
332-
assert results[0].iscc_id == non_existing
333-
assert results[0].simprints == {}
334-
index.close()
335-
336-
337-
def test_delete_raw_multi(temp_index_path, sample_entries):
338-
# type: (Path, list[SimprintEntryMulti]) -> None
339-
"""Test delete_raw_multi removes entries (currently a no-op)."""
340-
index = LmdbSimprintIndexMulti(str(temp_index_path))
341-
index.add_raw_multi(sample_entries)
342-
343-
# Delete doesn't raise error (even though not fully implemented)
344-
index.delete_raw_multi([sample_entries[0].iscc_id])
345-
index.close()
346-
347-
348310
def test_close_releases_resources(temp_index_path, sample_entries):
349311
# type: (Path, list[SimprintEntryMulti]) -> None
350312
"""Test close releases all index resources."""
@@ -475,20 +437,6 @@ def test_search_result_ordering(temp_index_path):
475437
index.close()
476438

477439

478-
def test_delete_raw_multi_with_indexes(temp_index_path, sample_entries):
479-
# type: (Path, list[SimprintEntryMulti]) -> None
480-
"""Test delete_raw_multi with populated indexes."""
481-
index = LmdbSimprintIndexMulti(str(temp_index_path))
482-
index.add_raw_multi(sample_entries)
483-
484-
# Ensure indexes exist
485-
assert len(index.indexes) > 0
486-
487-
# Delete should iterate over indexes (even if not fully implemented)
488-
index.delete_raw_multi([sample_entries[0].iscc_id])
489-
index.close()
490-
491-
492440
def test_context_manager_with_exception(temp_index_path, sample_entries):
493441
# type: (Path, list[SimprintEntryMulti]) -> None
494442
"""Test context manager properly closes even with exception."""

0 commit comments

Comments
 (0)