Evaluators¶
An evaluator turns a logical view into rows. CARML has three, and picks one per view.
| Evaluator | Add this module | How it runs a view |
|---|---|---|
| Reactive | carml-logical-view (comes with carml-engine) |
Reads records with a source resolver and streams them. Joins run in memory. |
| Native SQL | carml-logical-view-sql-mysql or carml-logical-view-sql-postgresql |
Sends one SQL query, joins included, to the database and streams the result. |
| DuckDB | carml-logical-view-duckdb |
Compiles the view to one query in an in-process DuckDB database. |
How one is picked¶
Each evaluator on the classpath scores a view, and the highest score wins.
- Native SQL scores highest. It takes a view when every source in it, joined views included, is the same MySQL or PostgreSQL database.
- DuckDB comes next. It takes a view when every source in it is a JSON file, a CSV file, or a MySQL or PostgreSQL
database, and the view compiles to SQL. It declines XML,
carml:Streamsources, compressed JSON, zip, tar and UTF-16 files, and views that use a function in a field or a join condition. - Reactive accepts every view with the lowest score, so it takes whatever the others decline. It can read JSON, XML, CSV and streams. It has no SQL resolver, so a SQL view needs one of the other two.
The choice is per view. One mapping can run a CSV join in DuckDB and an XML source in the reactive evaluator.
Choosing yourself¶
In the library¶
logicalViewEvaluatorFactory(...) on the builder registers an evaluator factory. Calling it switches classpath
discovery off, so only the factories you register are used. To keep the reactive evaluator as a fallback, also call
joinExecutorFactory(...). It adds the reactive evaluator with the mapper's functions. A
DefaultLogicalViewEvaluatorFactory you construct yourself has no functions unless you pass it a registry.
try (var duckDb = new DuckDbLogicalViewEvaluatorFactory()) {
RdfRmlMapper mapper = RdfRmlMapper.builder()
.mapping(mapping)
.logicalViewEvaluatorFactory(duckDb)
.joinExecutorFactory(JoinExecutorFactory.inMemory())
.build();
// run the mapping
}
The DuckDB factory owns a database connection, so close it when you are done.
joinExecutorFactory(...) replaces the reactive evaluator's in-memory join. It also switches discovery off. See
Large inputs.
In the CLI¶
-E or --evaluator takes one of three values:
| Value | Effect |
|---|---|
auto (default) |
DuckDB where it can run the view, the reactive evaluator for the rest. |
reactive |
The reactive evaluator for every view. |
in-process-db |
DuckDB for every view. A view DuckDB declines, such as an XML source, fails the run. |
The CLI does not include the native SQL evaluator. It reads MySQL and PostgreSQL through DuckDB, so -E reactive
cannot be used with a SQL source.