Skip to content

The engine (spark-core)

spark-core is a library JAR. It is not an application: something else starts it, either spark-submit or a Spring Boot service.

A fetch strategy knows how to read one kind of source. The registry, DataFetcherRegistery, finds all strategies on the classpath with ServiceLoader and stores them by type name in lower case. Calling loadAll() fills it.

ServiceLoader<FetchStrategy> loader = ServiceLoader.load(FetchStrategy.class);
for (FetchStrategy strategy : loader) {
strategyMap.put(strategy.getType().toLowerCase(), strategy);
}

To read from a new kind of source you add a strategy as a plugin; the engine does not change.

A filter is described as a tree:

  • a ConditionNode is one test, for example age > 30, with a value and a type (integer, double, date, or text);
  • a GroupNode joins children with AND or OR;
  • any node can be negated.

SparkFilterEngine.execute walks the tree and builds one Spark Column expression. Values are first converted to the stated type by ValueConverter, so a number typed in a UI as text becomes a real number.

Because the tree is plain data, the UI can build it and a backend can store it without any Spark code.

Functions come from plugins. The engine registers every SparkUdf it finds, after which pipelines can call them by name.

spark-core on GitLab, with its pom.xml.