예제 #1
0
 public EnumeratorType getEnuemratorType() {
   return indexDeligate.getEnuemratorType();
 }
예제 #2
0
  @Override
  public void runCommand() throws Exception {
    if (LOG.isInfoEnabled()) LOG.info("Running filtering.");
    if (LOG.isDebugEnabled()) LOG.debug(this);

    if (filterFeatureMinFreq > 0) {
      addFeaturesMinimumFrequency(filterFeatureMinFreq);
    }
    if (filterFeaturePattern != null) {
      addFeaturesPattern(filterFeaturePattern);
    }
    if (filterFeatureWhitelist != null) {
      addFeaturesWhitelist(
          com.google.common.io.Files.readLines(filterFeatureWhitelist, getCharset()));
    }

    if (filterEntryMinFreq > 0) {
      addEntryMinimumFrequency(filterEntryMinFreq);
    }
    if (filterEntryPattern != null) {
      addEntryPattern(filterEntryPattern);
    }
    if (filterEntryWhitelist != null) {
      addEntryWhitelist(com.google.common.io.Files.readLines(filterEntryWhitelist, getCharset()));
    }

    if (filterEventMinFreq > 0) {
      addEventMinimumFrequency(filterEventMinFreq);
    }

    checkState();
    activeEventsFile = inputEventsFile;
    activeEntriesFile = inputEntriesFile;
    activeFeaturesFile = inputFeaturesFile;

    progress.addProgressListener(
        new ProgressListener() {

          @Override
          public void progressChanged(ProgressEvent progressEvent) {
            LOG.info(progressEvent.getSource().getProgressReport());
          }
        });

    progress.setState(State.RUNNING);
    progress.setProgressPercent(0);

    // Run the filters forwards then backwards. Each filtering step may
    // introduce additionaly filters for the other files, so continue
    // looping until there is no work remaining. Depending on filters this
    // very unlikely to take more than 3 passes

    int passCount = 0;
    int opCount = 0;

    while (entryFilterRequired || eventFilterRequired || featureFilterRequired) {

      //            if (entryFilterRequired || eventFilterRequired) {

      progress.setMessage("Running filtering pass (#" + (++passCount) + ").");

      if (entryFilterRequired) {
        filterEntries();
        ++opCount;
        progress.setProgressPercent(
            100
                * opCount
                / (opCount
                    + 3
                    + (entryFilterRequired ? 1 : 0)
                    + (eventFilterRequired ? 1 : 0)
                    + (featureFilterRequired ? 1 : 0)));
      }

      if (eventFilterRequired) {
        filterEvents();
        ++opCount;
        progress.setProgressPercent(
            100
                * opCount
                / (opCount
                    + 3
                    + (entryFilterRequired ? 1 : 0)
                    + (eventFilterRequired ? 1 : 0)
                    + (featureFilterRequired ? 1 : 0)));
      }

      if (featureFilterRequired) {
        filterFeatures();
        ++opCount;
        progress.setProgressPercent(
            100
                * opCount
                / (opCount
                    + 3
                    + (entryFilterRequired ? 1 : 0)
                    + (eventFilterRequired ? 1 : 0)
                    + (featureFilterRequired ? 1 : 0)));
      }
      //            }
      //
      //            if (featureFilterRequired || eventFilterRequired) {
      //
      //                progress.setMessage("Running backwards filtering pass (#" + (++passCount) +
      // ").");
      //
      //                if (featureFilterRequired) {
      //                    filterFeatures();
      //                    ++opCount;
      //                    progress.setProgressPercent(100 * opCount / (opCount
      //                            + (entryFilterRequired ? 1 : 0)
      //                            + (eventFilterRequired ? 1 : 0)
      //                            + (featureFilterRequired ? 1 : 0)));
      //                }

      if (eventFilterRequired) {
        filterEvents();
        ++opCount;
        progress.setProgressPercent(
            100
                * opCount
                / (opCount
                    + 3
                    + (entryFilterRequired ? 1 : 0)
                    + (eventFilterRequired ? 1 : 0)
                    + (featureFilterRequired ? 1 : 0)));
      }

      if (entryFilterRequired) {
        filterEntries();
        ++opCount;
        progress.setProgressPercent(
            100
                * opCount
                / (opCount
                    + 3
                    + (entryFilterRequired ? 1 : 0)
                    + (eventFilterRequired ? 1 : 0)
                    + (featureFilterRequired ? 1 : 0)));
      }
      //            }
    }

    // Finished filtering so copy the results files to the outputs.

    progress.setMessage("Copying final entries file.");

    outputEntriesFile.delete();
    if (!activeEntriesFile.renameTo(outputEntriesFile)) {
      com.google.common.io.Files.copy(activeEntriesFile, outputEntriesFile);
      if (!activeEntriesFile.equals(inputEntriesFile)) activeEntriesFile.delete();
    }
    ++opCount;

    progress.startAdjusting();
    progress.setProgressPercent(
        100
            * opCount
            / (opCount
                + 2
                + (entryFilterRequired ? 1 : 0)
                + (eventFilterRequired ? 1 : 0)
                + (featureFilterRequired ? 1 : 0)));
    progress.setMessage("Copying finaly events file.");
    progress.endAdjusting();

    outputEventsFile.delete();
    if (!activeEventsFile.renameTo(outputEventsFile)) {
      com.google.common.io.Files.copy(activeEventsFile, outputEventsFile);
      if (!activeEventsFile.equals(inputEventsFile)) activeEventsFile.delete();
    }
    ++opCount;

    progress.startAdjusting();
    progress.setProgressPercent(
        100
            * opCount
            / (opCount
                + 1
                + (entryFilterRequired ? 1 : 0)
                + (eventFilterRequired ? 1 : 0)
                + (featureFilterRequired ? 1 : 0)));
    progress.setMessage("Copying final features file.");
    progress.endAdjusting();

    outputFeaturesFile.delete();
    if (!activeFeaturesFile.renameTo(outputFeaturesFile)) {
      com.google.common.io.Files.copy(activeFeaturesFile, outputFeaturesFile);
      if (!activeFeaturesFile.equals(inputFeaturesFile)) activeFeaturesFile.delete();
    }
    ++opCount;
    progress.setProgressPercent(
        100
            * opCount
            / (opCount
                + 0
                + (entryFilterRequired ? 1 : 0)
                + (eventFilterRequired ? 1 : 0)
                + (featureFilterRequired ? 1 : 0)));

    if (indexDeligate.isEnumeratorOpen()) {
      indexDeligate.saveEnumerator();
      indexDeligate.closeEnumerator();
    }

    progress.setState(State.COMPLETED);
  }
예제 #3
0
 public File getEntryEnumeratorFile() {
   return indexDeligate.getEntryEnumeratorFile();
 }
예제 #4
0
 public void setEnumeratorType(EnumeratorType type) {
   indexDeligate.setEnumeratorType(type);
 }
예제 #5
0
 public boolean isEnumeratedEntries() {
   return indexDeligate.isEnumeratedEntries();
 }
예제 #6
0
 public File getFeatureEnumeratorFile() {
   return indexDeligate.getFeatureEnumeratorFile();
 }
예제 #7
0
 public boolean isEnumeratedFeatures() {
   return indexDeligate.isEnumeratedFeatures();
 }
예제 #8
0
 public void setEntryEnumeratorFile(File entryEnumeratorFile) {
   indexDeligate.setEntryEnumeratorFile(entryEnumeratorFile);
 }
예제 #9
0
 public void setEnumeratedEntries(boolean enumeratedEntries) {
   indexDeligate.setEnumeratedEntries(enumeratedEntries);
 }
예제 #10
0
 public void setEnumeratedFeatures(boolean enumeratedFeatures) {
   indexDeligate.setEnumeratedFeatures(enumeratedFeatures);
 }
예제 #11
0
 public void setFeatureEnumeratorFile(File featureEnumeratorFile) {
   indexDeligate.setFeatureEnumeratorFile(featureEnumeratorFile);
 }