Serialization 如何在HBase列中存储基本数据类型和字符串,并使用序列化和反序列化检索它们?
如何在HBase列中存储基本数据类型和字符串并检索它们。通常,当我们想在HBase表中存储数据时,我们会按如下操作Serialization 如何在HBase列中存储基本数据类型和字符串,并使用序列化和反序列化检索它们?,serialization,hbase,deserialization,primitive-types,Serialization,Hbase,Deserialization,Primitive Types,如何在HBase列中存储基本数据类型和字符串并检索它们。通常,当我们想在HBase表中存储数据时,我们会按如下操作 Configuration conf = HBaseConfiguration.create(); HTable table = new HTable(conf, "people"); Put put = new Put(Bytes.toBytes("doe-john-m-12345")); put.add(Bytes.toBytes("personal"), Bytes.toBy
Configuration conf = HBaseConfiguration.create();
HTable table = new HTable(conf, "people");
Put put = new Put(Bytes.toBytes("doe-john-m-12345"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("givenName"), Bytes.toBytes("John"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("mi"), Bytes.toBytes("M"));
put.add(Bytes.toBytes("personal"), Bytes.toBytes("surame"), Bytes.toBytes("Doe"));
put.add(Bytes.toBytes("contactinfo"), Bytes.toBytes("email"), Bytes.toBytes("john.m.doe@gmail.com"));
table.put(put);
table.flushCommits();
table.close();
我的问题是如何在HBase中存储原始数据类型,包括字符串,以及如何使用序列化和派生来检索它们。我是HBase的新手,请给我一个明确的步骤来完成这项工作 看看我的答案
您可以在org.apache.hadoop.hbase.util
比如:
byte[] longBytes = Bytes.toBytes(2l);
long l = Bytes.toLong(longBytes);
System.out.println(l); // <-- this should give you 2l
byte[]longBytes=Bytes.toBytes(2l);
long l=字节。toLong(长字节);
系统输出打印LN(l)//