本文整理汇总了Java中org.apache.hadoop.hbase.util.ByteBufferUtils.toShort方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferUtils.toShort方法的具体用法?Java ByteBufferUtils.toShort怎么用?Java ByteBufferUtils.toShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.ByteBufferUtils
的用法示例。
在下文中一共展示了ByteBufferUtils.toShort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: getTagValuePartAsShort
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private static short getTagValuePartAsShort(Tag t, int offset) {
if (t.hasArray()) {
return Bytes.toShort(t.getValueArray(), offset);
}
return ByteBufferUtils.toShort(t.getValueByteBuffer(), offset);
}
示例3: getRowLen
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private short getRowLen() {
return ByteBufferUtils.toShort(this.buf, this.offset + KeyValue.ROW_OFFSET);
}
示例4: setKey
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* A setter that helps to avoid object creation every time and whenever
* there is a need to create new OffheapKeyOnlyKeyValue.
* @param key
* @param offset
* @param length
*/
public void setKey(ByteBuffer key, int offset, int length) {
this.buf = key;
this.offset = offset;
this.length = length;
this.rowLen = ByteBufferUtils.toShort(this.buf, this.offset);
}