public void addIndexesNoOptimize(Directory... dirs)
      throws CorruptIndexException, IOException {

    ensureOpen();

    noDupDirs(dirs);

    // Do not allow add docs or deletes while we are running:
    docWriter.pauseAllThreads();

    try {
      if (infoStream != null)
        message("flush at addIndexesNoOptimize");
      flush(true, false, true);

      boolean success = false;

      startTransaction(false);

      try {

        int docCount = 0;
        synchronized(this) {
          ensureOpen();

          for (int i = 0; i < dirs.length; i++) {
            if (directory == dirs[i]) {
              // cannot add this index: segments may be deleted in merge before added
              throw new IllegalArgumentException("Cannot add this index to itself");
            }

            SegmentInfos sis = new SegmentInfos(); // read infos from dir
            sis.read(dirs[i]);
            for (int j = 0; j < sis.size(); j++) {
              SegmentInfo info = sis.info(j);
              assert !segmentInfos.contains(info): "dup info dir=" + info.dir + " name=" + info.name;
              docCount += info.docCount;
              segmentInfos.add(info); // add each info
            }
          }
        }

        // Notify DocumentsWriter that the flushed count just increased
        docWriter.updateFlushedDocCount(docCount);

        maybeMerge();

        ensureOpen();

        // If after merging there remain segments in the index
        // that are in a different directory, just copy these
        // over into our index.  This is necessary (before
        // finishing the transaction) to avoid leaving the
        // index in an unusable (inconsistent) state.
        resolveExternalSegments();

        ensureOpen();

        success = true;

      } finally {
        if (success) {
          commitTransaction();
        } else {
          rollbackTransaction();
        }
      }
    } catch (OutOfMemoryError oom) {
      handleOOM(oom, "addIndexesNoOptimize");
    } finally {
      if (docWriter != null) {
        docWriter.resumeAllThreads();
      }
    }
  }