hydra.query module
A model for language-agnostic graph pattern queries.
- class hydra.query.ComparisonConstraint(*values)
Bases:
EnumOne of several comparison operators.
- EQUAL = Name(value='equal')
- GREATER_THAN = Name(value='greaterThan')
- GREATER_THAN_OR_EQUAL = Name(value='greaterThanOrEqual')
- LESS_THAN = Name(value='lessThan')
- LESS_THAN_OR_EQUAL = Name(value='lessThanOrEqual')
- NOT_EQUAL = Name(value='notEqual')
- TYPE_ = Name(value='hydra.query.ComparisonConstraint')
- class hydra.query.Edge(type: Annotated[Name, 'The name of a record type, for which the edge also specifies an out- and an in- projection'], out: Annotated[object, "The field representing the out-projection of the edge. Defaults to 'out'."], in_: Annotated[object, "The field representing the in-projection of the edge. Defaults to 'in'."])
Bases:
objectAn abstract edge based on a record type.
- class Builder(_type: 'hydra.core.Name' = None, _out: 'Optional[hydra.core.Name]' = None, _in_: 'Optional[hydra.core.Name]' = None)
Bases:
object- build()
- in_(in_)
- out(out)
- type(type)
- IN = Name(value='in')
- OUT = Name(value='out')
- TYPE = Name(value='type')
- TYPE_ = Name(value='hydra.query.Edge')
- static builder()
- out: Annotated[object, "The field representing the out-projection of the edge. Defaults to 'out'."]
- type: Annotated[Name, 'The name of a record type, for which the edge also specifies an out- and an in- projection']
- with_in_(in_)
- with_out(out)
- with_type(type)
- class hydra.query.GraphPattern(graph: Annotated[Name, 'The name of the component graph'], patterns: Annotated[Sequence[Pattern], 'The patterns to match within the subgraph'])
Bases:
objectA query pattern which matches within a designated component subgraph.
- class Builder(_graph: 'hydra.core.Name' = None, _patterns: 'Sequence[Pattern]' = None)
Bases:
object- build()
- graph(graph)
- patterns(patterns)
- GRAPH = Name(value='graph')
- PATTERNS = Name(value='patterns')
- TYPE_ = Name(value='hydra.query.GraphPattern')
- static builder()
- with_graph(graph)
- with_patterns(patterns)
- class hydra.query.NodeTerm(value: T)
Bases:
Node[hydra.core.Term]A graph term; an expression which is valid in the graph being matched
- class hydra.query.NodeVariable(value: T)
-
A query variable, not to be confused with a variable term
- class hydra.query.NodeWildcard
Bases:
objectAn anonymous variable which we do not care to join across patterns
- class hydra.query.Node_
Bases:
objectNodeTerm | NodeVariable | NodeWildcard
- TERM = Name(value='term')
- TYPE_ = Name(value='hydra.query.Node')
- VARIABLE = Name(value='variable')
- WILDCARD = Name(value='wildcard')
- class hydra.query.Path
Bases:
objectPathStep | PathRegex | PathInverse
- INVERSE = Name(value='inverse')
- REGEX = Name(value='regex')
- STEP = Name(value='step')
- TYPE_ = Name(value='hydra.query.Path')
- class hydra.query.PathEquation(left: Annotated[Path, 'The left-hand side of the equation'], right: Annotated[Path, 'The right-hand side of the equation'])
Bases:
objectA declared equivalence between two abstract paths in a graph.
- class Builder(_left: 'Path' = None, _right: 'Path' = None)
Bases:
object- build()
- left(left)
- right(right)
- LEFT = Name(value='left')
- RIGHT = Name(value='right')
- TYPE_ = Name(value='hydra.query.PathEquation')
- static builder()
- with_left(left)
- with_right(right)
- class hydra.query.PathInverse(value: T)
-
A path given by the inverse of another path
- class hydra.query.PathRegex(value: T)
Bases:
Node[RegexSequence]A path given by a regular expression quantifier applied to another path
- class hydra.query.Pattern
Bases:
objectPatternTriple | PatternNegation | PatternConjunction | PatternDisjunction | PatternGraph
- CONJUNCTION = Name(value='conjunction')
- DISJUNCTION = Name(value='disjunction')
- GRAPH = Name(value='graph')
- NEGATION = Name(value='negation')
- TRIPLE = Name(value='triple')
- TYPE_ = Name(value='hydra.query.Pattern')
- class hydra.query.PatternConjunction(value: T)
Bases:
Node[Sequence[Pattern]]The conjunction (‘and’) of several other patterns
- class hydra.query.PatternDisjunction(value: T)
Bases:
Node[Sequence[Pattern]]The disjunction (inclusive ‘or’) of several other patterns
- class hydra.query.PatternGraph(value: T)
Bases:
Node[GraphPattern]A pattern which matches within a named subgraph
- class hydra.query.PatternImplication(antecedent: Annotated[Pattern, 'The pattern which, if it matches, triggers the constraint'], consequent: Annotated[Pattern, 'The pattern which must also match when the antecedent matches'])
Bases:
objectA pattern which, if it matches in a given graph, implies that another pattern must also match. Query variables are shared between the two patterns.
- ANTECEDENT = Name(value='antecedent')
- class Builder(_antecedent: 'Pattern' = None, _consequent: 'Pattern' = None)
Bases:
object- antecedent(antecedent)
- build()
- consequent(consequent)
- CONSEQUENT = Name(value='consequent')
- TYPE_ = Name(value='hydra.query.PatternImplication')
- static builder()
- with_antecedent(antecedent)
- with_consequent(consequent)
- class hydra.query.PatternTriple(value: T)
Bases:
Node[TriplePattern]A subject/predicate/object pattern
- class hydra.query.Query(variables: Annotated[Sequence[Variable], 'The variables selected by the query'], patterns: Annotated[Sequence[Pattern], 'The patterns to be matched'])
Bases:
objectA SELECT-style graph pattern matching query.
- class Builder(_variables: 'Sequence[Variable]' = None, _patterns: 'Sequence[Pattern]' = None)
Bases:
object- build()
- patterns(patterns)
- variables(variables)
- PATTERNS = Name(value='patterns')
- TYPE_ = Name(value='hydra.query.Query')
- VARIABLES = Name(value='variables')
- static builder()
- with_patterns(patterns)
- with_variables(variables)
- class hydra.query.Range(min: Annotated[int, 'The minimum value (inclusive)'], max: Annotated[int, 'The maximum value (inclusive)'])
Bases:
objectA range from min to max, inclusive.
- MAX = Name(value='max')
- MIN = Name(value='min')
- TYPE_ = Name(value='hydra.query.Range')
- static builder()
- max: Annotated[int, 'The maximum value (inclusive)']
- min: Annotated[int, 'The minimum value (inclusive)']
- with_max(max)
- with_min(min)
- class hydra.query.RegexQuantifier
Bases:
objectRegexQuantifierOne | RegexQuantifierZeroOrOne | RegexQuantifierZeroOrMore | RegexQuantifierOneOrMore | RegexQuantifierExactly | RegexQuantifierAtLeast | RegexQuantifierRange
- AT_LEAST = Name(value='atLeast')
- EXACTLY = Name(value='exactly')
- ONE = Name(value='one')
- ONE_OR_MORE = Name(value='oneOrMore')
- RANGE = Name(value='range')
- TYPE_ = Name(value='hydra.query.RegexQuantifier')
- ZERO_OR_MORE = Name(value='zeroOrMore')
- ZERO_OR_ONE = Name(value='zeroOrOne')
- class hydra.query.RegexQuantifierAtLeast(value: T)
Bases:
Node[int]The {n,} quantifier; matches at least n occurrences
- class hydra.query.RegexQuantifierExactly(value: T)
Bases:
Node[int]The {n} quantifier; matches exactly n occurrences
- class hydra.query.RegexQuantifierOne
Bases:
objectNo quantifier; matches a single occurrence
- class hydra.query.RegexQuantifierOneOrMore
Bases:
objectThe + quantifier; matches one or more occurrences
- class hydra.query.RegexQuantifierRange(value: T)
-
The {n, m} quantifier; matches between n and m (inclusive) occurrences
- class hydra.query.RegexQuantifierZeroOrMore
Bases:
objectThe * quantifier; matches any number of occurrences
- class hydra.query.RegexQuantifierZeroOrOne
Bases:
objectThe ? quanifier; matches zero or one occurrence
- class hydra.query.RegexSequence(path: Annotated[Path, 'The path to which the quantifier applies'], quantifier: Annotated[RegexQuantifier, 'The quantifier'])
Bases:
objectA path with a regex quantifier.
- class Builder(_path: 'Path' = None, _quantifier: 'RegexQuantifier' = None)
Bases:
object- build()
- path(path)
- quantifier(quantifier)
- PATH = Name(value='path')
- QUANTIFIER = Name(value='quantifier')
- TYPE_ = Name(value='hydra.query.RegexSequence')
- static builder()
- quantifier: Annotated[RegexQuantifier, 'The quantifier']
- with_path(path)
- with_quantifier(quantifier)
- class hydra.query.Step
Bases:
objectStepEdge | StepProject | StepCompare
- COMPARE = Name(value='compare')
- EDGE = Name(value='edge')
- PROJECT = Name(value='project')
- TYPE_ = Name(value='hydra.query.Step')
- class hydra.query.StepCompare(value: T)
Bases:
Node[ComparisonConstraint]A comparison of two terms
- class hydra.query.StepProject(value: T)
Bases:
Node[hydra.core.Projection]A projection from a record through one of its fields
- class hydra.query.TriplePattern(subject: Annotated[Node_, 'The subject of the pattern'], predicate: Annotated[Path, 'The predicate (property) of the pattern'], object: Annotated[Node_, 'The object of the pattern'])
Bases:
objectA subject/predicate/object pattern.
- class Builder(_subject: 'Node_' = None, _predicate: 'Path' = None, _object: 'Node_' = None)
Bases:
object- build()
- object(object)
- predicate(predicate)
- subject(subject)
- OBJECT = Name(value='object')
- PREDICATE = Name(value='predicate')
- SUBJECT = Name(value='subject')
- TYPE_ = Name(value='hydra.query.TriplePattern')
- static builder()
- with_object(object)
- with_predicate(predicate)
- with_subject(subject)