hbase中Bytes类的使用
来源:互联网 发布:日本对外贸易数据2015 编辑:程序博客网 时间:2024/06/03 22:42
import org.apache.hadoop.hbase.util.Bytes;
public class ArrayTest {public static void main(String[] args) { byte[]x=new byte[8]; x[0]=1; x[1]=2; x[2]=3; x[3]=4; x[4]=5; x[5]=4; x[6]=1; x[7]=127;// byte[] bs = Arrays.copyOfRange(x, from,2); Integer short1 = Bytes.toInt(x, 1,4);System.out.println("'''''''''''''''''''"+short1.byteValue());byte[] int2Byte = int2Byte(short1);for (byte b : int2Byte) { System.out.println("int"+b);}Short short2 = Bytes.toShort(x, 1, 2);// for (byte b : bs) {// System.out.println(b);// }System.out.println("short"+short2.shortValue());byte[] short2Byte = short2Byte(short2);for (byte b : short2Byte) { System.out.println(b);}}public static byte[] short2Byte(short a){ byte[] b = new byte[2]; b[0] = (byte) (a >> 8); b[1] = (byte) (a); return b; }public static byte[] int2Byte(int a) { byte[] b = new byte[4]; b[0] = (byte) (a >> 24); b[1] = (byte) (a >> 16); b[2] = (byte) (a >> 8); b[3] = (byte) (a); return b; } }
结果如下
”””””””””’5
int2
int3
int4
int5
short515
2
3
阅读全文
0 0
- hbase中Bytes类的使用
- HBase中Bytes.compare从90到92的变化
- Hbase中Filter的使用
- 源码:一个涉及MR、Bytes、Hbase的简单程序
- protobuf-lua-gen 中使用 bytes
- hbase中各种过滤器的使用
- Python3中 bytes/str的区别
- 虚拟币开发中使用的算法灯泡,比特(bits)与字节(bytes)
- oozie 中使用hbase
- HBase中Disruptor使用
- python3中,socket使用send函数时出现的错误:TypeError: a bytes-like object is required, not 'str'
- hbase的replication使用
- HBASE的shell使用
- hbase的replication使用
- hbase的coprocessor使用
- HBase缓存的使用
- hbase的使用心得
- HBase的JavaAPI使用
- JAVA解析XML文件
- idea2015 注册激活5种方式
- php中奖概率算法,可用于刮刮卡,大转盘等抽奖算法
- Sheet列号与数字之间的相互转换
- JMeterPlugin 插件安装后,不能跑起来异常 解析(jmeter 3.2)
- hbase中Bytes类的使用
- 解决JDK的安装路径中有空格的情况
- Jedis Object has already been returned to this pool or is invalid
- Caffe(CPU)-Ubuntu16.04下安装教程(未完成)
- php mysql数据库备份
- leetcode--Construct Binary Tree from Preorder and Inorder Traversal
- 蓝桥杯-兰顿蚂蚁(Java)
- poj 2777 Count Color(线段树区间更新+技巧)
- lintcode刷题——快速幂