java.lang.Object
com.darkcollective.relix.connectors.std.internal.GedcomConnector
All Implemented Interfaces:
RelixConnector, AutoCloseable

public final class GedcomConnector extends Object implements RelixConnector
Reads a GEDCOM genealogy file as a pair of relations.

One file holds many kinds of record, which is why this is a connection rather than a file source: a CSV file is one relation and a .ged file is several, and a connection is exactly the thing several tables share.


 connection ancestry from gedcom { path: "family.ged" };

 source Individuals from ancestry { table: "individuals",
     schema: { id: STRING, name: STRING, surname: STRING, sex: STRING,
               birth: { date: DATE, text: STRING, place: STRING } } };
 

Two tables

individuals and families. Their fields are id, name, surname, sex, birth, death and id, husband, wife, children respectively, where an event (birth/death) has date, text and place, and children is an array of individual ids.

The declared schema decides the heading

Every column is filled by name, at every level, and a column this connector has nothing for is NULL rather than an error. So a schema naming only id and name gets two columns, and one naming a nested birth: { place: STRING } gets a one-field struct. That rule is what makes a format as extensible as GEDCOM safe to declare a heading over: the file cannot widen a relation behind the query's back.

A family is a hyperedge — two parents and any number of children — so the binary parent→child edge the graph operators take is a projection over μ children (families) rather than something this connector invents.

  • Constructor Details

    • GedcomConnector

      public GedcomConnector()
      Public no-arg constructor required for ServiceLoader discovery.
  • Method Details

    • handles

      public Set<String> handles()
      Description copied from interface: RelixConnector
      The type tokens this connector handles, lower-cased — e.g. {"jdbc"}, {"csv"}, {"mongodb"}. The registry uses these for dispatch.
      Specified by:
      handles in interface RelixConnector
      Returns:
      a non-empty set of handled type tokens
    • tableSchema

      public Optional<Schema> tableSchema(ConnectorConfig config, String table)
      Introspects the schema of a table, when the backend supports it. The default returns empty — "not available", in which case the declared schema is used as-is.

      GEDCOM's shape is fixed by the format rather than by the file, so both tables are described without opening anything. That is also what makes a declared schema optional rather than obligatory: a dotted reference resolves its columns here, and a script that wants fewer columns — or different names for them — still declares them.

      Answering without reading the file means an unreadable or absent one does not stop analysis, which is the same degradation a database that will not connect gets.

      Specified by:
      tableSchema in interface RelixConnector
      Parameters:
      config - the connector configuration
      table - the table/collection name
      Returns:
      the introspected schema, or empty when unavailable
    • open

      public Stream<Row> open(ConnectorConfig config, String table, Schema schema)
      Description copied from interface: RelixConnector
      Opens a stream of rows for a named table/collection/endpoint. The caller closes the returned stream.
      Specified by:
      open in interface RelixConnector
      Parameters:
      config - the connector configuration for this relation
      table - the table/collection/endpoint name within the source
      schema - the expected output schema (column order and types)
      Returns:
      a stream of rows; the caller is responsible for closing it