当前位置: 首页>>代码示例>>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;未经允许,请勿转载。