当前位置: 首页>>代码示例>>Java>>正文


Java ClassOption类代码示例

本文整理汇总了Java中com.github.javacliparser.ClassOption的典型用法代码示例。如果您正苦于以下问题:Java ClassOption类的具体用法?Java ClassOption怎么用?Java ClassOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassOption类属于com.github.javacliparser包,在下文中一共展示了ClassOption类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTask

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
public static Task getTask(String cliString) {
  Task task = null;
  try {
    logger.debug("Providing task [{}]", cliString);
    task = ClassOption.cliStringToObject(cliString, Task.class, null);
  } catch (Exception e) {
    logger.warn("Fail in initializing the task!");
    e.printStackTrace();
  }
  return task;
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:12,代码来源:ApexSamoaUtils.java

示例2: main

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * The main method.
 * 
 * @param args
 *          the arguments
 */
public static void main(String[] args) {

  // ArrayList<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));

  // args = tmpArgs.toArray(new String[0]);

  FlagOption suppressStatusOutOpt = new FlagOption("suppressStatusOut", 'S', SUPPRESS_STATUS_OUT_MSG);

  FlagOption suppressResultOutOpt = new FlagOption("suppressResultOut", 'R', SUPPRESS_RESULT_OUT_MSG);

  IntOption statusUpdateFreqOpt = new IntOption("statusUpdateFrequency", 'F', STATUS_UPDATE_FREQ_MSG, 1000, 0,
      Integer.MAX_VALUE);

  Option[] extraOptions = new Option[] { suppressStatusOutOpt, suppressResultOutOpt, statusUpdateFreqOpt };

  StringBuilder cliString = new StringBuilder();
  for (String arg : args) {
    cliString.append(" ").append(arg);
  }
  logger.debug("Command line string = {}", cliString.toString());
  System.out.println("Command line string = " + cliString.toString());

  Task task;
  try {
    task = ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions);
    logger.info("Successfully instantiating {}", task.getClass().getCanonicalName());
  } catch (Exception e) {
    logger.error("Fail to initialize the task", e);
    System.out.println("Fail to initialize the task" + e);
    return;
  }
  task.setFactory(new SimpleComponentFactory());
  task.init();
  SimpleEngine.submitTopology(task.getTopology());
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:42,代码来源:LocalDoTask.java

示例3: main

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));

	args = tmpArgs.toArray(new String[0]);

	// Init Task
	StringBuilder cliString = new StringBuilder();
	for (int i = 0; i < args.length; i++) {
		cliString.append(" ").append(args[i]);
	}
	logger.debug("Command line string = {}", cliString.toString());
	System.out.println("Command line string = " + cliString.toString());

	Task task;
	try {
		task = ClassOption.cliStringToObject(cliString.toString(), Task.class, null);
		logger.debug("Successfully instantiating {}", task.getClass().getCanonicalName());
	} catch (Exception e) {
		logger.error("Failed to initialize the task: ", e);
		System.out.println("Failed to initialize the task: " + e);
		return;
	}
	
	StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
	task.setFactory(new FlinkComponentFactory(env));
	task.init();
	
	logger.debug("Building Flink topology...");
	((FlinkTopology) task.getTopology()).build();
	
	logger.debug("Submitting the job...");
	env.execute();

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:35,代码来源:FlinkDoTask.java

示例4: getTask

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
public static Task getTask(String cliString) {
    Task task = null;
    try {
        logger.debug("Providing task [{}]", cliString);
        task = ClassOption.cliStringToObject(cliString, Task.class, null);
    } catch (Exception e) {
        logger.warn("Fail in initializing the task!");
        e.printStackTrace();
    }
    return task;
}
 
开发者ID:YahooArchive,项目名称:samoa,代码行数:12,代码来源:StormSamoaUtils.java

示例5: main

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * The main method.
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {

    // ArrayList<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));

    // args = tmpArgs.toArray(new String[0]);

    FlagOption suppressStatusOutOpt = new FlagOption("suppressStatusOut", 'S', SUPPRESS_STATUS_OUT_MSG);

    FlagOption suppressResultOutOpt = new FlagOption("suppressResultOut", 'R', SUPPRESS_RESULT_OUT_MSG);

    IntOption statusUpdateFreqOpt = new IntOption("statusUpdateFrequency", 'F', STATUS_UPDATE_FREQ_MSG, 1000, 0, Integer.MAX_VALUE);

    Option[] extraOptions = new Option[] { suppressStatusOutOpt, suppressResultOutOpt, statusUpdateFreqOpt };

    StringBuilder cliString = new StringBuilder();
    for (String arg : args) {
        cliString.append(" ").append(arg);
    }
    logger.debug("Command line string = {}", cliString.toString());
    System.out.println("Command line string = " + cliString.toString());

    Task task;
    try {
        task = ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions);
        logger.info("Successfully instantiating {}", task.getClass().getCanonicalName());
    } catch (Exception e) {
        logger.error("Fail to initialize the task", e);
        System.out.println("Fail to initialize the task" + e);
        return;
    }
    task.setFactory(new SimpleComponentFactory());
    task.init();
    SimpleEngine.submitTopology(task.getTopology());
}
 
开发者ID:YahooArchive,项目名称:samoa,代码行数:41,代码来源:LocalDoTask.java

示例6: MOAClustererAdapter

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * Instantiates a new learner.
 *
 * @param learner the learner
 * @param dataset the dataset
 */
public MOAClustererAdapter(Instances dataset, ClassOption learnerOption) {
    this.learnerOption = (ClassOption) learnerOption.copy();
    this.isInit = false;
    this.dataset = dataset;
    
}
 
开发者ID:samoa-moa,项目名称:samoa-moa,代码行数:13,代码来源:MOAClustererAdapter.java

示例7: setLayout

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * Sets the layout.
 */
protected void setLayout() {
  int ensembleSize = this.ensembleSizeOption.getValue();

  distributorP = new BaggingDistributorProcessor();
  distributorP.setEnsembleSize(ensembleSize);
  builder.addProcessor(distributorP, 1);

  // instantiate classifier
  ensemble = new AdaptiveLearner[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    try {
      ensemble[i] = (AdaptiveLearner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(),
          baseLearnerOption.getRequiredType());
    } catch (Exception e) {
      logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
      e.printStackTrace();
      throw new IllegalArgumentException(e);
    }
    ensemble[i].setChangeDetector((ChangeDetector) this.driftDetectionMethodOption.getValue());
    ensemble[i].init(builder, this.dataset, 1); // sequential
  }

  PredictionCombinerProcessor predictionCombinerP = new PredictionCombinerProcessor();
  predictionCombinerP.setEnsembleSize(ensembleSize);
  this.builder.addProcessor(predictionCombinerP, 1);

  // Streams
  resultStream = builder.createStream(predictionCombinerP);
  predictionCombinerP.setOutputStream(resultStream);

  for (AdaptiveLearner member : ensemble) {
    for (Stream subResultStream : member.getResultStreams()) { // a learner can have multiple output streams
      this.builder.connectInputKeyStream(subResultStream, predictionCombinerP); // the key is the instance id to combine predictions
    }
  }

  ensembleStreams = new Stream[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    ensembleStreams[i] = builder.createStream(distributorP);
    builder.connectInputShuffleStream(ensembleStreams[i], ensemble[i].getInputProcessor()); // connect streams one-to-one with ensemble members (the type of connection does not matter)
  }

  distributorP.setOutputStreams(ensembleStreams);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:48,代码来源:AdaptiveBagging.java

示例8: setLayout

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * Sets the layout.
 */
protected void setLayout() {

  int ensembleSize = this.ensembleSizeOption.getValue();

  distributor = new ShardingDistributorProcessor();
  distributor.setEnsembleSize(ensembleSize);
  this.builder.addProcessor(distributor, 1);

  // instantiate classifier
  ensemble = new Learner[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    try {
      ensemble[i] = (Learner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(),
          baseLearnerOption.getRequiredType());
    } catch (Exception e) {
      logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
      e.printStackTrace();
      throw new IllegalArgumentException(e);
    }
    ensemble[i].init(builder, this.dataset, 1); // sequential
  }

  PredictionCombinerProcessor predictionCombiner = new PredictionCombinerProcessor();
  predictionCombiner.setEnsembleSize(ensembleSize);
  this.builder.addProcessor(predictionCombiner, 1);

  // Streams
  resultStream = this.builder.createStream(predictionCombiner);
  predictionCombiner.setOutputStream(resultStream);

  for (Learner member : ensemble) {
    for (Stream subResultStream : member.getResultStreams()) { // a learner can have multiple output streams
      this.builder.connectInputKeyStream(subResultStream, predictionCombiner); // the key is the instance id to combine predictions
    }
  }

  ensembleStreams = new Stream[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    ensembleStreams[i] = builder.createStream(distributor);
    builder.connectInputShuffleStream(ensembleStreams[i], ensemble[i].getInputProcessor()); // connect streams one-to-one with ensemble members (the type of connection does not matter)
  }
  
  distributor.setOutputStreams(ensembleStreams);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:48,代码来源:Sharding.java

示例9: setLayout

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * Sets the layout.
 * 
 * @throws Exception
 */
protected void setLayout() {
  int ensembleSize = this.ensembleSizeOption.getValue();

  distributorP = new BaggingDistributorProcessor();
  distributorP.setEnsembleSize(ensembleSize);
  builder.addProcessor(distributorP, 1);

  // instantiate classifier
  ensemble = new Learner[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    try {
      ensemble[i] = (Learner) ClassOption.createObject(baseLearnerOption.getValueAsCLIString(),
          baseLearnerOption.getRequiredType());
    } catch (Exception e) {
      logger.error("Unable to create members of the ensemble. Please check your CLI parameters");
      e.printStackTrace();
      throw new IllegalArgumentException(e);
    }
    ensemble[i].init(builder, this.dataset, 1); // sequential
  }

  PredictionCombinerProcessor predictionCombinerP = new PredictionCombinerProcessor();
  predictionCombinerP.setEnsembleSize(ensembleSize);
  this.builder.addProcessor(predictionCombinerP, 1);

  // Streams
  resultStream = builder.createStream(predictionCombinerP);
  predictionCombinerP.setOutputStream(resultStream);

  for (Learner member : ensemble) {
    for (Stream subResultStream : member.getResultStreams()) { // a learner can have multiple output streams
      this.builder.connectInputKeyStream(subResultStream, predictionCombinerP); // the key is the instance id to combine predictions
    }
  }

  ensembleStreams = new Stream[ensembleSize];
  for (int i = 0; i < ensembleSize; i++) {
    ensembleStreams[i] = builder.createStream(distributorP);
    builder.connectInputShuffleStream(ensembleStreams[i], ensemble[i].getInputProcessor()); // connect streams one-to-one with ensemble members (the type of connection does not matter)
  }

  distributorP.setOutputStreams(ensembleStreams);
}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:49,代码来源:Bagging.java

示例10: main

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
public static void main(String[] args) {
  // Read arguments
  List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));
  parseArguments(tmpArgs);

  args = tmpArgs.toArray(new String[0]);

  // Init Task
  StringBuilder cliString = new StringBuilder();
  for (int i = 0; i < args.length; i++) {
    cliString.append(" ").append(args[i]);
  }
  logger.debug("Command line string = {}", cliString.toString());
  System.out.println("Command line string = " + cliString.toString());

  Task task = null;
  try {
    task = (Task) ClassOption.cliStringToObject(cliString.toString(), Task.class, null);
    logger.info("Sucessfully instantiating {}", task.getClass().getCanonicalName());
  } catch (Exception e) {
    logger.error("Fail to initialize the task", e);
    System.out.println("Fail to initialize the task" + e);
    return;
  }
  task.setFactory(new SamzaComponentFactory());
  task.init();

  // Upload JAR file to HDFS
  String hdfsPath = null;
  if (!isLocal) {
    Path path = FileSystems.getDefault().getPath(jarPackagePath);
    hdfsPath = uploadJarToHDFS(path.toFile());
    if (hdfsPath == null) {
      System.out.println("Fail uploading JAR file \"" + path.toAbsolutePath().toString() + "\" to HDFS.");
      return;
    }
  }

  // Set parameters
  SamzaEngine.getEngine()
      .setLocalMode(isLocal)
      .setZooKeeper(zookeeper)
      .setKafka(kafka)
      .setYarnPackage(hdfsPath)
      .setKafkaReplicationFactor(kafkaReplicationFactor)
      .setConfigHome(yarnConfHome)
      .setAMMemory(amMem)
      .setContainerMemory(containerMem)
      .setPiPerContainerRatio(piPerContainer)
      .setKryoRegisterFile(kryoRegisterFile)
      .setCheckpointFrequency(checkpointFrequency);

  // Submit topology
  SamzaEngine.submitTopology((SamzaTopology) task.getTopology());

}
 
开发者ID:apache,项目名称:incubator-samoa,代码行数:57,代码来源:SamzaDoTask.java

示例11: main

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
public static void main(String[] args) {
	// Read arguments
	List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));
	parseArguments(tmpArgs);
	
	args = tmpArgs.toArray(new String[0]);
	
	// Init Task
	StringBuilder cliString = new StringBuilder();
       for (int i = 0; i < args.length; i++) {
           cliString.append(" ").append(args[i]);
       }
       logger.debug("Command line string = {}", cliString.toString());
       System.out.println("Command line string = " + cliString.toString());
       
	Task task = null;
       try {
           task = (Task) ClassOption.cliStringToObject(cliString.toString(), Task.class, null);
           logger.info("Sucessfully instantiating {}", task.getClass().getCanonicalName());
       } catch (Exception e) {
           logger.error("Fail to initialize the task", e);
           System.out.println("Fail to initialize the task" + e);
           return;
       }
	task.setFactory(new SamzaComponentFactory());
	task.init();
	
	// Upload JAR file to HDFS
	String hdfsPath = null;
	if (!isLocal) {
		Path path = FileSystems.getDefault().getPath(jarPackagePath);
		hdfsPath = uploadJarToHDFS(path.toFile());
		if(hdfsPath == null) {
			System.out.println("Fail uploading JAR file \""+path.toAbsolutePath().toString()+"\" to HDFS.");
			return;
		}
	}
	
	// Set parameters
	SamzaEngine.getEngine()
	.setLocalMode(isLocal)
	.setZooKeeper(zookeeper)
	.setKafka(kafka)
	.setYarnPackage(hdfsPath)
	.setKafkaReplicationFactor(kafkaReplicationFactor)
	.setConfigHome(yarnConfHome)
	.setAMMemory(amMem)
	.setContainerMemory(containerMem)
	.setPiPerContainerRatio(piPerContainer)
	.setKryoRegisterFile(kryoRegisterFile)
	.setCheckpointFrequency(checkpointFrequency);
	
	// Submit topology
	SamzaEngine.submitTopology((SamzaTopology)task.getTopology());
	
}
 
开发者ID:YahooArchive,项目名称:samoa,代码行数:57,代码来源:SamzaDoTask.java

示例12: MOAClassifierAdapter

import com.github.javacliparser.ClassOption; //导入依赖的package包/类
/**
 * Instantiates a new learner.
 *
 * @param dataset the dataset
 * @param learnerOption the learner option
 */
public MOAClassifierAdapter(Instances dataset, ClassOption learnerOption) {        
    this.isInit = false;
    this.dataset = dataset;
    this.learnerOption = (ClassOption) learnerOption.copy();
}
 
开发者ID:samoa-moa,项目名称:samoa-moa,代码行数:12,代码来源:MOAClassifierAdapter.java


注:本文中的com.github.javacliparser.ClassOption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。