org.apache.hadoop.mapreduce.InputSplit.getLength()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.apache.hadoop.mapreduce.InputSplit.getLength()方法的一些代码示例,展示了InputSplit.getLength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InputSplit.getLength()方法的具体详情如下:
包路径:org.apache.hadoop.mapreduce.InputSplit
类名称:InputSplit
方法名:getLength

InputSplit.getLength介绍

[英]Get the size of the split, so that the input splits can be sorted by size.
[中]获取拆分的大小,以便可以按大小对输入拆分进行排序。

代码示例

代码示例来源:origin: apache/ignite

@Override public boolean nextKeyValue() throws IOException, InterruptedException {
  return cnt++ < split.getLength();
}

代码示例来源:origin: apache/ignite

@Override public boolean nextKeyValue() throws IOException, InterruptedException {
  return ++cnt <= split.getLength();
}

代码示例来源:origin: apache/ignite

@Override public float getProgress() throws IOException, InterruptedException {
  return (float)cnt / split.getLength();
}

代码示例来源:origin: apache/kylin

public static double getTotalMapInputMB(Job job)
    throws ClassNotFoundException, IOException, InterruptedException, JobException {
  if (job == null) {
    throw new JobException("Job is null");
  }
  long mapInputBytes = 0;
  InputFormat<?, ?> input = ReflectionUtils.newInstance(job.getInputFormatClass(), job.getConfiguration());
  for (InputSplit split : input.getSplits(job)) {
    mapInputBytes += split.getLength();
  }
  
  // 0 input bytes is possible when the segment range hits no partition on a partitioned hive table (KYLIN-2470) 
  if (mapInputBytes == 0) {
    logger.warn("Map input splits are 0 bytes, something is wrong?");
  }
  
  double totalMapInputMB = (double) mapInputBytes / 1024 / 1024;
  return totalMapInputMB;
}

代码示例来源:origin: apache/hive

protected static FileSplit getFileSplit(Job vectorJob) throws IOException, InterruptedException {
 ParquetInputFormat parquetInputFormat = new ParquetInputFormat(GroupReadSupport.class);
 InputSplit split = (InputSplit) parquetInputFormat.getSplits(vectorJob).get(0);
 FileSplit fsplit = new FileSplit(file, 0L, split.getLength(), split.getLocations());
 return fsplit;
}

代码示例来源:origin: KylinOLAP/Kylin

protected double getTotalMapInputMB() throws ClassNotFoundException, IOException, InterruptedException, JobException {
  if (job == null) {
    throw new JobException("Job is null");
  }
  long mapInputBytes = 0;
  InputFormat<?, ?> input = ReflectionUtils.newInstance(job.getInputFormatClass(), job.getConfiguration());
  for (InputSplit split : input.getSplits(job)) {
    mapInputBytes += split.getLength();
  }
  if (mapInputBytes == 0) {
    throw new IllegalArgumentException("Map input splits are 0 bytes, something is wrong!");
  }
  double totalMapInputMB = (double) mapInputBytes / 1024 / 1024;
  return totalMapInputMB;
}

代码示例来源:origin: org.apache.pig/pig

/**
 * Return the length of a wrapped split
 * @param idx the index into the wrapped splits
 * @return number of wrapped splits
 */
public long getLength(int idx) throws IOException, InterruptedException {
  return wrappedSplits[idx].getLength();
}

代码示例来源:origin: io.hops/hadoop-mapreduce-client-core

/**
 * Get the length of ith child InputSplit.
 */
public long getLength(int i) throws IOException, InterruptedException {
 return splits[i].getLength();
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapred

/**
 * Get the length of ith child InputSplit.
 */
public long getLength(int i) throws IOException, InterruptedException {
 return splits[i].getLength();
}

代码示例来源:origin: org.apache.pig/pig

@Override
public long getLength() throws IOException, InterruptedException {
  if (length == -1) {
    length = 0;
    for (int i = 0; i < wrappedSplits.length; i++)
      length += wrappedSplits[i].getLength();
  }
  return length;
}

代码示例来源:origin: com.moz.fiji.express/fiji-express-lib

@Override
public long getLength() throws IOException {
 try {
  return realSplit.getLength();
 } catch (InterruptedException e) {
  throw new IOException(e);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-gridmix

@Override
public void initialize(InputSplit split, TaskAttemptContext ctxt)
  throws IOException, InterruptedException {
 toWrite = split.getLength();
 RINTERVAL = ctxt.getConfiguration().getInt(
   GRIDMIX_GEN_INTERVAL, 10) << 20;
}
@Override

代码示例来源:origin: com.google.cloud.bigdataoss/util-hadoop

public static String toString(InputSplit input) throws IOException, InterruptedException {
 if (input == null) {
  return "null";
 }
 String result = "InputSplit::";
 result += " length:" + input.getLength();
 result += " locations: " + Arrays.toString(input.getLocations());
 result += " toString(): " + input.toString();
 return result;
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapred

public SplitMetaInfo(InputSplit split, long startOffset) throws IOException {
 try {
  this.locations = split.getLocations();
  this.inputDataLength = split.getLength();
  this.startOffset = startOffset;
 } catch (InterruptedException ie) {
  throw new IOException(ie);
 }
}

代码示例来源:origin: com.marklogic/mlcp

protected void initStream(InputSplit inSplit)
    throws IOException, InterruptedException {
  FSDataInputStream in = openFile(inSplit, false);
  if (in == null) {
    return;
  }
  long size = inSplit.getLength();
  initParser(file.toUri().toASCIIString(), size);
  parse(file.getName(), in);
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapred

public TaskSplitMetaInfo(InputSplit split, long startOffset) 
throws InterruptedException, IOException {
 this(new TaskSplitIndex("", startOffset), split.getLocations(), 
   split.getLength());
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

public TaskSplitMetaInfo(InputSplit split, long startOffset) 
throws InterruptedException, IOException {
 this(new TaskSplitIndex("", startOffset), split.getLocations(), 
   split.getLength());
}

代码示例来源:origin: ch.cern.hadoop/hadoop-mapreduce-client-core

public TaskSplitMetaInfo(InputSplit split, long startOffset) 
throws InterruptedException, IOException {
 this(new TaskSplitIndex("", startOffset), split.getLocations(), 
   split.getLength());
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-core

public TaskSplitMetaInfo(InputSplit split, long startOffset) 
throws InterruptedException, IOException {
 this(new TaskSplitIndex("", startOffset), split.getLocations(), 
   split.getLength());
}

代码示例来源:origin: com.marklogic/mlcp

@Override
public void initialize(InputSplit inSplit, TaskAttemptContext context)
throws IOException, InterruptedException {
  initConfig(context);
  iterator = new FileIterator(((CombineDocumentSplit) inSplit)
    .getSplits().iterator(), context);
  bytesTotal = inSplit.getLength();
  this.context = context;
  batchSize = conf.getInt(MarkLogicConstants.BATCH_SIZE, 
          MarkLogicConstants.DEFAULT_BATCH_SIZE);
}

相关文章

微信公众号

最新文章

更多