public SampleSQLBuilder(Map<String, String> arguments) throws Exception {
    String baseDir = arguments.get("sample.sql.base.dir");

    _dbType = arguments.get("sample.sql.db.type");
    _maxBlogsEntryCommentCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.blogs.entry.comment.count"));
    _maxBlogsEntryCount = GetterUtil.getInteger(arguments.get("sample.sql.max.blogs.entry.count"));
    _maxDDLRecordCount = GetterUtil.getInteger(arguments.get("sample.sql.max.ddl.record.count"));
    _maxDDLRecordSetCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.ddl.record.set.count"));
    _maxDLFileEntryCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.dl.file.entry.count"));
    _maxDLFileEntrySize = GetterUtil.getInteger(arguments.get("sample.sql.max.dl.file.entry.size"));
    _maxDLFolderCount = GetterUtil.getInteger(arguments.get("sample.sql.max.dl.folder.count"));
    _maxDLFolderDepth = GetterUtil.getInteger(arguments.get("sample.sql.max.dl.folder.depth"));
    _maxGroupCount = GetterUtil.getInteger(arguments.get("sample.sql.max.group.count"));
    _maxJournalArticleCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.journal.article.count"));
    _maxJournalArticleSize =
        GetterUtil.getInteger(arguments.get("sample.sql.max.journal.article.size"));
    _maxMBCategoryCount = GetterUtil.getInteger(arguments.get("sample.sql.max.mb.category.count"));
    _maxMBMessageCount = GetterUtil.getInteger(arguments.get("sample.sql.max.mb.message.count"));
    _maxMBThreadCount = GetterUtil.getInteger(arguments.get("sample.sql.max.mb.thread.count"));
    _maxUserCount = GetterUtil.getInteger(arguments.get("sample.sql.max.user.count"));
    _maxUserToGroupCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.user.to.group.count"));
    _maxWikiNodeCount = GetterUtil.getInteger(arguments.get("sample.sql.max.wiki.node.count"));
    _maxWikiPageCommentCount =
        GetterUtil.getInteger(arguments.get("sample.sql.max.wiki.page.comment.count"));
    _maxWikiPageCount = GetterUtil.getInteger(arguments.get("sample.sql.max.wiki.page.count"));
    _optimizeBufferSize = GetterUtil.getInteger(arguments.get("sample.sql.optimize.buffer.size"));
    _outputDir = arguments.get("sample.sql.output.dir");
    _outputMerge = GetterUtil.getBoolean(arguments.get("sample.sql.output.merge"));

    _dataFactory =
        new DataFactory(
            baseDir,
            _maxBlogsEntryCount,
            _maxGroupCount,
            _maxJournalArticleSize,
            _maxMBCategoryCount,
            _maxMBThreadCount,
            _maxMBMessageCount,
            _maxUserToGroupCount);

    _db = DBFactoryUtil.getDB(_dbType);

    if (_db instanceof MySQLDB) {
      _db = new SampleMySQLDB();
    }

    // Clean up previous output

    FileUtil.delete(_outputDir + "/sample-" + _dbType + ".sql");
    FileUtil.deltree(_outputDir + "/output");

    // Generic

    _tempDir = new File(_outputDir, "temp");

    _tempDir.mkdirs();

    final CharPipe charPipe = new CharPipe(_PIPE_BUFFER_SIZE);

    generateSQL(charPipe);

    try {

      // Specific

      compressSQL(charPipe.getReader());

      // Merge

      mergeSQL();
    } finally {
      FileUtil.deltree(_tempDir);
    }

    StringBundler sb = new StringBundler();

    List<String> keys = ListUtil.fromMapKeys(arguments);

    Collections.sort(keys);

    for (String key : keys) {
      if (!key.startsWith("sample.sql")) {
        continue;
      }

      String value = arguments.get(key);

      sb.append(key);
      sb.append(StringPool.EQUAL);
      sb.append(value);
      sb.append(StringPool.NEW_LINE);
    }

    FileUtil.write(new File(_outputDir, "benchmarks-actual.properties"), sb.toString());
  }
 @Override
 public List<String> getPortletNames() {
   return ListUtil.fromMapKeys(_portletModelResources);
 }