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


Java ByteBufferUtils.toLong方法代码示例

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


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

示例1: 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

示例2: getCell

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
protected Cell getCell(int i) {
  // get the index of the relevant chunk inside chunk array
  int chunkIndex = (i / NUM_OF_CELL_REPS_IN_CHUNK);
  ByteBuffer block = chunks[chunkIndex].getData();// get the ByteBuffer of the relevant chunk
  int j = i - chunkIndex * NUM_OF_CELL_REPS_IN_CHUNK; // get the index of the cell-representation

  // find inside the offset inside the chunk holding the index, skip bytes for chunk id
  int offsetInBytes = ChunkCreator.SIZEOF_CHUNK_HEADER + j* ClassSize.CELL_CHUNK_MAP_ENTRY;

  // find the chunk holding the data of the cell, the chunkID is stored first
  int chunkId = ByteBufferUtils.toInt(block, offsetInBytes);
  Chunk chunk = ChunkCreator.getInstance().getChunk(chunkId);
  if (chunk == null) {
    // this should not happen
    throw new IllegalArgumentException("In CellChunkMap, cell must be associated with chunk."
        + ". We were looking for a cell at index " + i);
  }

  // find the offset of the data of the cell, skip integer for chunkID, offset is stored second
  int offsetOfCell = ByteBufferUtils.toInt(block, offsetInBytes + Bytes.SIZEOF_INT);
  // find the length of the data of the cell, skip two integers for chunkID and offset,
  // length is stored third
  int lengthOfCell = ByteBufferUtils.toInt(block, offsetInBytes + 2*Bytes.SIZEOF_INT);
  // find the seqID of the cell, skip three integers for chunkID, offset, and length
  // the seqID is plain written as part of the cell representation
  long cellSeqID = ByteBufferUtils.toLong(block, offsetInBytes + 3*Bytes.SIZEOF_INT);

  ByteBuffer buf = chunk.getData();   // get the ByteBuffer where the cell data is stored
  if (buf == null) {
    // this should not happen
    throw new IllegalArgumentException("In CellChunkMap, chunk must be associated with ByteBuffer."
        + " Chunk: " + chunk + " Chunk ID: " + chunk.getId() + ", is from pool: "
        + chunk.isFromPool() + ". We were looking for a cell at index " + i);
  }

  return new ByteBufferChunkKeyValue(buf, offsetOfCell, lengthOfCell, cellSeqID);
}
 
开发者ID:apache,项目名称:hbase,代码行数:39,代码来源:CellChunkMap.java

示例3: getValueAsLong

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
 * Converts the value bytes of the given cell into a long value
 * @param cell
 * @return value as long
 */
public static long getValueAsLong(Cell cell) {
  if (cell instanceof ByteBufferExtendedCell) {
    return ByteBufferUtils.toLong(((ByteBufferExtendedCell) cell).getValueByteBuffer(),
      ((ByteBufferExtendedCell) cell).getValuePosition());
  }
  return Bytes.toLong(cell.getValueArray(), cell.getValueOffset());
}
 
开发者ID:apache,项目名称:hbase,代码行数:13,代码来源:PrivateCellUtil.java

示例4: getValueAsLong

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

示例5: compareTo

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public int compareTo(ByteBuffer value, int offset, int length) {
  long that = ByteBufferUtils.toLong(value, offset);
  return Long.compare(longValue, that);
}
 
开发者ID:apache,项目名称:hbase,代码行数:6,代码来源:LongComparator.java

示例6: getTimestamp

import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public long getTimestamp() {
  int offset = getTimestampOffset(getKeyLen());
  return ByteBufferUtils.toLong(this.buf, offset);
}
 
开发者ID:apache,项目名称:hbase,代码行数:6,代码来源:ByteBufferKeyValue.java

示例7: getTimestamp

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


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