Skip to content

Commit

Permalink
Make redis store lazy-resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Feb 27, 2024
1 parent 98e322f commit 590c09e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nomenklatura/store/redis_.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ def add_statement(self, stmt: Statement) -> None:
self.flush()
if self.pipeline is None:
self.pipeline = self.store.db.pipeline()
canonical_id = self.store.resolver.get_canonical(stmt.entity_id)
stmt.canonical_id = canonical_id
# canonical_id = self.store.resolver.get_canonical(stmt.entity_id)
stmt.canonical_id = stmt.entity_id

self.pipeline.sadd(b(f"ds:{stmt.dataset}"), b(canonical_id))
key = f"x:{canonical_id}" if stmt.external else f"s:{canonical_id}"
self.pipeline.sadd(b(f"ds:{stmt.dataset}"), b(stmt.entity_id))
key = f"x:{stmt.entity_id}" if stmt.external else f"s:{stmt.entity_id}"
self.pipeline.sadd(b(key), pack_statement(stmt))
if stmt.prop_type == registry.entity.name:
vc = self.store.resolver.get_canonical(stmt.value)
self.pipeline.sadd(b(f"i:{vc}"), b(canonical_id))
self.pipeline.sadd(b(f"i:{vc}"), b(stmt.entity_id))

self.batch_size += 1

Expand All @@ -85,8 +85,8 @@ def pop(self, entity_id: str) -> List[Statement]:
datasets.add(stmt.dataset)

if stmt.prop_type == registry.entity.name:
vc = self.store.resolver.get_canonical(stmt.value)
self.pipeline.srem(b(f"i:{vc}"), b(entity_id))
# vc = self.store.resolver.get_canonical(stmt.value)
self.pipeline.srem(b(f"i:{stmt.value}"), b(entity_id))

for dataset in datasets:
self.pipeline.srem(b(f"ds:{dataset}"), b(entity_id))
Expand Down

0 comments on commit 590c09e

Please sign in to comment.