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


Java WritableUtils.isNegativeVInt方法代碼示例

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


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

示例1: _readMvccVersion

import org.apache.hadoop.io.WritableUtils; //導入方法依賴的package包/類
/**
 * Actually do the mvcc read. Does no checks.
 * @param position
 */
private void _readMvccVersion(final int position) {
  // This is Bytes#bytesToVint inlined so can save a few instructions in this hot method; i.e.
  // previous if one-byte vint, we'd redo the vint call to find int size.
  // Also the method is kept small so can be inlined.
  byte firstByte = blockBuffer.array()[position];
  int len = WritableUtils.decodeVIntSize(firstByte);
  if (len == 1) {
    this.currMemstoreTS = firstByte;
  } else {
    long i = 0;
    for (int idx = 0; idx < len - 1; idx++) {
      byte b = blockBuffer.array()[position + 1 + idx];
      i = i << 8;
      i = i | (b & 0xFF);
    }
    currMemstoreTS = (WritableUtils.isNegativeVInt(firstByte) ? ~i : i);
  }
  this.currMemstoreTSLen = len;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:HFileReaderV2.java

示例2: bytesToVint

import org.apache.hadoop.io.WritableUtils; //導入方法依賴的package包/類
/**
 * @param buffer buffer to convert
 * @return vint bytes as an integer.
 */
public static long bytesToVint(final byte [] buffer) {
  int offset = 0;
  byte firstByte = buffer[offset++];
  int len = WritableUtils.decodeVIntSize(firstByte);
  if (len == 1) {
    return firstByte;
  }
  long i = 0;
  for (int idx = 0; idx < len-1; idx++) {
    byte b = buffer[offset++];
    i = i << 8;
    i = i | (b & 0xFF);
  }
  return (WritableUtils.isNegativeVInt(firstByte) ? ~i : i);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:Bytes.java

示例3: readVLong

import org.apache.hadoop.io.WritableUtils; //導入方法依賴的package包/類
/**
 * Similar to {@link WritableUtils#readVLong(DataInput)} but reads from a
 * {@link ByteBuffer}.
 */
public static long readVLong(ByteBuffer in) {
  byte firstByte = in.get();
  int len = WritableUtils.decodeVIntSize(firstByte);
  if (len == 1) {
    return firstByte;
  }
  long i = 0;
  for (int idx = 0; idx < len-1; idx++) {
    byte b = in.get();
    i = i << 8;
    i = i | (b & 0xFF);
  }
  return (WritableUtils.isNegativeVInt(firstByte) ? (i ^ -1L) : i);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:ByteBufferUtils.java

示例4: readAsVLong

import org.apache.hadoop.io.WritableUtils; //導入方法依賴的package包/類
/**
 * Reads a zero-compressed encoded long from input buffer and returns it.
 * @param buffer Binary array
 * @param offset Offset into array at which vint begins.
 * @return deserialized long from buffer.
 */
public static long readAsVLong(final byte [] buffer, final int offset) {
  byte firstByte = buffer[offset];
  int len = WritableUtils.decodeVIntSize(firstByte);
  if (len == 1) {
    return firstByte;
  }
  long i = 0;
  for (int idx = 0; idx < len-1; idx++) {
    byte b = buffer[offset + 1 + idx];
    i = i << 8;
    i = i | (b & 0xFF);
  }
  return (WritableUtils.isNegativeVInt(firstByte) ? ~i : i);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:Bytes.java


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