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


Java BytesComparator类代码示例

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


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

示例1: makeComparator

import org.apache.hadoop.io.file.tfile.CompareUtils.BytesComparator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static BytesComparator makeComparator(String comparator) {
  if (comparator.length() == 0) {
    // unsorted keys
    return null;
  }
  if (comparator.equals(COMPARATOR_MEMCMP)) {
    // default comparator
    return new BytesComparator(new MemcmpRawComparator());
  } else if (comparator.startsWith(COMPARATOR_JCLASS)) {
    String compClassName =
        comparator.substring(COMPARATOR_JCLASS.length()).trim();
    try {
      Class compClass = Class.forName(compClassName);
      // use its default ctor to create an instance
      return new BytesComparator((RawComparator<Object>) compClass
          .newInstance());
    } catch (Exception e) {
      throw new IllegalArgumentException(
          "Failed to instantiate comparator: " + comparator + "("
              + e.toString() + ")");
    }
  } else {
    throw new IllegalArgumentException("Unsupported comparator: "
        + comparator);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:28,代码来源:TFile.java

示例2: TFileIndex

import org.apache.hadoop.io.file.tfile.CompareUtils.BytesComparator; //导入依赖的package包/类
/**
 * For reading from file.
 * 
 * @throws IOException
 */
public TFileIndex(int entryCount, DataInput in, BytesComparator comparator)
    throws IOException {
  index = new ArrayList<TFileIndexEntry>(entryCount);
  recordNumIndex = new ArrayList<Long>(entryCount);
  int size = Utils.readVInt(in); // size for the first key entry.
  if (size > 0) {
    byte[] buffer = new byte[size];
    in.readFully(buffer);
    DataInputStream firstKeyInputStream =
        new DataInputStream(new ByteArrayInputStream(buffer, 0, size));

    int firstKeyLength = Utils.readVInt(firstKeyInputStream);
    firstKey = new ByteArray(new byte[firstKeyLength]);
    firstKeyInputStream.readFully(firstKey.buffer());

    for (int i = 0; i < entryCount; i++) {
      size = Utils.readVInt(in);
      if (buffer.length < size) {
        buffer = new byte[size];
      }
      in.readFully(buffer, 0, size);
      TFileIndexEntry idx =
          new TFileIndexEntry(new DataInputStream(new ByteArrayInputStream(
              buffer, 0, size)));
      index.add(idx);
      sum += idx.entries();
      recordNumIndex.add(sum);
    }
  } else {
    if (entryCount != 0) {
      throw new RuntimeException("Internal error");
    }
  }
  this.comparator = comparator;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:41,代码来源:TFile.java

示例3: TFileIndex

import org.apache.hadoop.io.file.tfile.CompareUtils.BytesComparator; //导入依赖的package包/类
/**
 * For reading from file.
 *
 * @throws IOException
 */
public TFileIndex(int entryCount, DataInput in, BytesComparator comparator)
    throws IOException {
  index = new ArrayList<TFileIndexEntry>(entryCount);
  recordNumIndex = new ArrayList<Long>(entryCount);
  int size = Utils.readVInt(in); // size for the first key entry.
  if (size > 0) {
    byte[] buffer = new byte[size];
    in.readFully(buffer);
    DataInputStream firstKeyInputStream =
        new DataInputStream(new ByteArrayInputStream(buffer, 0, size));

    int firstKeyLength = Utils.readVInt(firstKeyInputStream);
    firstKey = new ByteArray(new byte[firstKeyLength]);
    firstKeyInputStream.readFully(firstKey.buffer());

    for (int i = 0; i < entryCount; i++) {
      size = Utils.readVInt(in);
      if (buffer.length < size) {
        buffer = new byte[size];
      }
      in.readFully(buffer, 0, size);
      TFileIndexEntry idx =
          new TFileIndexEntry(new DataInputStream(new ByteArrayInputStream(
              buffer, 0, size)));
      index.add(idx);
      sum += idx.entries();
      recordNumIndex.add(sum);
    }
  } else {
    if (entryCount != 0) {
      throw new RuntimeException("Internal error");
    }
  }
  this.comparator = comparator;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:41,代码来源:DTFile.java

示例4: TFileIndex

import org.apache.hadoop.io.file.tfile.CompareUtils.BytesComparator; //导入依赖的package包/类
/**
 * For reading from file.
 * 
 * @throws IOException
 */
public TFileIndex(int entryCount, DataInput in, BytesComparator comparator)
    throws IOException {
  index = new ArrayList<TFileIndexEntry>(entryCount);
  int size = Utils.readVInt(in); // size for the first key entry.
  if (size > 0) {
    byte[] buffer = new byte[size];
    in.readFully(buffer);
    DataInputStream firstKeyInputStream =
        new DataInputStream(new ByteArrayInputStream(buffer, 0, size));

    int firstKeyLength = Utils.readVInt(firstKeyInputStream);
    firstKey = new ByteArray(new byte[firstKeyLength]);
    firstKeyInputStream.readFully(firstKey.buffer());

    for (int i = 0; i < entryCount; i++) {
      size = Utils.readVInt(in);
      if (buffer.length < size) {
        buffer = new byte[size];
      }
      in.readFully(buffer, 0, size);
      TFileIndexEntry idx =
          new TFileIndexEntry(new DataInputStream(new ByteArrayInputStream(
              buffer, 0, size)));
      index.add(idx);
    }
  } else {
    if (entryCount != 0) {
      throw new RuntimeException("Internal error");
    }
  }
  this.comparator = comparator;
}
 
开发者ID:koichi626,项目名称:hadoop-gpu,代码行数:38,代码来源:TFile.java

示例5: getComparator

import org.apache.hadoop.io.file.tfile.CompareUtils.BytesComparator; //导入依赖的package包/类
public BytesComparator getComparator() {
  return comparator;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:TFile.java


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