Class JsonFileDataSourceConnector
- All Implemented Interfaces:
DataSourceConnector,AutoCloseable
DataSourceConnector that reads rows from a local JSON file as
open (schema-on-read) documents — the first native nested-data source.
The connector looks up each relation in the semantic model's
SemanticModel.sources() map to obtain its JsonFileSourceConfig,
reads the file at the configured path (resolved against the supplied base
directory), parses it via JsonValues, and yields one
DocumentRow per record object.
Record extraction
Where the records live in the parsed document depends on
JsonFileSourceConfig.records():
- present — the path (e.g.
"data.items") is navigated null-propagatingly into the document; the value found there must be a JSON array, and each element becomes a row. - absent — the top-level value is the record source: an array yields one row per element; a single object yields a single row.
Each record element must be a JSON object (StructValue); a non-object
element raises an EvaluationException (a document row must be a struct).
Schema
JSON sources are open: the schema argument to open(java.lang.String, com.darkcollective.relix.symbol.Schema) is
ignored, and every row reports Schema.open() via its
DocumentRow. Columns are resolved by path at query time.
Resource management
The file is read eagerly into memory; the returned stream holds no open file handle, so closing it is a no-op.
-
Constructor Summary
ConstructorsConstructorDescriptionJsonFileDataSourceConnector(SemanticModel model, Path baseDir) Creates a connector for the given semantic model and base directory. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.darkcollective.relix.processor.internal.DataSourceConnector
close, openQuery, openQuery
-
Constructor Details
-
JsonFileDataSourceConnector
Creates a connector for the given semantic model and base directory.- Parameters:
model- the fully-validated semantic model whosesourcesmap provides JSON path configuration; must not be nullbaseDir- the directory used to resolve relative JSON paths; must not be null
-
-
Method Details
-
open
Opens a stream of document rows for the named JSON-backed relation.- Specified by:
openin interfaceDataSourceConnector- Parameters:
relationName- the canonical (lower-cased) relation nameschema- ignored — JSON sources are open / schema-on-read- Returns:
- a stream of
DocumentRows, one per record object - Throws:
EvaluationException- if no JSON source declaration exists for the relation, the records path does not resolve to an array, or a record element is not an objectUncheckedIOException- if the file cannot be read
-