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


Java ByteBufferUtils.toByte方法代码示例

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


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

示例1: getTag

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Retrieve Cell's first tag, matching the passed in type
 * @param cell The Cell
 * @param type Type of the Tag to retrieve
 * @return null if there is no tag of the passed in tag type
 */
public static Optional<Tag> getTag(Cell cell, byte type) {
  boolean bufferBacked = cell instanceof ByteBufferExtendedCell;
  int length = cell.getTagsLength();
  int offset =
    bufferBacked ? ((ByteBufferExtendedCell) cell).getTagsPosition() : cell.getTagsOffset();
  int pos = offset;
  while (pos < offset + length) {
    int tagLen;
    if (bufferBacked) {
      ByteBuffer tagsBuffer = ((ByteBufferExtendedCell) cell).getTagsByteBuffer();
      tagLen = ByteBufferUtils.readAsInt(tagsBuffer, pos, TAG_LENGTH_SIZE);
      if (ByteBufferUtils.toByte(tagsBuffer, pos + TAG_LENGTH_SIZE) == type) {
        return Optional.of(new ByteBufferTag(tagsBuffer, pos, tagLen + TAG_LENGTH_SIZE));
      }
    } else {
      tagLen = Bytes.readAsInt(cell.getTagsArray(), pos, TAG_LENGTH_SIZE);
      if (cell.getTagsArray()[pos + TAG_LENGTH_SIZE] == type) {
        return Optional
          .of(new ArrayBackedTag(cell.getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE));
      }
    }
    pos += TAG_LENGTH_SIZE + tagLen;
  }
  return Optional.empty();
}
 
开发者ID:apache,项目名称:hbase,代码行数:32,代码来源:PrivateCellUtil.java

示例2: getInt

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private int getInt(int index, int itemIndex) {
  ByteBuffer item = items[itemIndex];
  int offsetInItem = index - this.itemBeginPos[itemIndex];
  int remainingLen = item.limit() - offsetInItem;
  if (remainingLen >= Bytes.SIZEOF_INT) {
    return ByteBufferUtils.toInt(item, offsetInItem);
  }
  if (items.length - 1 == itemIndex) {
    // means cur item is the last one and we wont be able to read a int. Throw exception
    throw new BufferUnderflowException();
  }
  ByteBuffer nextItem = items[itemIndex + 1];
  // Get available bytes from this item and remaining from next
  int l = 0;
  for (int i = offsetInItem; i < item.capacity(); i++) {
    l <<= 8;
    l ^= ByteBufferUtils.toByte(item, i) & 0xFF;
  }
  for (int i = 0; i < Bytes.SIZEOF_INT - remainingLen; i++) {
    l <<= 8;
    l ^= ByteBufferUtils.toByte(nextItem, i) & 0xFF;
  }
  return l;
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:MultiByteBuff.java

示例3: getShort

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private short getShort(int index, int itemIndex) {
  ByteBuffer item = items[itemIndex];
  int offsetInItem = index - this.itemBeginPos[itemIndex];
  int remainingLen = item.limit() - offsetInItem;
  if (remainingLen >= Bytes.SIZEOF_SHORT) {
    return ByteBufferUtils.toShort(item, offsetInItem);
  }
  if (items.length - 1 == itemIndex) {
    // means cur item is the last one and we wont be able to read a int. Throw exception
    throw new BufferUnderflowException();
  }
  ByteBuffer nextItem = items[itemIndex + 1];
  // Get available bytes from this item and remaining from next
  short l = 0;
  for (int i = offsetInItem; i < item.capacity(); i++) {
    l = (short) (l << 8);
    l = (short) (l ^ (ByteBufferUtils.toByte(item, i) & 0xFF));
  }
  for (int i = 0; i < Bytes.SIZEOF_SHORT - remainingLen; i++) {
    l = (short) (l << 8);
    l = (short) (l ^ (ByteBufferUtils.toByte(item, i) & 0xFF));
  }
  return l;
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:MultiByteBuff.java

示例4: getLong

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private long getLong(int index, int itemIndex) {
  ByteBuffer item = items[itemIndex];
  int offsetInItem = index - this.itemBeginPos[itemIndex];
  int remainingLen = item.limit() - offsetInItem;
  if (remainingLen >= Bytes.SIZEOF_LONG) {
    return ByteBufferUtils.toLong(item, offsetInItem);
  }
  if (items.length - 1 == itemIndex) {
    // means cur item is the last one and we wont be able to read a long. Throw exception
    throw new BufferUnderflowException();
  }
  ByteBuffer nextItem = items[itemIndex + 1];
  // Get available bytes from this item and remaining from next
  long l = 0;
  for (int i = offsetInItem; i < item.capacity(); i++) {
    l <<= 8;
    l ^= ByteBufferUtils.toByte(item, i) & 0xFF;
  }
  for (int i = 0; i < Bytes.SIZEOF_LONG - remainingLen; i++) {
    l <<= 8;
    l ^= ByteBufferUtils.toByte(nextItem, i) & 0xFF;
  }
  return l;
}
 
开发者ID:apache,项目名称:hbase,代码行数:25,代码来源:MultiByteBuff.java

示例5: getMinimumMidpointArray

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private static byte[] getMinimumMidpointArray(ByteBuffer left, int leftOffset, int leftLength,
    ByteBuffer right, int rightOffset, int rightLength) {
  // rows are different
  int minLength = leftLength < rightLength ? leftLength : rightLength;
  int diffIdx = 0;
  while (diffIdx < minLength && ByteBufferUtils.toByte(left,
      leftOffset + diffIdx) == ByteBufferUtils.toByte(right, rightOffset + diffIdx)) {
    diffIdx++;
  }
  byte[] minMidpoint = null;
  if (diffIdx >= minLength) {
    // leftKey's row is prefix of rightKey's.
    minMidpoint = new byte[diffIdx + 1];
    ByteBufferUtils.copyFromBufferToArray(minMidpoint, right, rightOffset, 0, diffIdx + 1);
  } else {
    int diffByte = ByteBufferUtils.toByte(left, leftOffset + diffIdx);
    if ((0xff & diffByte) < 0xff
        && (diffByte + 1) < (ByteBufferUtils.toByte(right, rightOffset + diffIdx) & 0xff)) {
      minMidpoint = new byte[diffIdx + 1];
      ByteBufferUtils.copyFromBufferToArray(minMidpoint, left, leftOffset, 0, diffIdx);
      minMidpoint[diffIdx] = (byte) (diffByte + 1);
    } else {
      minMidpoint = new byte[diffIdx + 1];
      ByteBufferUtils.copyFromBufferToArray(minMidpoint, right, rightOffset, 0, diffIdx + 1);
    }
  }
  return minMidpoint;
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:HFileWriterImpl.java

示例6: getValueAsByte

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Converts the value bytes of the given tag into a byte value
 * @param tag The Tag
 * @return value as byte
 */
public static byte getValueAsByte(Tag tag) {
  if (tag.hasArray()) {
    return tag.getValueArray()[tag.getValueOffset()];
  }
  return ByteBufferUtils.toByte(tag.getValueByteBuffer(), tag.getValueOffset());
}
 
开发者ID:apache,项目名称:hbase,代码行数:12,代码来源:Tag.java

示例7: getByteAfterPosition

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public byte getByteAfterPosition(int offset) {
  // Mostly the index specified will land within this current item. Short circuit for that
  int index = offset + this.position();
  int itemIndex = getItemIndexFromCurItemIndex(index);
  return ByteBufferUtils.toByte(this.items[itemIndex], index - this.itemBeginPos[itemIndex]);
}
 
开发者ID:apache,项目名称:hbase,代码行数:8,代码来源:MultiByteBuff.java

示例8: ByteBufferTag

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
public ByteBufferTag(ByteBuffer buffer, int offset, int length) {
  this.buffer = buffer;
  this.offset = offset;
  this.length = length;
  this.type = ByteBufferUtils.toByte(buffer, offset + TAG_LENGTH_SIZE);
}
 
开发者ID:apache,项目名称:hbase,代码行数:7,代码来源:ByteBufferTag.java

示例9: getFamilyLength

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private byte getFamilyLength(int famLenPos) {
  return ByteBufferUtils.toByte(this.buf, famLenPos);
}
 
开发者ID:apache,项目名称:hbase,代码行数:4,代码来源:ByteBufferKeyValue.java

示例10: getTypeByte

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public byte getTypeByte() {
  return ByteBufferUtils.toByte(this.buf,
    this.offset + getKeyLen() - 1 + KeyValue.ROW_OFFSET);
}
 
开发者ID:apache,项目名称:hbase,代码行数:6,代码来源:ByteBufferKeyValue.java

示例11: getTypeByte

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public byte getTypeByte() {
  return ByteBufferUtils.toByte(this.buf, this.offset + this.length - 1);
}
 
开发者ID:apache,项目名称:hbase,代码行数:5,代码来源:ByteBufferKeyOnlyKeyValue.java

示例12: get

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Fetches the byte at the given index. Does not change position of the underlying ByteBuffers
 * @param index
 * @return the byte at the given index
 */
@Override
public byte get(int index) {
  int itemIndex = getItemIndex(index);
  return ByteBufferUtils.toByte(this.items[itemIndex], index - this.itemBeginPos[itemIndex]);
}
 
开发者ID:apache,项目名称:hbase,代码行数:11,代码来源:MultiByteBuff.java


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