hydra.pg.coder module

Property graph element coders for mapping Hydra terms to property graph elements.

hydra.pg.coder.check(_cx: T0, b: bool, e: object) object

Check a condition, returning an error if false.

hydra.pg.coder.check_record_name(cx: T0, expected: Name, actual: Name) object

Check that a record name matches the expected name.

hydra.pg.coder.construct_edge_coder(cx: T0, g: Graph, parent_label: VertexLabel, schema: Schema[T1, T2, T3, Error], source: Type, vid_type: T2, eid_type: T2, dir: Direction, name: Name, fields: Sequence[FieldType], prop_adapters: Sequence[Adapter[FieldType, PropertyType[T2], Field, Property[T3], Error]], m_out_spec: object, m_in_spec: object) object

Construct an edge coder from components.

hydra.pg.coder.construct_vertex_coder(cx: T0, g: Graph, schema: Schema[T1, T2, T3, Error], source: Type, vid_type: T2, eid_type: T2, name: Name, fields: Sequence[FieldType], prop_adapters: Sequence[Adapter[FieldType, PropertyType[T2], Field, Property[T3], Error]]) object

Construct a vertex coder from components.

hydra.pg.coder.edge_coder(cx: T0, g: T1, dir: Direction, schema: Schema[T2, T3, T4, T5], source: T6, eid_type: T7, tname: Name, label: EdgeLabel, out_label: VertexLabel, in_label: VertexLabel, m_id_adapter: object, out_adapter: object, in_adapter: object, prop_adapters: Sequence[Adapter[FieldType, PropertyType[T7], Field, Property[T4], Error]], vertex_adapters: Sequence[tuple[Name, Adapter[T14, T15, Term, ElementTree[T4], Error]]]) Adapter[T6, ElementTypeTree[T7], Term, ElementTree[T4], Error]

Create an edge coder given all components.

hydra.pg.coder.edge_id_adapter(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], eid_type: T5, name: Name, id_key: Name, fields: Sequence[FieldType]) object

Create an edge id adapter.

hydra.pg.coder.element_coder(mparent: object, schema: Schema[T0, T1, T2, Error], source: Type, vid_type: T1, eid_type: T1, cx: T3, g: Graph) object

Construct an element adapter for a given type, interpreting it either as a vertex specification or an edge specification.

hydra.pg.coder.element_tree_edge(edge: Edge[T0], deps: Sequence[ElementTree[T0]]) ElementTree[T0]

Create an element tree for an edge.

hydra.pg.coder.element_tree_vertex(vertex: Vertex[T0], deps: Sequence[ElementTree[T0]]) ElementTree[T0]

Create an element tree for a vertex.

hydra.pg.coder.element_type_tree_edge(etype: EdgeType[T0], deps: Sequence[ElementTypeTree[T0]]) ElementTypeTree[T0]

Create an element type tree for an edge type.

hydra.pg.coder.element_type_tree_vertex(vtype: VertexType[T0], deps: Sequence[ElementTypeTree[T0]]) ElementTypeTree[T0]

Create an element type tree for a vertex type.

hydra.pg.coder.encode_properties(cx: T0, fields: Mapping[Name, Term], adapters: Sequence[Adapter[FieldType, T1, Field, Property[T2], Error]]) object

Encode all properties from a field map using property adapters.

hydra.pg.coder.encode_property(cx: T0, fields: Mapping[Name, Term], adapter: Adapter[FieldType, T1, Field, T2, Error]) object

Encode a single property from a field map using a property adapter.

hydra.pg.coder.extract_string(cx: T0, g: Graph, t: Term) object

Extract a string from a term.

hydra.pg.coder.find_adjacen_edge_adapters(cx: T0, g: Graph, schema: Schema[T1, T2, T3, Error], vid_type: T2, eid_type: T2, parent_label: VertexLabel, dir: Direction, fields: Sequence[FieldType]) object

Find adjacent edge adapters for a given direction.

hydra.pg.coder.find_id_projection_spec(cx: T0, required: bool, tname: Name, id_key: Name, fields: Sequence[FieldType]) object

Find an id projection spec for a field.

hydra.pg.coder.find_incident_vertex_adapter(cx: T0, g: Graph, schema: Schema[T1, T2, T3, Error], vid_type: T2, eid_type: T2, spec: tuple[FieldType, tuple[ValueSpec, object]]) object

Find an incident vertex adapter for a projection spec.

hydra.pg.coder.find_label_string(cx: T0, g: Graph, source: Type, tname: Name, label_key: Name) object

Find a label string from annotations or the type name.

hydra.pg.coder.find_projection_spec(cx: T0, g: Graph, tname: Name, key: Name, alias_key: Name, fields: Sequence[FieldType]) object

Find a projection spec for a field.

hydra.pg.coder.find_property_specs(cx: T0, g: Graph, schema: Schema[T1, T2, T3, T4], kind: ElementKind, fields: Sequence[FieldType]) object

Find property specs for element fields.

hydra.pg.coder.find_single_field_with_annotation_key(cx: T0, tname: Name, key: Name, fields: Sequence[FieldType]) object

Find a single field with a given annotation key.

hydra.pg.coder.has_vertex_adapters(dir: Direction, m_out_spec: object, m_in_spec: object) bool

Determine whether the spec has vertex adapters based on direction and out/in specs.

hydra.pg.coder.projection_adapter(cx: T0, g: T1, idtype: T2, coder: Coder[Term, T3, Error], spec: tuple[FieldType, tuple[ValueSpec, T4]], key: str) object

Create a projection adapter from a projection spec.

hydra.pg.coder.property_adapter(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: tuple[FieldType, tuple[ValueSpec, object]]) object

Create a property adapter from a property spec.

hydra.pg.coder.property_types(prop_adapters: Sequence[Adapter[T0, PropertyType[T1], T2, T3, T4]]) Sequence[PropertyType[T1]]

Extract property types from property adapters.

hydra.pg.coder.select_edge_id(cx: T0, fields: Mapping[Name, T1], ad: tuple[Name, Adapter[T2, T3, T1, T4, Error]]) object

Select an edge id from record fields using an id adapter.

hydra.pg.coder.select_vertex_id(cx: T0, fields: Mapping[Name, T1], ad: tuple[Name, Adapter[T2, T3, T1, T4, Error]]) object

Select a vertex id from record fields using an id adapter.

hydra.pg.coder.traverse_to_single_term(cx: T0, desc: str, traversal: Callable[[T1], object], term: T1) object

Traverse to a single term, failing if zero or multiple terms are found.

hydra.pg.coder.vertex_coder(cx: T0, g: T1, schema: Schema[T2, T3, T4, T5], source: T6, vid_type: T7, tname: T8, vlabel: VertexLabel, id_adapter: tuple[Name, Adapter[T9, T10, Term, T4, Error]], prop_adapters: Sequence[Adapter[FieldType, PropertyType[T7], Field, Property[T4], Error]], edge_adapters: Sequence[tuple[Direction, tuple[FieldType, tuple[EdgeLabel, Adapter[T11, ElementTypeTree[T7], Term, ElementTree[T4], Error]]]]]) Adapter[T6, ElementTypeTree[T7], Term, ElementTree[T4], Error]

Create a vertex coder given all components.

hydra.pg.coder.vertex_id_adapter(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], vid_type: T5, name: Name, id_key: Name, fields: Sequence[FieldType]) object

Create a vertex id adapter.