package edu.mit.csail.db.ml.util.duplicator;

import edu.mit.csail.db.ml.conf.ModelDbConfig;
import edu.mit.csail.db.ml.util.ContextFactory;
import org.jooq.DSLContext;

import java.util.Arrays;
import java.util.List;

public class DuplicatorMain {
  public static void main(String[] args) throws Exception {
    System.out.println("Duplicating a total of " + args[0] + " times.");
    ModelDbConfig config = ModelDbConfig.parse(new String[] {});
    DSLContext ctx = ContextFactory.create(config.dbUser, config.dbPassword, config.jbdcUrl, config.dbType);

    int NUM_ITERATIONS = Integer.parseInt(args[0]);
    List<Duplicator> duplicators = Arrays.asList(
      TreeNodeDuplicator.getInstance(ctx),
      ExperimentRunDuplicator.getInstance(ctx),
      DataFrameDuplicator.getInstance(ctx),
      TransformerDuplicator.getInstance(ctx),
      TransformerSpecDuplicator.getInstance(ctx),
      TransformEventDuplicator.getInstance(ctx),
      FitEventDuplicator.getInstance(ctx),
      MetricEventDuplicator.getInstance(ctx),
      RandomSplitEventDuplicator.getInstance(ctx),
      DataFrameColumnDuplicator.getInstance(ctx),
      DataFrameSplitDuplicator.getInstance(ctx),
      FeatureDuplicator.getInstance(ctx),
      HyperParameterDuplicator.getInstance(ctx),
      LinearModelDuplicator.getInstance(ctx),
      LinearModelTermDuplicator.getInstance(ctx),
      TreeModelDuplicator.getInstance(ctx),
      TreeLinkDuplicator.getInstance(ctx),
      TreeModelComponentDuplicator.getInstance(ctx),
      ModelObjectiveHistoryDuplicator.getInstance(ctx),
      CrossValidationEventDuplicator.getInstance(ctx),
      CrossValidationFoldDuplicator.getInstance(ctx),
      GridSearchCrossValidationEventDuplicator.getInstance(ctx),
      GridCellCrossValidationDuplicator.getInstance(ctx),
      EventDuplicator.getInstance(ctx),
      PipelineStageDuplicator.getInstance(ctx)
    );

    for (Duplicator duplicator : duplicators) {
      duplicator.duplicate(NUM_ITERATIONS);
    }
    System.out.println("Finished duplication!");
  }
}

@@ -212,16 +212,774 @@
 .List;%0A%0A
+/**%0A * This is a command line program that basically copies all the rows in all the tables of a ModelDB SQLite database%0A * a specified number of times.%0A *%0A * You basically execute as follows:%0A *%0A * mvn exec:java -Dexec.mainClass=%22edu.mit.csail.db.ml.util.duplicator.DuplicatorMain%22 -Dexec.args=%22numcopies%22%0A *%0A * where numcopies is the number of copies you want for each row.%0A *%0A * The reason we need a command line program for this is because when we copy a row, its primary key must change.%0A * Also, since the row may have foreign keys that point to rows in other tables, those rows must be copied first (and%0A * given their own new primary keys).%0A *%0A * The path to the SQLite file is specified in the default configuration file that ModelDbConfig uses.%0A */%0A
 public c
@@ -1132,16 +1132,81 @@
 imes.%22);
+%0A%0A    // Read the configuration file and connect to the database.
 %0A    Mod
@@ -1369,24 +1369,237 @@
 g.dbType);%0A%0A
+    // Create the duplicators. They are TOPOLOGICALLY sorted based on foreign key dependencies. For example,%0A    // If table T2 has a foreign key pointing to table T1, then T1 should appear before T2 in the list.%0A
     int NUM_
@@ -2913,24 +2913,53 @@
 tx)%0A    );%0A%0A
+    // Run every duplicator.%0A
     for (Dup

Comment DuplicatorMain