For the complete documentation index, see llms.txt. This page is also available as Markdown.

Executors

Running DataVec transform processes — LocalTransformExecutor and SparkTransformExecutor

Once you have defined a TransformProcess, an executor runs it against your actual data. DataVec provides two executor implementations:

  • LocalTransformExecutor — runs transforms in the current JVM, processing records sequentially. No additional infrastructure required.

  • SparkTransformExecutor — runs transforms distributed across a Spark cluster using JavaRDD<List<Writable>> as input and output.

Both executors take the same TransformProcess and produce the same output schema. You can develop and test locally, then switch to Spark for production-scale data without changing your transform definition.

LocalTransformExecutor

The local executor is the easiest way to run a TransformProcess. Pass either a RecordReader or an in-memory List<List<Writable>>.

Execute on a List

import org.datavec.local.transforms.LocalTransformExecutor;

// Load all records into memory first (suitable for small datasets)
List<List<Writable>> originalData = new ArrayList<>();
while (reader.hasNext()) {
    originalData.add(reader.next());
}

List<List<Writable>> processedData = LocalTransformExecutor.execute(originalData, transformProcess);

Execute on a RecordReader

Execute Sequences (2D records -> sequences)

When a TransformProcess ends with a convertToSequence step, use executeToSequence:

The outer list is the collection of sequences; the middle list is the time steps within one sequence; the inner list is the column values at one time step.

Execute a Join Locally

Error Handling

By default, the local executor will throw an exception if any record fails to transform. To log errors and skip bad records instead:

When tryCatch is enabled, records that cause exceptions are silently dropped and a warning is logged. Disable this in production pipelines where dropping records silently would be a problem.

SparkTransformExecutor

The Spark executor applies the same TransformProcess to a JavaRDD<List<Writable>>. The Spark context and data loading are your responsibility; the executor handles the distributed application of the transforms.

Setup

Add the Spark dependency to your project:

Basic Execution

Execute to Sequence

When the transform produces sequence data:

Execute from Sequence

When input is sequences but output is flat records:

Execute a Join on Spark

Error Handling on Spark

Choosing Local vs. Spark

Criterion
LocalTransformExecutor
SparkTransformExecutor

Dataset size

Up to ~1M records comfortably

Millions to billions of records

Infrastructure

None — runs in current JVM

Requires Spark cluster (local or distributed)

Development speed

Fast — no cluster startup

Slower — cluster overhead

Production batch

Small datasets, real-time inference

Large offline batch preprocessing

Real-time inference

Yes

No

A common pattern is to use LocalTransformExecutor during development and testing, then switch to SparkTransformExecutor for the production batch preprocessing job. Because the TransformProcess is shared between both, the switch requires only changing the executor call.

Using TransformProcessRecordReader Instead

For training workflows where you want to apply transforms record-by-record during DataSetIterator iteration (rather than materializing all transformed data at once), use TransformProcessRecordReader:

This avoids materializing the full transformed dataset in memory and integrates naturally with the DL4J training loop.

Last updated

Was this helpful?