Custom importer

If an existing import tool does not support your input data, a custom importer can. This guide covers custom importers in Deephaven, starting with a minimal working example and progressing to more advanced patterns.

Note

This guide applies to Deephaven Enterprise deployments with merge servers. Custom importers extend the Enterprise BaseImporter API and run as standalone processes on merge server hosts. This feature is not available in Core+ workers.

Overview

A custom importer is a Java program that:

  1. Extends BaseImporter, which handles setup, table writing, and cleanup.
  2. Implements processData, where you read your source data and write rows to the table.
  3. Optionally extends StandardImporterArguments to add custom command-line arguments.

The importer runs as a standalone process on a merge server host with access to intraday data.

Prerequisites

  • You must deploy the schema before running the importer.
  • The table must be a System table.

Minimal example

This section guides you through creating a simple custom importer from start to finish. The example imports stock trade data from a hypothetical data source.

Step 1: Define the schema

Create a schema file for your target table. This example defines a Trades table in the MyData namespace:

Deploy the schema using the Schema Editor or schema_tool. See Schema management for details.

Step 2: Create the importer

Create a Java class that extends BaseImporter. This minimal example hardcodes the data source, but a real importer would read from files, APIs, or other sources.

Key points:

  • Extend BaseImporter — provides getTableWriter, getTableDefinition, and handles setup/cleanup.
  • Implement processData — this is where you read your data source and write rows.
  • Use typed setters — call setDouble, setLong, etc. for primitives to avoid boxing overhead.
  • Don't set partitioning columns — these are handled automatically based on the -dp argument.

Step 3: Compile the importer

Compile your importer against the Deephaven libraries:

Step 4: Run the importer

Execute the importer on a merge server host:

Required arguments:

ArgumentDescription
-ns, --namespaceTarget namespace (e.g., MyData)
-tn, --tableNameTarget table name (e.g., Trades)
-dp, --destinationPartitionInternal partition and date (e.g., hostname/2024-01-15)
-om, --outputModeImport behavior: REPLACE, APPEND, or SAFE

Advanced patterns

The following sections cover more advanced patterns, including custom arguments and dynamic schema handling.

Custom arguments

To add custom command-line arguments, extend StandardImporterArguments:

Then in main, parse with your custom options:

JVM and runtime arguments

ParameterTypeDescription
Classpath

The ingester's classpath. Should include installed Deephaven files, default override locations, and path to custom Java code:

  • /etc/sysconfig/illumon.d/hotfixes
  • /etc/sysconfig/illumon.d/override
  • /etc/sysconfig/illumon.d/resources
  • /etc/sysconfig/illumon.d/java_lib/*
  • /usr/illumon/latest/etc
  • /usr/illumon/latest/java_lib/*
process.name

The name of the process. The process name must be unique; only one instance of the process name can run at a given time. This must be passed as a JVM argument:

-Dprocess.name=example_importer

Configuration.rootFile

The root property file specifying configuration properties for your process passed in as a JVM argument:

-DConfiguration.rootFile=iris-common.prop

devroot

Either /usr/illumon/latest or the resolved target of that link. Also passed in as a JVM argument:

-Ddevroot=/usr/illumon/latest

workspace

The workspace directory for the importer. This is where log files will go. This can match other import processes, or be its own directory. Also passed in as a JVM argument:

-Dworkspace=/db/TempFiles/dbmerge/example_importer

Standard program arguments

In addition to any custom arguments you define, importers accept these standard arguments:

ArgumentDescription
-dd, --destinationDirectoryOutput directory path
-dp, --destinationPartitionInternal partition and date (e.g., hostname/2024-01-15)
-ns, --namespaceTarget namespace
-tn, --tableNameTarget table name
-om, --outputModeImport behavior: REPLACE, APPEND, or SAFE

Importing from a query

ExampleImporter and ExampleImporter.Arguments include overrides that bypass the command line. Importers that override these methods in a similar way can be called from a Deephaven console or persistent query.

Full example: ExampleImporter.java

Expand here to see the full code for ExampleImporter.java

Base class: BaseImporter.java

Expand here to see the full code for BaseImporter.java