DataGenerator is a Java library for systematically producing large volumes of data. DataGenerator frames data production as a modeling problem, with a user providing a model of dependencies among variables and the library traversing the model to produce relevant data sets.
Java Scala
Clone or download
yukaReal Merge pull request #318 from yukaReal/clean_BlackDuckSecurityRiskBadge
Clean second Black Duck Security Risk badge. Pull all of badges on on…
Latest commit 1f69f94 Feb 12, 2018

Build Status Dependency Status Black Duck Security Risk Join the chat at

Quick Start Videos


We encourage contribution from the open source community to make DataGenerator better. Please refer to the development page for more information on how to contribute to this project.

Maven Dependency

For the core


For the commons library



DataGenerator uses Maven for build. Please install Maven by downloading it from here.

# Clone DataGenerator git repo
git clone git://
cd DataGenerator

# Checkout master branch
git checkout master

# Run package to compile and create jar (also runs unit tests)
mvn package

# Compile and run unit tests only
mvn test


The DataGenerator project is licensed under Apache License Version 2.0


Data Generator generates pattern using two pieces of user provided information:

  1. An SCXML state chart representing interactions between different states, and setting values to output variables
  2. A user Transformer that formats the variables and stores them.

The user can optionally provide their own distributor that distributes the search of bigger problems on systems like hadoop. By default, DataGenerator will use a multithreaded distributor.

Quick start

For the full compilable code please see the default example

First step, define an SCXML model:

<scxml xmlns=""

    <state id="start">
        <transition event="SETV1" target="SETV1"/>

    <state id="SETV1">
            <assign name="var_out_V1_1" expr="set:{A1,B1,C1}"/>
            <assign name="var_out_V1_2" expr="set:{A2,B2,C2}"/>
            <assign name="var_out_V1_3" expr="77"/>
        <transition event="SETV2" target="SETV2"/>

    <state id="SETV2">
            <assign name="var_out_V2" expr="set:{1,2,3}"/>
            <assign name="var_out_V3" expr="#{customplaceholder}"/>
        <transition event="end" target="end"/>

    <state id="end">
        <!-- We're done -->

This model contains five variables controlled by two states. The transition between those states is unconditional. One of those variables is always constant ( var_out_V1_3 ). Three will acquire every value from a set ( var_out_V1_1, var_out_V1_2 and var_out_V2 ). var_out_V3 will be set to a holder value that will be replaced by the user at a later point.

The second step will be to write a Transformer. The code is here

public class SampleMachineTransformer implements DataTransformer {

    private static final Logger log = Logger.getLogger(SampleMachineTransformer.class);
    private final Random rand = new Random(System.currentTimeMillis());

     * The transform method for this DataTransformer
     * @param cr a reference to DataPipe from which to read the current map
    public void transform(DataPipe cr) {
        for (Map.Entry<String, String> entry : cr.getDataMap().entrySet()) {
            String value = entry.getValue();

            if (value.equals("#{customplaceholder}")) {
                // Generate a random number
                int ran = rand.nextInt();


The above transformer will intercept every generated row, and convert the place holder "#customplaceholder" with a random number.

The last step will be writing a main function that ties both pieces together. Code is here

    public static void main(String[] args) {

        Engine engine = new SCXMLEngine();

        //will default to samplemachine, but you could specify a different file if you choose to
        InputStream is = CmdLine.class.getResourceAsStream("/" + (args.length == 0 ? "samplemachine" : args[0]) + ".xml");


        // Usually, this should be more than the number of threads you intend to run

        //Prepare the consumer with the proper writer and transformer
        DataConsumer consumer = new DataConsumer();
        consumer.addDataTransformer(new SampleMachineTransformer());
        consumer.addDataWriter(new DefaultWriter(System.out,
                new String[]{"var_out_V1_1", "var_out_V1_2", "var_out_V1_3", "var_out_V2", "var_out_V3"}));

        //Prepare the distributor
        DefaultDistributor defaultDistributor = new DefaultDistributor();


The first few lines will open an input stream on the SCXML file and pass the stream to the engine. Calling setBootStrapMin will attempt to split the graph generated from the state chart to at least the given number of splits. Here we passed 1 but in case you will execute the same code over hadoop or use a multithreaded version, you will need to increase that number to be at least the number of threads or mappers you wish to run. The rest of the code will set our transformer to the engine and create a writer based on the DefaultWriter. The function of the writer is to write the output to the user's desired destination.

The final piece sets the number of threads and called engine.process.