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


Java OutputType.LONG属性代码示例

本文整理汇总了Java中org.apache.hadoop.fs.slive.OperationOutput.OutputType.LONG属性的典型用法代码示例。如果您正苦于以下问题:Java OutputType.LONG属性的具体用法?Java OutputType.LONG怎么用?Java OutputType.LONG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.hadoop.fs.slive.OperationOutput.OutputType的用法示例。


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

示例1: map

@Override // Mapper
public void map(Object key, Object value, OutputCollector<Text, Text> output,
    Reporter reporter) throws IOException {
  logAndSetStatus(reporter, "Running slive mapper for dummy key " + key
      + " and dummy value " + value);
  //Add taskID to randomSeed to deterministically seed rnd.
  Random rnd = config.getRandomSeed() != null ?
    new Random(this.taskId + config.getRandomSeed()) : new Random();
  WeightSelector selector = new WeightSelector(config, rnd);
  long startTime = Timer.now();
  long opAm = 0;
  long sleepOps = 0;
  int duration = getConfig().getDurationMilliseconds();
  Range<Long> sleepRange = getConfig().getSleepRange();
  Operation sleeper = null;
  if (sleepRange != null) {
    sleeper = new SleepOp(getConfig(), rnd);
  }
  while (Timer.elapsed(startTime) < duration) {
    try {
      logAndSetStatus(reporter, "Attempting to select operation #"
          + (opAm + 1));
      int currElapsed = (int) (Timer.elapsed(startTime));
      Operation op = selector.select(currElapsed, duration);
      if (op == null) {
        // no ops left
        break;
      } else {
        // got a good op
        ++opAm;
        runOperation(op, reporter, output, opAm);
      }
      // do a sleep??
      if (sleeper != null) {
        // these don't count against the number of operations
        ++sleepOps;
        runOperation(sleeper, reporter, output, sleepOps);
      }
    } catch (Exception e) {
      logAndSetStatus(reporter, "Failed at running due to "
          + StringUtils.stringifyException(e));
      if (getConfig().shouldExitOnFirstError()) {
        break;
      }
    }
  }
  // write out any accumulated mapper stats
  {
    long timeTaken = Timer.elapsed(startTime);
    OperationOutput opCount = new OperationOutput(OutputType.LONG, OP_TYPE,
        ReportWriter.OP_COUNT, opAm);
    output.collect(opCount.getKey(), opCount.getOutputValue());
    OperationOutput overallTime = new OperationOutput(OutputType.LONG,
        OP_TYPE, ReportWriter.OK_TIME_TAKEN, timeTaken);
    output.collect(overallTime.getKey(), overallTime.getOutputValue());
    logAndSetStatus(reporter, "Finished " + opAm + " operations in "
        + timeTaken + " milliseconds");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:59,代码来源:SliveMapper.java

示例2: map

@Override // Mapper
public void map(Object key, Object value, OutputCollector<Text, Text> output,
    Reporter reporter) throws IOException {
  logAndSetStatus(reporter, "Running slive mapper for dummy key " + key
      + " and dummy value " + value);
  long startTime = Timer.now();
  long opAm = 0;
  long sleepOps = 0;
  int duration = getConfig().getDurationMilliseconds();
  Range<Long> sleepRange = getConfig().getSleepRange();
  Operation sleeper = null;
  if (sleepRange != null) {
    sleeper = new SleepOp(getConfig(), rnd);
  }
  WeightSelector selector = getSelector();
  while (Timer.elapsed(startTime) < duration) {
    try {
      logAndSetStatus(reporter, "Attempting to select operation #"
          + (opAm + 1));
      int currElapsed = (int) (Timer.elapsed(startTime));
      Operation op = selector.select(currElapsed, duration);
      if (op == null) {
        // no ops left
        break;
      } else {
        // got a good op
        ++opAm;
        runOperation(op, reporter, output, opAm);
      }
      // do a sleep??
      if (sleeper != null) {
        // these don't count against the number of operations
        ++sleepOps;
        runOperation(sleeper, reporter, output, sleepOps);
      }
    } catch (Exception e) {
      logAndSetStatus(reporter, "Failed at running due to "
          + StringUtils.stringifyException(e));
      if (getConfig().shouldExitOnFirstError()) {
        break;
      }
    }
  }
  // write out any accumulated mapper stats
  {
    long timeTaken = Timer.elapsed(startTime);
    OperationOutput opCount = new OperationOutput(OutputType.LONG, OP_TYPE,
        ReportWriter.OP_COUNT, opAm);
    output.collect(opCount.getKey(), opCount.getOutputValue());
    OperationOutput overallTime = new OperationOutput(OutputType.LONG,
        OP_TYPE, ReportWriter.OK_TIME_TAKEN, timeTaken);
    output.collect(overallTime.getKey(), overallTime.getOutputValue());
    logAndSetStatus(reporter, "Finished " + opAm + " operations in "
        + timeTaken + " milliseconds");
  }
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:56,代码来源:SliveMapper.java


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