當前位置: 首頁>>代碼示例>>Java>>正文


Java WritableComparator.compareBytes方法代碼示例

本文整理匯總了Java中org.apache.hadoop.io.WritableComparator.compareBytes方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableComparator.compareBytes方法的具體用法?Java WritableComparator.compareBytes怎麽用?Java WritableComparator.compareBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.io.WritableComparator的用法示例。


在下文中一共展示了WritableComparator.compareBytes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fillKey

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
private void fillKey(BytesWritable o) {
  int len = keyLenRNG.nextInt();
  if (len < MIN_KEY_LEN) len = MIN_KEY_LEN;
  o.setSize(len);
  int n = MIN_KEY_LEN;
  while (n < len) {
    byte[] word = dict[random.nextInt(dict.length)];
    int l = Math.min(word.length, len - n);
    System.arraycopy(word, 0, o.getBytes(), n, l);
    n += l;
  }
  if (sorted && WritableComparator.compareBytes(
          lastKey.getBytes(), MIN_KEY_LEN, lastKey.getLength() - MIN_KEY_LEN,
          o.getBytes(), MIN_KEY_LEN, o.getLength() - MIN_KEY_LEN) > 0) {
    incrementPrefix();
  }

  System.arraycopy(prefix, 0, o.getBytes(), 0, MIN_KEY_LEN);
  lastKey.set(o);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:21,代碼來源:KVGenerator.java

示例2: fillKey

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
private void fillKey(BytesWritable o) {
  int len = keyLenRNG.nextInt();
  if (len < MIN_KEY_LEN) len = MIN_KEY_LEN;
  o.setSize(len);
  int n = MIN_KEY_LEN;
  while (n < len) {
    byte[] word = dict[random.nextInt(dict.length)];
    int l = Math.min(word.length, len - n);
    System.arraycopy(word, 0, o.get(), n, l);
    n += l;
  }
  if (sorted
      && WritableComparator.compareBytes(lastKey.get(), MIN_KEY_LEN, lastKey
          .getSize()
          - MIN_KEY_LEN, o.get(), MIN_KEY_LEN, o.getSize() - MIN_KEY_LEN) > 0) {
    incrementPrefix();
  }

  System.arraycopy(prefix, 0, o.get(), 0, MIN_KEY_LEN);
  lastKey.set(o);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:KVGenerator.java

示例3: compareTo

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
/**
 * Compare bytes from {#getBytes()}.
 * @see org.apache.hadoop.io.WritableComparator#compareBytes(byte[],int,int,byte[],int,int)
 */
public int compareTo(BinaryComparable other) {
  if (this == other)
    return 0;
  return WritableComparator.compareBytes(getBytes(), 0, getLength(),
           other.getBytes(), 0, other.getLength());
}
 
開發者ID:spafka,項目名稱:spark_deep,代碼行數:11,代碼來源:BinaryComparable.java

示例4: prefixMatches

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
/**
 * Returns true if the byte array begins with the specified prefix.
 */
public static boolean prefixMatches(byte[] prefix, int prefixlen,
    byte[] b) {
  if (b.length < prefixlen) {
    return false;
  }
  return WritableComparator.compareBytes(prefix, 0, prefixlen, b, 0,
      prefixlen) == 0;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:12,代碼來源:LeveldbUtils.java

示例5: binSortTest

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
static void binSortTest(GridmixRecord x, GridmixRecord y, int min,
    int max, WritableComparator cmp) throws Exception {
  final Random r = new Random();
  final long s = r.nextLong();
  r.setSeed(s);
  LOG.info("sort: " + s);
  final DataOutputBuffer out1 = new DataOutputBuffer();
  final DataOutputBuffer out2 = new DataOutputBuffer();
  for (int i = min; i < max; ++i) {
    final long seed1 = r.nextLong();
    setSerialize(x, seed1, i, out1);
    assertEquals(0, x.compareSeed(seed1, Math.max(0, i - x.fixedBytes())));

    final long seed2 = r.nextLong();
    setSerialize(y, seed2, i, out2);
    assertEquals(0, y.compareSeed(seed2, Math.max(0, i - x.fixedBytes())));

    // for eq sized records, ensure byte cmp where req
    final int chk = WritableComparator.compareBytes(
        out1.getData(), 0, out1.getLength(),
        out2.getData(), 0, out2.getLength());
    assertEquals(Integer.signum(chk), Integer.signum(x.compareTo(y)));
    assertEquals(Integer.signum(chk), Integer.signum(cmp.compare(
          out1.getData(), 0, out1.getLength(),
          out2.getData(), 0, out2.getLength())));
    // write second copy, compare eq
    final int s1 = out1.getLength();
    x.write(out1);
    assertEquals(0, cmp.compare(out1.getData(), 0, s1,
          out1.getData(), s1, out1.getLength() - s1));
    final int s2 = out2.getLength();
    y.write(out2);
    assertEquals(0, cmp.compare(out2.getData(), 0, s2,
          out2.getData(), s2, out2.getLength() - s2));
    assertEquals(Integer.signum(chk), Integer.signum(cmp.compare(out1.getData(), 0, s1,
          out2.getData(), s2, out2.getLength() - s2)));
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:39,代碼來源:TestGridmixRecord.java

示例6: notInTable

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
private boolean notInTable(final TableName tn, final byte [] rn) {
  if (WritableComparator.compareBytes(tn.getName(), 0, tn.getName().length,
      rn, 0, tn.getName().length) != 0) {
    LOG.error("Region " + Bytes.toStringBinary(rn) + " does not belong to table " +
      tn);
    return true;
  }
  return false;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:10,代碼來源:Merge.java

示例7: compareTo

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
@Override
public final int compareTo(Key k) {
  byte[] b1 = this.key;
  byte[] b2 = k.key;

  return WritableComparator.compareBytes(b1, 0, b1.length, b2, 0, b2.length);
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:8,代碼來源:Key.java

示例8: compareTo

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
@Override
public int compareTo(GFKey o) {
  try {
    byte[] b1 = BlobHelper.serializeToBlob(key);
    byte[] b2 = BlobHelper.serializeToBlob(o.key);
    return WritableComparator.compareBytes(b1, 0, b1.length, b2, 0, b2.length);
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  
  return 0;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:14,代碼來源:GFKey.java

示例9: compare

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:5,代碼來源:CompareUtils.java

示例10: compareTo

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
public int compareTo(BinaryComparable other) {
    return this == other?0: WritableComparator.compareBytes(this.getBytes(), 0, this.getLength(), other.getBytes(), 0, other.getLength());
}
 
開發者ID:DStream-Storm,項目名稱:DStream,代碼行數:4,代碼來源:BinaryComparable.java

示例11: compare

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  int n1 = WritableUtils.decodeVIntSize(b1[s1]);
  int n2 = WritableUtils.decodeVIntSize(b2[s2]);
  return -1 * WritableComparator.compareBytes(b1, s1+n1, l1-n1,
                                              b2, s2+n2, l2-n2);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:7,代碼來源:TestTotalOrderPartitioner.java

示例12: compare

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  return WritableComparator.compareBytes(b1, s1, Integer.SIZE/8, 
                                         b2, s2, Integer.SIZE/8);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:6,代碼來源:SecondarySort.java

示例13: compareBytes

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
/** Lexicographic order of binary data. */
public static int compareBytes(byte[] b1, int s1, int l1,
                               byte[] b2, int s2, int l2) {
  return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:6,代碼來源:Utils.java

示例14: compare

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
@Override
public int compare(byte[] o1, byte[] o2) {
  return WritableComparator.compareBytes(o1, 0, o1.length, o2, 0, o2.length);
}
 
開發者ID:yncxcw,項目名稱:big-c,代碼行數:5,代碼來源:TestTFileJClassComparatorByteArrays.java

示例15: compareTo

import org.apache.hadoop.io.WritableComparator; //導入方法依賴的package包/類
/**
 * Define the sort order of the BytesWritable.
 * @param that The other bytes writable
 * @return Positive if left is bigger than right, 0 if they are equal, and
 *         negative if left is smaller than right.
 */
public int compareTo(ImmutableBytesWritable that) {
  return WritableComparator.compareBytes(
    this.bytes, this.offset, this.length,
    that.bytes, that.offset, that.length);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:ImmutableBytesWritable.java


注:本文中的org.apache.hadoop.io.WritableComparator.compareBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。