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

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

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

Bytes.incrementBytes介绍

[英]Bytewise binary increment/deincrement of long contained in byte array on given amount.
[中]字节数组中包含的long在给定数量上的字节二进制增量/增量。

代码示例

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

private static boolean checkTestIncrementBytes(long val, long amount)
throws IOException {
 byte[] value = Bytes.toBytes(val);
 byte [] testValue = {-1, -1, -1, -1, -1, -1, -1, -1};
 if (value[0] > 0) {
  testValue = new byte[Bytes.SIZEOF_LONG];
 }
 System.arraycopy(value, 0, testValue, testValue.length - value.length,
   value.length);
 long incrementResult = Bytes.toLong(Bytes.incrementBytes(value, amount));
 return (Bytes.toLong(testValue) + amount) == incrementResult;
}

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

startRow = new byte[] { 0, 0, 0, 0, 1 };
byte[] row = Bytes.incrementBytes(startRow, counts[i % n]);
row = Arrays.copyOfRange(row, 3, 8); // use last 5 bytes because

代码示例来源:origin: NGDATA/lilyproject

/**
 * Get the next OCC (Optimistic Concurrency Control) value, or an initialized occ value if the current
 * value is null.
 *
 * The handling of null values is needed for working with repositories that were created before the OCC
 * was in place.
 *
 * @param occValue current occ value
 */
protected static byte[] nextOcc(byte[] occValue) {
  if (occValue == null) {
    return Bytes.toBytes(1L);
  }
  byte[] newOcc = new byte[occValue.length];
  System.arraycopy(occValue, 0, newOcc, 0, occValue.length);
  return Bytes.incrementBytes(newOcc, 1L);
}

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

private static boolean checkTestIncrementBytes(long val, long amount)
throws IOException {
 byte[] value = Bytes.toBytes(val);
 byte [] testValue = {-1, -1, -1, -1, -1, -1, -1, -1};
 if (value[0] > 0) {
  testValue = new byte[Bytes.SIZEOF_LONG];
 }
 System.arraycopy(value, 0, testValue, testValue.length - value.length,
   value.length);
 long incrementResult = Bytes.toLong(Bytes.incrementBytes(value, amount));
 return (Bytes.toLong(testValue) + amount) == incrementResult;
}

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

private static boolean checkTestIncrementBytes(long val, long amount)
throws IOException {
 byte[] value = Bytes.toBytes(val);
 byte [] testValue = {-1, -1, -1, -1, -1, -1, -1, -1};
 if (value[0] > 0) {
  testValue = new byte[Bytes.SIZEOF_LONG];
 }
 System.arraycopy(value, 0, testValue, testValue.length - value.length,
   value.length);
 long incrementResult = Bytes.toLong(Bytes.incrementBytes(value, amount));
 return (Bytes.toLong(testValue) + amount) == incrementResult;
}

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

startRow = new byte[] { 0, 0, 0, 0, 1 };
byte[] row = Bytes.incrementBytes(startRow, counts[i % n]);
row = Arrays.copyOfRange(row, 3, 8); // use last 5 bytes because

相关文章

微信公众号

最新文章

更多