public MemoryCleanUp(OperatorDescription description) {
    super(description);

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
  }
  public ClearProcessLog(OperatorDescription description) {
    super(description);

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
  }
  /** @param description */
  public AbstractRepositoryManagerOperator(OperatorDescription description) {
    super(description);

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
  }
 @Override
 public void doWork() throws OperatorException {
   clearAllInnerSinks();
   inputExtender.passDataThrough();
   super.doWork();
   outputExtender.passDataThrough();
 }
 /** This constructor allows subclasses to change the subprocess' name. */
 protected SimpleOperatorChain(OperatorDescription description, String subProcessName) {
   super(description, subProcessName);
   inputExtender.start();
   outputExtender.start();
   getTransformer().addRule(inputExtender.makePassThroughRule());
   getTransformer().addRule(new SubprocessTransformRule(getSubprocess(0)));
   getTransformer().addRule(outputExtender.makePassThroughRule());
 }
  public CommandLineOperator(OperatorDescription description) {
    super(description);

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
    getTransformer().addGenerationRule(stdout, FileObject.class);
    getTransformer().addGenerationRule(stderr, FileObject.class);
  }
  public ProcessLog2ExampleSet(OperatorDescription description) {
    super(description);
    ExampleSetMetaData newEMD = new ExampleSetMetaData();
    newEMD.attributesAreSuperset();
    newEMD.setNumberOfExamples(0);
    newEMD.getNumberOfExamples().increaseByUnknownAmount();
    getTransformer().addRule(new GenerateNewMDRule(exampleSetOutput, newEMD));

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());
  }
 public ParameterIteratingOperatorChain(OperatorDescription description, String subprocessName) {
   super(description, subprocessName);
   innerSinkExtender = makeInnerSinkExtender();
   inputExtender.start();
   innerSinkExtender.start();
   getPerformanceInnerSink()
       .addPrecondition(
           new SimplePrecondition(
               getPerformanceInnerSink(),
               new MetaData(PerformanceVector.class),
               isPerformanceRequired()));
   getTransformer().addRule(inputExtender.makePassThroughRule());
   getTransformer().addRule(new SubprocessTransformRule(getSubprocess(0)));
   getTransformer().addRule(innerSinkExtender.makePassThroughRule());
 }
  public Macro2Log(OperatorDescription description) {
    super(description);

    dummyPorts.start();

    getTransformer().addRule(dummyPorts.makePassThroughRule());

    addValue(
        new ValueString("macro_value", "The value from the macro which should be logged.") {

          @Override
          public String getStringValue() {
            return currentValue;
          }
        });
  }
  @Override
  public void doWork() throws OperatorException {
    DataTable table = null;
    if (isParameterSet(PARAMETER_LOG_NAME)) {
      String dataTableName = getParameterAsString(PARAMETER_LOG_NAME);
      table = getProcess().getDataTable(dataTableName);
    } else {
      if (getProcess().getDataTables().size() > 0) {
        table = getProcess().getDataTables().iterator().next();
        logNote("No log name was specified, using first data table found...");
      }
    }

    // check
    if (table == null) {
      throw new UserError(this, 939);
    }

    // create attributes
    List<Attribute> attributes = new ArrayList<Attribute>();
    for (int i = 0; i < table.getNumberOfColumns(); i++) {
      String name = table.getColumnName(i);
      if (table.isDate(i)) {
        attributes.add(AttributeFactory.createAttribute(name, Ontology.DATE));
      } else if (table.isDateTime(i)) {
        attributes.add(AttributeFactory.createAttribute(name, Ontology.DATE_TIME));
      } else if (table.isNumerical(i)) {
        attributes.add(AttributeFactory.createAttribute(name, Ontology.REAL));
      } else {
        attributes.add(AttributeFactory.createAttribute(name, Ontology.NOMINAL));
      }
    }

    // create table
    MemoryExampleTable exampleTable = new MemoryExampleTable(attributes);
    for (int r = 0; r < table.getNumberOfRows(); r++) {
      DataTableRow row = table.getRow(r);
      double[] data = new double[attributes.size()];
      for (int i = 0; i < table.getNumberOfColumns(); i++) {
        if (table.isDate(i)) {
          data[i] = row.getValue(i);
        } else if (table.isDateTime(i)) {
          data[i] = row.getValue(i);
        } else if (table.isNumerical(i)) {
          data[i] = row.getValue(i);
        } else {
          Attribute attribute = attributes.get(i);
          String value = table.getValueAsString(row, i);
          data[i] = attribute.getMapping().mapString(value);
        }
      }
      exampleTable.addDataRow(new DoubleArrayDataRow(data));
    }

    // create and return example set
    exampleSetOutput.deliver(exampleTable.createExampleSet());
    dummyPorts.passDataThrough();
  }
  @Override
  public void doWork() throws OperatorException {
    getProcess().clearDataTable(getParameterAsString(PARAMETER_LOG_NAME));
    if (getParameterAsBoolean(PARAMETER_DELETE_TABLE)) {
      getProcess().deleteDataTable(getParameterAsString(PARAMETER_LOG_NAME));
    }

    dummyPorts.passDataThrough();
  }
 protected PerformanceVector getPerformance(boolean cloneInput) {
   try {
     inputExtender.passDataThrough();
     executeSubprocess();
     if (isPerformanceRequired()) {
       return getPerformanceInnerSink().getData(PerformanceVector.class);
     } else {
       return getPerformanceInnerSink().getDataOrNull(PerformanceVector.class);
     }
   } catch (OperatorException e) {
     StringBuilder builder = new StringBuilder();
     builder.append(this.getName());
     builder.append(
         ": Cannot evaluate performance for current parameter combination because of an error in one of the inner operators: ");
     builder.append(e.getMessage());
     getLogger().severe(builder.toString());
     //            getLogger().severe("Cannot evaluate performance for current parameter
     // combination: " + e.getMessage());
     if (Boolean.parseBoolean(
         ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEBUGMODE)))
       e.printStackTrace();
     return null;
   }
 }
 /** Passes data from the inner sinks to the output ports. */
 protected void passResultsThrough() {
   innerSinkExtender.passDataThrough();
 }
 /**
  * Returns the results at the inner sink port extender. Does not include a possible performance
  * vector at the respective input. {@link #executeSubprocess()} or {@link #getPerformance()} must
  * have been called earlier.
  *
  * @throws UserError
  */
 protected Collection<IOObject> getInnerResults() throws UserError {
   return innerSinkExtender.getData(IOObject.class);
 }
 @Override
 public void doWork() throws OperatorException {
   dummyPorts.passDataThrough();
 }
  @Override
  public void doWork() throws OperatorException {
    String command = getParameterAsString(PARAMETER_COMMAND);
    final boolean logOut = !stdout.isConnected() && getParameterAsBoolean(PARAMETER_LOG_STDOUT);
    final boolean logErr = !stderr.isConnected() && getParameterAsBoolean(PARAMETER_LOG_STDERR);
    final List<Throwable> exceptions = Collections.synchronizedList(new ArrayList<Throwable>(3));
    try {
      final Process process = Runtime.getRuntime().exec(command);
      final ByteArrayOutputStream stdOutBuf = new ByteArrayOutputStream();
      final ByteArrayOutputStream stdErrBuf = new ByteArrayOutputStream();

      if (stdin.isConnected()) {
        final FileObject input = stdin.getData(FileObject.class);
        new Thread(getName() + "-stdin") {
          public void run() {
            try {
              Tools.copyStreamSynchronously(input.openStream(), process.getOutputStream(), true);
            } catch (Exception e) {
              exceptions.add(e);
            }
          };
        }.start();
      }

      new Thread(getName() + "-stdout") {
        public void run() {
          try {
            if (logOut) {
              logOutput("stdout:", process.getInputStream());
            } else {
              Tools.copyStreamSynchronously(process.getInputStream(), stdOutBuf, true);
            }
          } catch (Exception e) {
            exceptions.add(e);
          }
        }
      }.start();
      new Thread(getName() + "-stderr") {
        public void run() {
          try {
            if (logErr) {
              logOutput("stderr:", process.getErrorStream());
            } else {
              Tools.copyStreamSynchronously(process.getErrorStream(), stdErrBuf, true);
            }
          } catch (Exception e) {
            exceptions.add(e);
          }
        }
      }.start();

      Tools.waitForProcess(this, process, command);
      getLogger().info("Program exited succesfully.");

      if (stdout.isConnected()) {
        stdout.deliver(new BufferedFileObject(stdOutBuf.toByteArray()));
      }
      if (stderr.isConnected()) {
        stderr.deliver(new BufferedFileObject(stdErrBuf.toByteArray()));
      }
    } catch (IOException e) {
      throw new UserError(this, e, 310, new Object[] {command, e.getMessage()});
    } finally {
      getLogger()
          .log(
              Level.WARNING,
              "com.rapidminer.operator.CommandLineOperator.errors_occurred",
              new Object[] {exceptions.size(), command});
      for (Throwable t : exceptions) {
        getLogger().log(Level.WARNING, t.toString(), t);
      }
      if (!exceptions.isEmpty()) {
        Throwable t = exceptions.get(0);
        if (t instanceof OperatorException) {
          throw (OperatorException) t;
        } else {
          throw new UserError(this, t, 310, new Object[] {command, t.getMessage()});
        }
      }
    }

    dummyPorts.passDataThrough();
  }
Esempio n. 17
0
 @Override
 public void doWork() throws OperatorException {
   this.currentValue =
       getProcess().getMacroHandler().getMacro(getParameterAsString(PARAMETER_MACRO_NAME));
   dummyPorts.passDataThrough();
 }