@@ -1521,7 +1521,20 @@ def DownstreamClassConnectivity_to_schema(name, take_default):
15211521 Schema for downstream class connectivity query.
15221522 Shows which neuron classes receive synapses from this neuron class.
15231523 Matching criteria: Class + Neuron
1524- Query chain: Solr downstream_connectivity_query field
1524+
1525+ Implementation: multi-step aggregation, not a single Solr lookup.
1526+ 1. Neo4j: instances in the SUBCLASSOF closure of the queried class.
1527+ 2. Solr cache (batched): per-instance synaptic partners.
1528+ 3. Solr: direct partner classes from the downstream_connectivity_query
1529+ field (seed set for the partner-side ancestor walk).
1530+ 4. Neo4j: walk SUBCLASSOF up from each direct partner to the neuron root.
1531+ 5. Neo4j (batched): partner_instance -> {class_ids} membership map.
1532+ 6. In-memory aggregation with set-union semantics to handle FBbt
1533+ multi-inheritance without double-counting.
1534+
1535+ Results are cached server-side (@with_solr_cache) per queried class, so
1536+ repeat calls return in milliseconds, but cold calls on broad classes can
1537+ take tens of seconds.
15251538 """
15261539 query = "DownstreamClassConnectivity"
15271540 label = f"Downstream connectivity classes for { name } "
@@ -1540,7 +1553,11 @@ def UpstreamClassConnectivity_to_schema(name, take_default):
15401553 Schema for upstream class connectivity query.
15411554 Shows which neuron classes send synapses to this neuron class.
15421555 Matching criteria: Class + Neuron
1543- Query chain: Solr upstream_connectivity_query field
1556+
1557+ Implementation: same multi-step aggregation as
1558+ DownstreamClassConnectivity but with the upstream_connectivity_query
1559+ Solr field as the seed for the partner-side ancestor walk. See
1560+ DownstreamClassConnectivity_to_schema for the full pipeline.
15441561 """
15451562 query = "UpstreamClassConnectivity"
15461563 label = f"Upstream connectivity classes for { name } "
@@ -3404,13 +3421,19 @@ def get_downstream_class_connectivity(short_form: str, return_dataframe=True, li
34043421 """
34053422 Retrieves downstream connectivity classes for the specified neuron class.
34063423
3407- Uses OWLERY to expand subclasses of the queried class, fetches per-instance
3424+ Uses a Neo4j SUBCLASSOF traversal to enumerate instances of the queried
3425+ class (Owlery's get_instances was observed to hang for some classes;
3426+ Cypher is equivalent and fast here), bulk-fetches per-instance
34083427 connectivity from the Solr cache, and aggregates by partner class with
34093428 set-union semantics on partner instance memberships. The partner-side
3410- hierarchy is walked up to ``NEURON_ROOT_SHORT_FORM`` so that connections to
3411- a child class also count toward each ancestor class's row, without
3429+ hierarchy is walked up to ``NEURON_ROOT_SHORT_FORM`` so that connections
3430+ to a child class also count toward each ancestor class's row, without
34123431 double-counting under FBbt multi-inheritance.
34133432
3433+ Server-side cached via ``@with_solr_cache``; cold calls on broad classes
3434+ can take tens of seconds because of the aggregation work (already batched
3435+ across Solr/Neo4j round-trips).
3436+
34143437 Matching criteria: Class + Neuron
34153438
34163439 :param short_form: short form of the neuron class
@@ -3454,12 +3477,15 @@ def get_upstream_class_connectivity(short_form: str, return_dataframe=True, limi
34543477 """
34553478 Retrieves upstream connectivity classes for the specified neuron class.
34563479
3457- Uses OWLERY to expand subclasses of the queried class, fetches per-instance
3458- connectivity from the Solr cache, and aggregates by partner class with
3459- set-union semantics on partner instance memberships. The partner-side
3460- hierarchy is walked up to ``NEURON_ROOT_SHORT_FORM`` so that connections
3461- from a child class also count toward each ancestor class's row, without
3462- double-counting under FBbt multi-inheritance.
3480+ Same multi-step aggregation as ``get_downstream_class_connectivity`` but
3481+ walking the upstream side: Neo4j SUBCLASSOF enumerates queried-class
3482+ instances, batched Solr cache fetches their synaptic partners, and the
3483+ partner-side hierarchy is walked up to ``NEURON_ROOT_SHORT_FORM`` with
3484+ set-union semantics to avoid double-counting under FBbt multi-inheritance.
3485+
3486+ Server-side cached via ``@with_solr_cache``; cold calls on broad classes
3487+ can take tens of seconds because of the aggregation work (already batched
3488+ across Solr/Neo4j round-trips).
34633489
34643490 Matching criteria: Class + Neuron
34653491
0 commit comments