MCPcopy Create free account
hub / github.com/alephdata/aleph / resolve

Function resolve

aleph/logic/resolver.py:47–74  ·  view source on GitHub ↗
(stub)

Source from the content-addressed store, hash-verified

45
46
47def resolve(stub):
48 _instrument_stub(stub)
49 cache_keys = {}
50 schemata = {}
51 for clazz, key, schema in stub._rx_queue:
52 if (clazz, key) in stub._rx_cache:
53 continue
54
55 cid = cache.object_key(clazz, key)
56 cache_keys[cid] = (clazz, key)
57 schemata[cid] = schema
58
59 keys = list(cache_keys.keys())
60 queries = defaultdict(list)
61 for cid, value in cache.get_many_complex(keys):
62 clazz, key = cache_keys.get(cid)
63 if value is None:
64 # log.info("MISS [%s]: %s", clazz.__name__, key)
65 if clazz == Entity:
66 queries[schemata.get(cid)].append(key)
67 loader = LOADERS.get(clazz)
68 if loader is not None:
69 value = loader(key)
70 stub._rx_cache[(clazz, key)] = value
71
72 for schema, ids in queries.items():
73 for entity in entities_by_ids(ids, schemata=schema, cached=True):
74 stub._rx_cache[(Entity, entity.get("id"))] = entity
75
76
77def get(stub, clazz, key):

Callers 2

getEntitySuggestionsMethod · 0.85

Calls 6

entities_by_idsFunction · 0.90
_instrument_stubFunction · 0.85
object_keyMethod · 0.80
get_many_complexMethod · 0.80
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected