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

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

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

Bytes.readAsInt介绍

[英]Converts a byte array to an int value
[中]将字节数组转换为int值

代码示例

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

private static int getLength(byte[] bytes, int offset) {
 return TAG_LENGTH_SIZE + Bytes.readAsInt(bytes, offset, TAG_LENGTH_SIZE);
}

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

/**
 * Creates list of tags from given byte array, expected that it is in the expected tag format.
 * @param b The byte array
 * @param offset The offset in array where tag bytes begin
 * @param length Total length of all tags bytes
 * @return List of tags
 */
public static List<Tag> asList(byte[] b, int offset, int length) {
 List<Tag> tags = new ArrayList<>();
 int pos = offset;
 while (pos < offset + length) {
  int tagLen = Bytes.readAsInt(b, pos, Tag.TAG_LENGTH_SIZE);
  tags.add(new ArrayBackedTag(b, pos, tagLen + Tag.TAG_LENGTH_SIZE));
  pos += Tag.TAG_LENGTH_SIZE + tagLen;
 }
 return tags;
}

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

/**
 * Compress tags one by one and writes to the OutputStream.
 * @param out Stream to which the compressed tags to be written
 * @param in Source where tags are available
 * @param offset Offset for the tags bytes
 * @param length Length of all tag bytes
 * @throws IOException
 */
public void compressTags(OutputStream out, byte[] in, int offset, int length)
  throws IOException {
 int pos = offset;
 int endOffset = pos + length;
 assert pos < endOffset;
 while (pos < endOffset) {
  int tagLen = Bytes.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
  pos += Tag.TAG_LENGTH_SIZE;
  Dictionary.write(out, in, pos, tagLen, tagDict);
  pos += tagLen;
 }
}

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

@Override
public Tag next() {
 if (hasNext()) {
  int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);
  Tag tag = new ArrayBackedTag(tags, pos, curTagLen + TAG_LENGTH_SIZE);
  this.pos += Bytes.SIZEOF_SHORT + curTagLen;
  return tag;
 }
 return null;
}

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

tagLen = Bytes.readAsInt(cell.getTagsArray(), pos, TAG_LENGTH_SIZE);
if (cell.getTagsArray()[pos + TAG_LENGTH_SIZE] == type) {
 return Optional

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

private static boolean isRowKeyOrderOptimized(boolean isFixedWidth, SortOrder sortOrder, byte[] buf, int offset, int length) {
  if (length == 0 || sortOrder == SortOrder.ASC || isFixedWidth) {
    return true;
  }
  int offsetToHeaderOffset = offset + length - Bytes.SIZEOF_BYTE - Bytes.SIZEOF_INT * 2;
  int offsetToSeparatorByte = Bytes.readAsInt(buf, offsetToHeaderOffset, Bytes.SIZEOF_INT) - 1;
  return buf[offsetToSeparatorByte] == QueryConstants.DESC_SEPARATOR_BYTE;
}

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

private static boolean isRowKeyOrderOptimized(boolean isFixedWidth, SortOrder sortOrder, byte[] buf, int offset, int length) {
  if (length == 0 || sortOrder == SortOrder.ASC || isFixedWidth) {
    return true;
  }
  int offsetToHeaderOffset = offset + length - Bytes.SIZEOF_BYTE - Bytes.SIZEOF_INT * 2;
  int offsetToSeparatorByte = Bytes.readAsInt(buf, offsetToHeaderOffset, Bytes.SIZEOF_INT) - 1;
  return buf[offsetToSeparatorByte] == QueryConstants.DESC_SEPARATOR_BYTE;
}

代码示例来源:origin: org.apache.phoenix/phoenix-core

private static boolean isRowKeyOrderOptimized(boolean isFixedWidth, SortOrder sortOrder, byte[] buf, int offset, int length) {
  if (length == 0 || sortOrder == SortOrder.ASC || isFixedWidth) {
    return true;
  }
  int offsetToHeaderOffset = offset + length - Bytes.SIZEOF_BYTE - Bytes.SIZEOF_INT * 2;
  int offsetToSeparatorByte = Bytes.readAsInt(buf, offsetToHeaderOffset, Bytes.SIZEOF_INT) - 1;
  return buf[offsetToSeparatorByte] == QueryConstants.DESC_SEPARATOR_BYTE;
}

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

private static int getLength(byte[] bytes, int offset) {
 return TAG_LENGTH_SIZE + Bytes.readAsInt(bytes, offset, TAG_LENGTH_SIZE);
}

代码示例来源:origin: harbby/presto-connectors

private static int getLength(byte[] bytes, int offset) {
 return TAG_LENGTH_SIZE + Bytes.readAsInt(bytes, offset, TAG_LENGTH_SIZE);
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

private static int getLength(byte[] bytes, int offset) {
 return TAG_LENGTH_SIZE + Bytes.readAsInt(bytes, offset, TAG_LENGTH_SIZE);
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

/**
 * Creates list of tags from given byte array, expected that it is in the expected tag format.
 * @param b The byte array
 * @param offset The offset in array where tag bytes begin
 * @param length Total length of all tags bytes
 * @return List of tags
 */
public static List<Tag> asList(byte[] b, int offset, int length) {
 List<Tag> tags = new ArrayList<>();
 int pos = offset;
 while (pos < offset + length) {
  int tagLen = Bytes.readAsInt(b, pos, Tag.TAG_LENGTH_SIZE);
  tags.add(new ArrayBackedTag(b, pos, tagLen + Tag.TAG_LENGTH_SIZE));
  pos += Tag.TAG_LENGTH_SIZE + tagLen;
 }
 return tags;
}

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

/**
 * Creates list of tags from given byte array, expected that it is in the expected tag format.
 * @param b The byte array
 * @param offset The offset in array where tag bytes begin
 * @param length Total length of all tags bytes
 * @return List of tags
 */
public static List<Tag> asList(byte[] b, int offset, int length) {
 List<Tag> tags = new ArrayList<>();
 int pos = offset;
 while (pos < offset + length) {
  int tagLen = Bytes.readAsInt(b, pos, Tag.TAG_LENGTH_SIZE);
  tags.add(new ArrayBackedTag(b, pos, tagLen + Tag.TAG_LENGTH_SIZE));
  pos += Tag.TAG_LENGTH_SIZE + tagLen;
 }
 return tags;
}

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

/**
 * Compress tags one by one and writes to the OutputStream.
 * @param out Stream to which the compressed tags to be written
 * @param in Source where tags are available
 * @param offset Offset for the tags bytes
 * @param length Length of all tag bytes
 * @throws IOException
 */
public void compressTags(OutputStream out, byte[] in, int offset, int length)
  throws IOException {
 int pos = offset;
 int endOffset = pos + length;
 assert pos < endOffset;
 while (pos < endOffset) {
  int tagLen = Bytes.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
  pos += Tag.TAG_LENGTH_SIZE;
  Dictionary.write(out, in, pos, tagLen, tagDict);
  pos += tagLen;
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

/**
 * Compress tags one by one and writes to the OutputStream.
 * @param out Stream to which the compressed tags to be written
 * @param in Source where tags are available
 * @param offset Offset for the tags bytes
 * @param length Length of all tag bytes
 * @throws IOException
 */
public void compressTags(OutputStream out, byte[] in, int offset, int length)
  throws IOException {
 int pos = offset;
 int endOffset = pos + length;
 assert pos < endOffset;
 while (pos < endOffset) {
  int tagLen = Bytes.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
  pos += Tag.TAG_LENGTH_SIZE;
  Dictionary.write(out, in, pos, tagLen, tagDict);
  pos += tagLen;
 }
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Creates the list of tags from the byte array b. Expected that b is in the
 * expected tag format
 * @param b
 * @param offset
 * @param length
 * @return List of tags
 */
public static List<Tag> asList(byte[] b, int offset, int length) {
 List<Tag> tags = new ArrayList<Tag>();
 int pos = offset;
 while (pos < offset + length) {
  int tagLen = Bytes.readAsInt(b, pos, TAG_LENGTH_SIZE);
  tags.add(new Tag(b, pos, tagLen + TAG_LENGTH_SIZE));
  pos += TAG_LENGTH_SIZE + tagLen;
 }
 return tags;
}

代码示例来源:origin: harbby/presto-connectors

/**
 * Compress tags one by one and writes to the OutputStream.
 * @param out Stream to which the compressed tags to be written
 * @param in Source where tags are available
 * @param offset Offset for the tags bytes
 * @param length Length of all tag bytes
 * @throws IOException
 */
public void compressTags(OutputStream out, byte[] in, int offset, int length)
  throws IOException {
 int pos = offset;
 int endOffset = pos + length;
 assert pos < endOffset;
 while (pos < endOffset) {
  int tagLen = Bytes.readAsInt(in, pos, Tag.TAG_LENGTH_SIZE);
  pos += Tag.TAG_LENGTH_SIZE;
  write(in, pos, tagLen, out);
  pos += tagLen;
 }
}

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

@Override
public Tag next() {
 if (hasNext()) {
  int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);
  Tag tag = new ArrayBackedTag(tags, pos, curTagLen + TAG_LENGTH_SIZE);
  this.pos += Bytes.SIZEOF_SHORT + curTagLen;
  return tag;
 }
 return null;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-common

@Override
public Tag next() {
 if (hasNext()) {
  int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);
  Tag tag = new ArrayBackedTag(tags, pos, curTagLen + TAG_LENGTH_SIZE);
  this.pos += Bytes.SIZEOF_SHORT + curTagLen;
  return tag;
 }
 return null;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public Tag next() {
 if (hasNext()) {
  int curTagLen = Bytes.readAsInt(tags, this.pos, Tag.TAG_LENGTH_SIZE);
  Tag tag = new Tag(tags, pos, curTagLen + Tag.TAG_LENGTH_SIZE);
  this.pos += Bytes.SIZEOF_SHORT + curTagLen;
  return tag;
 }
 return null;
}

相关文章

微信公众号

最新文章

更多