org.apache.hadoop.hbase.util.Bytes.putByte()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.hadoop.hbase.util.Bytes.putByte()方法的一些代码示例,展示了Bytes.putByte()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.putByte()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.util.Bytes
类名称:Bytes
方法名:putByte

Bytes.putByte介绍

[英]Write a single byte out to the specified byte array position.
[中]将单个字节写入指定的字节数组位置。

代码示例

代码示例来源:origin: apache/hbase

/**
  * Write instance {@code val} into buffer {@code buff}.
  */
 public int encodeByte(byte[] buff, int offset, byte val) {
  return Bytes.putByte(buff, offset, val);
 }
}

代码示例来源:origin: apache/hbase

public static byte[] appendMetaData(byte[] id, byte[] data) {
 if (data == null || data.length == 0) {
  return data;
 }
 byte[] salt = Bytes.toBytes(ThreadLocalRandom.current().nextLong());
 int idLength = id.length + salt.length;
 byte[] newData = new byte[MAGIC_SIZE + ID_LENGTH_SIZE + idLength + data.length];
 int pos = 0;
 pos = Bytes.putByte(newData, pos, MAGIC);
 pos = Bytes.putInt(newData, pos, idLength);
 pos = Bytes.putBytes(newData, pos, id, 0, id.length);
 pos = Bytes.putBytes(newData, pos, salt, 0, salt.length);
 pos = Bytes.putBytes(newData, pos, data, 0, data.length);
 return newData;
}

代码示例来源:origin: apache/hbase

pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(bytes, pos, row, roffset, rlength);
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));
if(flength != 0) {
 pos = Bytes.putBytes(bytes, pos, family, foffset, flength);
pos = Bytes.putByte(bytes, pos, type.getCode());
if (vlength > 0) {
 if (value instanceof ByteBuffer) {
  int tlen = t.getValueLength();
  pos = Bytes.putAsShort(bytes, pos, tlen + Tag.TYPE_LENGTH_SIZE);
  pos = Bytes.putByte(bytes, pos, t.getType());
  Tag.copyValueTo(t, bytes, pos);
  pos += tlen;

代码示例来源:origin: apache/hbase

/**
 * Format for a tag :
 * {@code <length of tag - 2 bytes><type code - 1 byte><tag>} tag length is serialized
 * using 2 bytes only but as this will be unsigned, we can have max tag length of
 * (Short.MAX_SIZE * 2) +1. It includes 1 byte type length and actual tag bytes length.
 */
public ArrayBackedTag(byte tagType, byte[] tag) {
 int tagLength = tag.length + TYPE_LENGTH_SIZE;
 if (tagLength > MAX_TAG_LENGTH) {
  throw new IllegalArgumentException(
    "Invalid tag data being passed. Its length can not exceed " + MAX_TAG_LENGTH);
 }
 length = TAG_LENGTH_SIZE + tagLength;
 bytes = new byte[length];
 int pos = Bytes.putAsShort(bytes, 0, tagLength);
 pos = Bytes.putByte(bytes, pos, tagType);
 Bytes.putBytes(bytes, pos, tag, 0, tag.length);
 this.type = tagType;
}

代码示例来源:origin: alibaba/canal

private static int encodeUnsignedByte(byte v, byte[] b, int o) {
  if (v < 0) {
    throw new RuntimeException();
  }
  Bytes.putByte(b, o, v);
  return Bytes.SIZEOF_BYTE;
}

代码示例来源:origin: apache/hbase

pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(bytes, pos, row, roffset, rlength);
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));
if(flength != 0) {
 pos = Bytes.putBytes(bytes, pos, family, foffset, flength);
pos = Bytes.putByte(bytes, pos, type.getCode());
if (value != null && value.length > 0) {
 pos = Bytes.putBytes(bytes, pos, value, voffset, vlength);

代码示例来源:origin: apache/hbase

@Override
public int encode(PositionedByteRange dst, Byte val) {
 Bytes.putByte(dst.getBytes(), dst.getOffset() + dst.getPosition(), val);
 return skip(dst);
}

代码示例来源:origin: apache/hbase

pos = Bytes.putShort(buffer, pos, (short)(rlength & 0x0000ffff));
pos = Bytes.putBytes(buffer, pos, row, roffset, rlength);
pos = Bytes.putByte(buffer, pos, (byte) (flength & 0x0000ff));
if (flength != 0) {
 pos = Bytes.putBytes(buffer, pos, family, foffset, flength);
pos = Bytes.putByte(buffer, pos, type.getCode());
if (value != null && value.length > 0) {
 pos = Bytes.putBytes(buffer, pos, value, voffset, vlength);
  int tlen = t.getValueLength();
  pos = Bytes.putAsShort(buffer, pos, tlen + Tag.TYPE_LENGTH_SIZE);
  pos = Bytes.putByte(buffer, pos, t.getType());
  Tag.copyValueTo(t, buffer, pos);
  pos += tlen;

代码示例来源:origin: apache/hbase

public static int appendKeyTo(final Cell cell, final byte[] output,
  final int offset) {
 int nextOffset = offset;
 nextOffset = Bytes.putShort(output, nextOffset, cell.getRowLength());
 nextOffset = CellUtil.copyRowTo(cell, output, nextOffset);
 nextOffset = Bytes.putByte(output, nextOffset, cell.getFamilyLength());
 nextOffset = CellUtil.copyFamilyTo(cell, output, nextOffset);
 nextOffset = CellUtil.copyQualifierTo(cell, output, nextOffset);
 nextOffset = Bytes.putLong(output, nextOffset, cell.getTimestamp());
 nextOffset = Bytes.putByte(output, nextOffset, cell.getTypeByte());
 return nextOffset;
}

代码示例来源:origin: apache/hbase

tlen = tag.getValueLength();
pos = Bytes.putAsShort(b, pos, tlen + Tag.TYPE_LENGTH_SIZE);
pos = Bytes.putByte(b, pos, tag.getType());
if (tag.hasArray()) {
 pos = Bytes.putBytes(b, pos, tag.getValueArray(), tag.getValueOffset(), tlen);

代码示例来源:origin: apache/hbase

Bytes.putByte(newKey, rightKey.length - TYPE_SIZE, Type.Maximum.getCode());
return newKey;

代码示例来源:origin: org.apache.hbase/hbase-client

public static byte[] appendMetaData(byte[] id, byte[] data) {
 if (data == null || data.length == 0) {
  return data;
 }
 byte[] salt = Bytes.toBytes(ThreadLocalRandom.current().nextLong());
 int idLength = id.length + salt.length;
 byte[] newData = new byte[MAGIC_SIZE + ID_LENGTH_SIZE + idLength + data.length];
 int pos = 0;
 pos = Bytes.putByte(newData, pos, MAGIC);
 pos = Bytes.putInt(newData, pos, idLength);
 pos = Bytes.putBytes(newData, pos, id, 0, id.length);
 pos = Bytes.putBytes(newData, pos, salt, 0, salt.length);
 pos = Bytes.putBytes(newData, pos, data, 0, data.length);
 return newData;
}

代码示例来源:origin: apache/hbase

pos = Bytes.putShort(bytes, pos, (short)(rlength & 0x0000ffff));
pos += rlength;
pos = Bytes.putByte(bytes, pos, (byte)(flength & 0x0000ff));
pos += flength + qlength;
pos = Bytes.putLong(bytes, pos, timestamp);
pos = Bytes.putByte(bytes, pos, type.getCode());
pos += vlength;
if (tagsLength > 0) {

代码示例来源:origin: apache/hbase

/**
 * Put the header into the given byte array at the given offset.
 * @param onDiskSize size of the block on disk header + data + checksum
 * @param uncompressedSize size of the block after decompression (but
 *          before optional data block decoding) including header
 * @param onDiskDataSize size of the block on disk with header
 *        and data but not including the checksums
 */
private void putHeader(byte[] dest, int offset, int onDiskSize,
  int uncompressedSize, int onDiskDataSize) {
 offset = blockType.put(dest, offset);
 offset = Bytes.putInt(dest, offset, onDiskSize - HConstants.HFILEBLOCK_HEADER_SIZE);
 offset = Bytes.putInt(dest, offset, uncompressedSize - HConstants.HFILEBLOCK_HEADER_SIZE);
 offset = Bytes.putLong(dest, offset, prevOffset);
 offset = Bytes.putByte(dest, offset, fileContext.getChecksumType().getCode());
 offset = Bytes.putInt(dest, offset, fileContext.getBytesPerChecksum());
 Bytes.putInt(dest, offset, onDiskDataSize);
}

代码示例来源:origin: apache/hbase

pos = Bytes.putByte(backingArray, pos, (byte)elemLen);
IOUtils.readFully(cin, backingArray, pos, elemLen);
pos += elemLen;

代码示例来源:origin: apache/phoenix

@Override
 public int encodeByte(byte v, byte[] b, int o) {
  if (v < 0) {
   throw newIllegalDataException();
  }
  Bytes.putByte(b, o, v);
  return Bytes.SIZEOF_BYTE;
 }
}

代码示例来源:origin: forcedotcom/phoenix

@Override
 public int encodeByte(byte v, byte[] b, int o) {
  if (v < 0) {
   throw new IllegalDataException();
  }
  Bytes.putByte(b, o, v);
  return Bytes.SIZEOF_BYTE;
 }
}

代码示例来源:origin: apache/hbase

compression.getDictionary(CompressionContext.DictionaryIndex.FAMILY));
checkLength(elemLen, Byte.MAX_VALUE);
pos = Bytes.putByte(backingArray, pos, (byte)elemLen);
pos += elemLen;

代码示例来源:origin: apache/phoenix

private static void writeEndBytes(byte[] array, int newOffsetArrayPosition, int offsetArrayLength, int arrayLength,
    byte header, boolean useInt) {
  int byteSize = useInt ? Bytes.SIZEOF_INT : Bytes.SIZEOF_SHORT;
  Bytes.putInt(array, newOffsetArrayPosition + offsetArrayLength + byteSize, newOffsetArrayPosition);
  Bytes.putInt(array, newOffsetArrayPosition + offsetArrayLength + byteSize + Bytes.SIZEOF_INT, arrayLength);
  Bytes.putByte(array, newOffsetArrayPosition + offsetArrayLength + byteSize + 2 * Bytes.SIZEOF_INT, header);
}

代码示例来源:origin: apache/phoenix

Bytes.putInt(newArray, currentPosition, useShortNew ? arrayLength : -arrayLength);
currentPosition += Bytes.SIZEOF_INT;
Bytes.putByte(newArray, currentPosition, arrayBytes[offset + length - 1]);

相关文章

微信公众号

最新文章

更多