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


Java WritableComparator.get方法代码示例

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


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

示例1: WritableSortable

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
public WritableSortable(int j) throws IOException {
  seed = r.nextLong();
  r.setSeed(seed);
  Text t = new Text();
  StringBuilder sb = new StringBuilder();
  indices = new int[j];
  offsets = new int[j];
  check = new String[j];
  DataOutputBuffer dob = new DataOutputBuffer();
  for (int i = 0; i < j; ++i) {
    indices[i] = i;
    offsets[i] = dob.getLength();
    genRandom(t, r.nextInt(15) + 1, sb);
    t.write(dob);
    check[i] = t.toString();
  }
  eob = dob.getLength();
  bytes = dob.getData();
  comparator = WritableComparator.get(Text.class);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestIndexedSort.java

示例2: add

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
/**
 * Add a RecordReader to this collection.
 * The id() of a RecordReader determines where in the Tuple its
 * entry will appear. Adding RecordReaders with the same id has
 * undefined behavior.
 */
public void add(ComposableRecordReader<K,? extends V> rr) throws IOException {
  kids[rr.id()] = rr;
  if (null == q) {
    cmp = WritableComparator.get(rr.createKey().getClass(), conf);
    q = new PriorityQueue<ComposableRecordReader<K,?>>(3,
        new Comparator<ComposableRecordReader<K,?>>() {
          public int compare(ComposableRecordReader<K,?> o1,
                             ComposableRecordReader<K,?> o2) {
            return cmp.compare(o1.key(), o2.key());
          }
        });
  }
  if (rr.hasNext()) {
    q.add(rr);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:CompositeRecordReader.java

示例3: getOutputKeyComparator

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
/**
 * Get the {@link RawComparator} comparator used to compare keys.
 * 
 * @return the {@link RawComparator} comparator used to compare keys.
 */
public RawComparator getOutputKeyComparator() {
  Class<? extends RawComparator> theClass = getClass(
    JobContext.KEY_COMPARATOR, null, RawComparator.class);
  if (theClass != null)
    return ReflectionUtils.newInstance(theClass, this);
  return WritableComparator.get(getMapOutputKeyClass().asSubclass(WritableComparable.class), this);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:JobConf.java

示例4: initialize

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
public void initialize(InputSplit split,
                       TaskAttemptContext context)
throws IOException, InterruptedException {
  rr.initialize(split, context);
  conf = context.getConfiguration();
  nextKeyValue();
  if (!empty) {
    keyclass = key.getClass().asSubclass(WritableComparable.class);
    valueclass = value.getClass();
    if (cmp == null) {
      cmp = WritableComparator.get(keyclass, conf);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:WrappedRecordReader.java

示例5: initialize

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void initialize(InputSplit split, TaskAttemptContext context) 
    throws IOException, InterruptedException {
  if (kids != null) {
    for (int i = 0; i < kids.length; ++i) {
      kids[i].initialize(((CompositeInputSplit)split).get(i), context);
      if (kids[i].key() == null) {
        continue;
      }
      
      // get keyclass
      if (keyclass == null) {
        keyclass = kids[i].createKey().getClass().
          asSubclass(WritableComparable.class);
      }
      // create priority queue
      if (null == q) {
        cmp = WritableComparator.get(keyclass, conf);
        q = new PriorityQueue<ComposableRecordReader<K,?>>(3,
              new Comparator<ComposableRecordReader<K,?>>() {
                public int compare(ComposableRecordReader<K,?> o1,
                                   ComposableRecordReader<K,?> o2) {
                  return cmp.compare(o1.key(), o2.key());
                }
              });
      }
      // Explicit check for key class agreement
      if (!keyclass.equals(kids[i].key().getClass())) {
        throw new ClassCastException("Child key classes fail to agree");
      }
      
      // add the kid to priority queue if it has any elements
      if (kids[i].hasNext()) {
        q.add(kids[i]);
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:CompositeRecordReader.java

示例6: Sorter

import org.apache.hadoop.io.WritableComparator; //导入方法依赖的package包/类
/** Sort and merge files containing the named classes. */
public Sorter(FileSystem fs, Class<? extends WritableComparable> keyClass,
              Class valClass, Configuration conf)  {
  this(fs, WritableComparator.get(keyClass), keyClass, valClass, conf);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:6,代码来源:SequenceFile.java


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