graflo.db.cypher.introspection¶
Sampling introspection for the Cypher family.
Neo4j, Memgraph and FalkorDB answer "what is in this graph?" with the same four
queries -- list labels, sample a label's property keys, list the distinct
(source, type, target) patterns, sample a pattern's property keys -- so one
collector serves all three, the same reason :func:cypher_rel_pattern and
:func:cypher_graph_neighbors are shared.
What genuinely differs is only how a driver hands back rows: the Neo4j driver returns records addressable by name, while the Memgraph and FalkorDB wrappers return tuples plus a column list. Callers supply run to bridge that, exactly as they already do for traversal.
This is sampling, not a catalogue read. A property that appears on no sampled
node is not reported, so the recovered schema is a lower bound on the real one --
which is why :attr:GraphIntrospectionResult.sample_limit travels with the
result rather than being discarded.
collect_cypher_introspection(*, name, run, sample_limit=100)
¶
Sample a Cypher-family graph into a :class:GraphIntrospectionResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for the recovered schema. |
required |
run
|
CypherRunner
|
Executes a query and returns rows as dicts keyed by the given
|
required |
sample_limit
|
int
|
Nodes/relationships examined per type. Higher costs more and recovers rarer properties; it never affects which types are found, only which properties. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
GraphIntrospectionResult |
GraphIntrospectionResult
|
with |
GraphIntrospectionResult
|
consumer cannot judge the result without knowing how it was obtained. |
Note
directed is left at True throughout. An undirected edge is stored
in one orientation on this family and observed in one orientation, so
sampling cannot distinguish it from a directed one -- claiming otherwise
would silently widen every query built on the recovered schema.
Source code in graflo/db/cypher/introspection.py
collect_cypher_labels(run)
¶
List node labels, falling back to a full scan when the procedure is absent.