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

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

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

Bytes.unsignedCopyAndIncrement介绍

[英]Treat the byte[] as an unsigned series of bytes, most significant bits first. Start by adding 1 to the rightmost bit/byte and carry over all overflows to the more significant bits/bytes.
[中]将字节[]视为无符号的字节序列,首先是最高有效位。从最右边的位/字节加1开始,并将所有溢出带到更重要的位/字节。

代码示例

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

public void testUnsignedIncrement(){
 byte[] a = Bytes.toBytes(0);
 int a2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(a), 0);
 Assert.assertTrue(a2==1);
 byte[] b = Bytes.toBytes(-1);
 byte[] actual = Bytes.unsignedCopyAndIncrement(b);
 Assert.assertNotSame(b, actual);
 byte[] expected = new byte[]{1,0,0,0,0};
 Assert.assertArrayEquals(expected, actual);
 byte[] c = Bytes.toBytes(255);//should wrap to the next significant byte
 int c2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(c), 0);
 Assert.assertTrue(c2==256);
}

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

public void testUnsignedIncrement(){
 byte[] a = Bytes.toBytes(0);
 int a2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(a), 0);
 Assert.assertTrue(a2==1);
 byte[] b = Bytes.toBytes(-1);
 byte[] actual = Bytes.unsignedCopyAndIncrement(b);
 Assert.assertNotSame(b, actual);
 byte[] expected = new byte[]{1,0,0,0,0};
 Assert.assertArrayEquals(expected, actual);
 byte[] c = Bytes.toBytes(255);//should wrap to the next significant byte
 int c2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(c), 0);
 Assert.assertTrue(c2==256);
}

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

public void testUnsignedIncrement(){
 byte[] a = Bytes.toBytes(0);
 int a2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(a), 0);
 Assert.assertTrue(a2==1);
 byte[] b = Bytes.toBytes(-1);
 byte[] actual = Bytes.unsignedCopyAndIncrement(b);
 Assert.assertNotSame(b, actual);
 byte[] expected = new byte[]{1,0,0,0,0};
 Assert.assertArrayEquals(expected, actual);
 byte[] c = Bytes.toBytes(255);//should wrap to the next significant byte
 int c2 = Bytes.toInt(Bytes.unsignedCopyAndIncrement(c), 0);
 Assert.assertTrue(c2==256);
}

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

/**
 * Increment the row bytes and clear the other fields
 */
public static KeyValue createFirstKeyInIncrementedRow(final Cell in){
 byte[] thisRow = new SimpleMutableByteRange(in.getRowArray(), in.getRowOffset(),
   in.getRowLength()).deepCopyToNewArray();
 byte[] nextRow = Bytes.unsignedCopyAndIncrement(thisRow);
 return createFirstOnRow(nextRow);
}

相关文章

微信公众号

最新文章

更多