题记:

那一夜,就只专注着灌输

所以,那一天,就只干了这事儿

其它的,没做

累吗?

嗯啊

这大概就是,开心着跌爬滚打。。。

============================== 业 务 需 求 =============================

1. 微博内容的浏览,数据库表设计

2. 用户社交体现:关注用户,取关用户

3. 拉取关注的人的微博内容

============================= 实 现 思 路 =============================

1.  创建命名空间以及表名的定义

a.设置配置,定义常量表名
 
      b.初始化表与命名空间

c.创建微博命名空间

 2.  创建微博内容表

-------------------------------------------------------------------------------------------------------------
tableName(表名)  rowKey(行键)      ColumnFamily(列族):column(列名)    Value(值)

CONTENT_TABLE    uid_timestamp     info :blog                        content
--------------------------------------------------------------------------------------------------------------

 3.  创建微博用户关系表

------------------------------------------------------------------------------------------------------------------------------
tableName       rowkey    ColumnFamily_01:column     Value_01     ColumnFamily_02:column    Value_02

RELATION_TABLE  uid       attends :attend_uid         attend_uid      fans:fan_uid                         fan_uid
--------------------------------------------------------------------------------------------------------------------------------

 4.  创建微博用户收件箱表(消息提示表)

--------------------------------------------------------------------------------------------------------
tableName             rowKey      ColumnFamily:column   Value

RECEIVE_EMAIL_TABLE   uid     info : attend_uid       attend_rowkey(uid_timestamp)
----------------------------------------------------------------------------------------------------------

 5.  发布微博内容 ----> Put

a.在用户的微博内容表中添加数据(content)(需连接内容表操作)
 
      b.将发布微博内容用户的 rowkey(uid:uid_timestamp)发送到该用户粉丝的收件箱表中(需连接收件箱表操作)

 6.  添加关注用户 ----> Put

a.添加关注用户的 id 到 attends 中 (需连接关系表操作)
      
      b.在被关注用户的 列族fans中添加关注用户的 id (需连接关系表操作)

c.将被关注用户的微博内容表中的 "id: rowkey" 添加到关注用户的收件箱表中(需连接收件箱表操作)

 7.  取消(移除)关注用户 ----> Delete

a.在 attends 中删除被取关用户的 id  (需连接取关用户的关系表操作)
     
      b.在被取关用户的 fans 中删除取关当前用户id  (需连接被取关用户的关系表操作)

c.在当前取关用户的收件箱表中删除被取关用户的 id 和 rowkey(uid_timestamp) (需连接取关用户的收件箱表操作)

 8.  获取关注的人的微博内容 ---->Get

a.根据收件箱表获取发布微博用户的 rowkey(需连接收件箱表操作)

b.根据发布微博用户的 rowkey,从他的微博内容表中获取他发布的微博(uid,timestamp,content)(需连接内容表操作)

 9.  代码测试 
      a.发布微博内容

b.添加关注

c.取消关注

d.展示内容

=============================== 创 建 WeiBo 类 ============================

IDEA  scala  JAVA Hbase  API:

package WeiBo;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.PrefixFilter;
import org.apache.hadoop.hbase.util.Bytes;import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;public class WeiBo {// private Configuration conf = HBaseConfiguration.create();public static Configuration conf;static {conf = HBaseConfiguration.create(); //使用 HBaseConfiguration的单例方法获取配置confconf.set("hbase.zookeeper.quorum","192.168.15.14"); //设置访问hbase.zookeeper的ip地址conf.set("hbase.zookeeper.property.clientPort","2181"); //设置访问hbase.zookeeper的端口号}/*** 1.1 表名的定义*/private static final byte[] CONTENT_TABLE = Bytes.toBytes("weibo:content");  //定义微博内容表的表名private static final byte[] RELATION_TABLE = Bytes.toBytes("weibo:relation"); //定义用户关系表的表名private static final byte[] RECEIVE_EMAIL_TABLE = Bytes.toBytes("weibo:receive_email"); //定义收件箱表的表名/*** 1.2 初始化表与命名空间*/public void initTable(){init_namespace(); //创建微博业务命名空间content_table(); //创建内容表relation_table(); //创建用户关系表receive_email_table();  //创建收件箱表}/*** 1.3 创建微博命名空间 */public void init_namespace(){HBaseAdmin admin = null; //创建管理对象(在hbase中管理、访问表需要先创建HBaseAdmin对象),此时未使用try {admin = new HBaseAdmin(conf); //HBaseAdmin对象(实例化),通过连接hbase对数据库进行操作NamespaceDescriptor weibo = NamespaceDescriptor.create("weibo").addConfiguration("creator","Meng").addConfiguration("create_time", String.valueOf(System.currentTimeMillis())).build(); //创建命名空间描述器:名字,创建者,创建时间(感觉像是一本书的封面)admin.createNamespace(weibo); //创建命名空间} catch (IOException e) {e.printStackTrace();}finally {if(null != admin){try {admin.close(); //关闭连接} catch (IOException e) {e.printStackTrace();}}}}/*** 2.创建微博内容表* 表名:weibo:content  (CONTENT_TABLE)* 行键:uid_timestamp* 列族:info* 列名:blog* 值  :content*/private void content_table() {HBaseAdmin admin = null; //创建HBaseAdmin对象try {admin = new HBaseAdmin(conf);   //将HBaseAdmin对象实例化HTableDescriptor content_table_desc = new HTableDescriptor(TableName.valueOf(CONTENT_TABLE));//创建表描述:表属性对象,表名转字节HColumnDescriptor column_desc_info = new HColumnDescriptor(Bytes.toBytes("info")); //创建列描述:列族infocolumn_desc_info.setBlockCacheEnabled(true); //设置块缓存 column_desc_info.setBlocksize(2*1024*1024); //设置块缓存大小: 2M//column_desc_info.getCompressionType(Algorithm.SNAPPY); //设置压缩方式:SNAPPY//设置版本界限column_desc_info.setMaxVersions(1);column_desc_info.setMinVersions(1);content_table_desc.addFamily(column_desc_info); //将列描述添加到表描述中admin.createTable(content_table_desc); //根据对表的配置,创建表} catch (IOException e) {e.printStackTrace();}finally {if(null != admin){try {admin.close();} catch (IOException e) {e.printStackTrace();}}}}/*** 3.创建用户关系表* 表名:weibo:relation  (RELATION_TABLE)* 行键:uid* 列族:attends(关注) fans(粉丝)* 列名:attend_uid     fan_uid* 值  :attend_uid     fan_uid*/private void relation_table() {HBaseAdmin admin = null;  //创建HBaseAdmin对象try {admin = new HBaseAdmin(conf);  //将HBaseAdmin对象实例化HTableDescriptor relation_table_desc = new HTableDescriptor(TableName.valueOf(RELATION_TABLE));//创建表描述HColumnDescriptor column_desc_attends = new HColumnDescriptor(Bytes.toBytes("attends"));//创建列描述1:关注列族 attendscolumn_desc_attends.setBlockCacheEnabled(true); //设置块缓存(有效)column_desc_attends.setBlocksize(2*1024*1024); //设置块缓存大小: 2M//设置版本界限column_desc_attends.setMaxVersions(1);column_desc_attends.setMinVersions(1);relation_table_desc.addFamily(column_desc_attends); //将关注列族添加到表描述中HColumnDescriptor column_desc_fans = new HColumnDescriptor(Bytes.toBytes("fans"));  //创建列描述2:粉丝列族 fanscolumn_desc_fans.setBlockCacheEnabled(true); //设置块缓存 column_desc_fans.setBlocksize(2*1024*1024);//设置块缓存大小: 2M//设置版本界限column_desc_fans.setMaxVersions(1);column_desc_fans.setMinVersions(1);relation_table_desc.addFamily(column_desc_fans); //将粉丝列族添加到表描述中admin.createTable(relation_table_desc); //根据对表的配置,创建用户关系表} catch (IOException e) {e.printStackTrace();}finally {if(null != admin){try {admin.close();} catch (IOException e) {e.printStackTrace();}}}}/*** 4.创建微博收件箱表* 表名:RECEIVE_EMAIL_TABLE* 行键:uid* 列族:info* 列名:attend_id* 值  :attend_rowkey(uid_timestamp)*/private void receive_email_table() {HBaseAdmin admin = null;  //创建HBaseAdmin对象try {admin = new HBaseAdmin(conf);  //将HBaseAdmin对象实例化HTableDescriptor recceive_email_table_desc = new HTableDescriptor(TableName.valueOf(RECEIVE_EMAIL_TABLE));//创建表描述HColumnDescriptor column_desc_info = new HColumnDescriptor(Bytes.toBytes("info")); //创建列描述:列族 infocolumn_desc_info.setBlockCacheEnabled(true); //设置块缓存(有效)column_desc_info.setBlocksize(2*1024*1024); //设置块缓存大小: 2M//设置版本界限column_desc_info.setMaxVersions(1000);column_desc_info.setMinVersions(1000);recceive_email_table_desc.addFamily(column_desc_info); //将列族添加到表描述中admin.createTable(recceive_email_table_desc); //根据对表的配置,创建收件箱表} catch (IOException e) {e.printStackTrace();}finally {if(null != admin){try {admin.close();} catch (IOException e) {e.printStackTrace();}}}}/*** 5.发布微博内容* step 1:向内容表中添加数据* step 2:将发布内容的用户rowkey发送给被关注用户*/public void publish_content(String uid,String content){HConnection connection = null; //创建hbase连接try{connection = HConnectionManager.createConnection(conf); //连接实例化// step 1:向内容表中添加数据HTableInterface content_table_con = connection.getTable(TableName.valueOf(CONTENT_TABLE)); //通过连接实现对内容表的操作
//            HTable content_table_con = new HTable(conf,TableName.valueOf(CONTENT_TABLE)); //通过连接实现对内容表的操作(上面两句可用本句代替,更简洁)long timestamp = System.currentTimeMillis(); //获取当前时间戳String rowkey = uid + "_" + timestamp; //组装行键 RowKey(uid_timestamp)Put put = new Put(Bytes.toBytes(rowkey)); //根据组装好的rowkey,创建一个Put对象:putput.addColumn(Bytes.toBytes("info"),Bytes.toBytes("blog"),timestamp,Bytes.toBytes(content));//把发布的微博内容添加到put中,列族info,列名blog,内容contentcontent_table_con.put(put); //通过连接把要插入的数据添加到相应的用户微博内容表中// step 2:将发布微博的用户rowkey发送到他所有粉丝的收件箱表中//** 首先,从发布微博用户的关系表中获取发布微博用户的粉丝HTableInterface relation_table_con = connection.getTable(TableName.valueOf(RELATION_TABLE)); //通过连接实现对关系表的操作// HTable relation_table_con = new HTable(conf,TableName.valueOf(RELATION_TABLE));Get get = new Get(Bytes.toBytes(uid)); //根据发布微博用户id,创建一个Get对象:getget.addFamily(Bytes.toBytes("fans")); //通过指定发布微博用户的fans列族,获取该列族的所有列(uid-->fans:fan_uid)Result result = relation_table_con.get(get); //通过连接获取发布微博用户的所有粉丝信息 --> resultList<byte[]> fan_uids = new ArrayList<byte[]>(); //创建一个fan_uids列表,用来存储所有粉丝的id// 遍历获取发布微博用户的所有粉丝数据(fan_uid)for(Cell cell:result.rawCells()){ //rawCells()将result转换可遍历文件,获取单元格Qualifier信息fan_uids.add(CellUtil.cloneQualifier(cell)); //将fans列族中的列名fan_uid添加到fan_uids列表中}if(fan_uids.size()<=0)return; // 如果当前用户没有粉丝,则直接退出//** Then,在粉丝的收件箱表中插入发布微博用户的rowkeyHTableInterface receive_email_table_con = connection.getTable(TableName.valueOf(RECEIVE_EMAIL_TABLE)); //通过连接实现对收件箱表操作//HTable receive_email_table_con = new HTable(conf,TableName.valueOf(RECEIVE_EMAIL_TABLE));List<Put> puts = new ArrayList<Put>(); //创建一个Put对象:puts列表,用来存储所关注用户的id和rowkey// 遍历所有粉丝,将发布微博用户的id和rowkey存放在puts列表中for(byte[] fan_uid:fan_uids){Put fan_put = new Put(fan_uid); //通过fan_uid,创建一个put对象:fan_putfan_put.addColumn(Bytes.toBytes("info"),Bytes.toBytes(uid),timestamp,Bytes.toBytes(rowkey)); //将发布微博用户的id和rowkey添加到fan_put中puts.add(fan_put); // 将fan_put中的数据添加到puts列表中}receive_email_table_con.put(puts); // 通过连接向收件箱表放置数据 } catch (IOException e) {e.printStackTrace();}finally {if (null!=connection){try {connection.close(); // 关闭连接} catch (IOException e) {e.printStackTrace();}}}}/*** 6.关注用户* step 1:在该用户的 列族attends中添加关注用户的id(关注用户的关系表)* step 2:在被关注用户的 列族fans中添加该用户的id (被关注用户的关系表)* step 3:将被关注用户的微博内容表中的 "id: rowkey" 添加到该用户的收件箱表中*/public void add_attends(String uid,String... attend_uids){// 参数过滤:如果没有传递关注的人或没有关注的对象,则直接返回if(attend_uids == null || attend_uids.length <= 0|| uid == null || uid.length()<=0){return;}HConnection connection = null; //创建hbase连接try{//step 1:在该用户关系表中添加新关注用户//step 2:为被关注的用户添加粉丝(该用户)HTable relation_table_con = new HTable(conf,TableName.valueOf(RELATION_TABLE)); //通过连接实现对关系表操作List<Put> puts = new ArrayList<Put>(); //创建一个Put对象:puts列表,用来存储所关注用户的idPut attend_put = new Put(Bytes.toBytes(uid));//根据该用户id,创建一个Put对象:attend_put,用来存放所有attend_uidfor(String attend_uid:attend_uids){attend_put.addColumn(Bytes.toBytes("attends"),Bytes.toBytes(attend_uid),Bytes.toBytes(attend_uid));//逐一向该用户关系表中的attends列族中添加关注用户idPut fan_put = new Put(Bytes.toBytes(attend_uid)); //对每一个关注的用户,创建一个Put对象:fan_put,用来存放fan_uidfan_put.addColumn(Bytes.toBytes("fans"),Bytes.toBytes(uid),Bytes.toBytes(uid)); //向一个被关注用户关系表中的fans列族添加该用户的信息idputs.add(fan_put); //将被关注用户要增加的fans列族信息添加到puts列表中}puts.add(attend_put); //将该用户要增加的attends列族信息添加到puts列表中relation_table_con.put(puts); //通过连接操作将要增加的信息添加到相应的用户关系表中//step 3:将关注用户的id和rowkey添加到当前用户的收件箱表中//3-1:获取所有新关注用户发布微博内容表的rowkeyHTable content_table_con = new HTable(conf,TableName.valueOf(CONTENT_TABLE)); //通过连接实现对发布微博内容表操作Scan scan = new Scan(); //创建Scan对象:scanList<byte[]> rowkeys = new ArrayList<byte[]>(); //创建一个列表:rowkeys,用来存放所关注用户微博内容表的rowkey//遍历所有新关注用户,将他们的rowkey存放到rowkeys列表中for(String attend_uid:attend_uids){PrefixFilter filter = new PrefixFilter(attend_uid.getBytes()); //根据每一个新关注用户的id,创建一个过滤器scan.setFilter(filter); //过滤扫描获取每一个新关注用户的发布微博内容表信息ResultScanner result = content_table_con.getScanner(scan); //将获取的新关注用户的内容表信息存放到result中Iterator<Result> iterator = result.iterator(); //迭代器遍历扫描出来的结果集while(iterator.hasNext()){Result r = iterator.next(); //取出符合扫描结果的一行数据//逐一将新关注用户的rowkey添加到rowkeys列表中for(Cell cell:r.rawCells()){ rowkeys.add(CellUtil.cloneRow(cell));}}}if(rowkeys.size()<=0)return; //如果新关注用户没有发表微博内容,则直接退出//3-2:将获取的rowkeys列表信息添加到当前用户的收件箱表中HTable receive_email_table_con = new HTable(conf,TableName.valueOf(RECEIVE_EMAIL_TABLE)); //通过连接实现对邮件箱表操作Put rowkeys_put = new Put(Bytes.toBytes(uid)); //创建Put对象:rowkey_puts,用来存放新关注用户发布微博内容的信息(attend_uid rowkey)for(byte[] rk:rowkeys){String rowkey = Bytes.toString(rk);//将字节rowkey转字符String attend_uid = rowkey.substring(0,rowkey.indexOf("_")); //截取新关注用户的rowkey字符串,获得关注用户idlong timestamp = Long.parseLong(rowkey.substring(rowkey.indexOf("_")+1)); //获得新关注用户发布内容时间戳rowkeys_put.addColumn(Bytes.toBytes("info"),Bytes.toBytes(attend_uid),timestamp,rk); //将新关注用户的id,timestamp,rowkey添加到rowkeys_put中}receive_email_table_con.put(rowkeys_put); //通过连接操作把新关注用户的相关信息添加到当前用户的收件箱表} catch (Exception e) {e.printStackTrace();}finally {if(null!=connection){try {connection.close();} catch (IOException e) {e.printStackTrace();}}}}/*** 7.取消关注* step 1:在该用户关系表的列族attends中删除要取消关注的用户id(关注用户的关系表)* step 2:在被关注用户关系表的列族fans中删除该用户id (被关注用户的关系表)* step 3:从该用户的收件箱表删除取消关注用户的"id: rowkey"*/public void remove_attends(String uid, String... attend_uids){HConnection connection = null; //创建连接//step 1:在该用户关系表的列族attends中删除要取消关注的用户id(关注用户的关系表)//step 2:在被关注用户关系表的列族fans中删除该用户id (被关注用户的关系表)"try{HTable relation_table_con = new HTable(conf,TableName.valueOf(RELATION_TABLE)); //通过连接实现对关系表操作List<Delete> deletes = new ArrayList<Delete>(); //创建一个列表deletes,用来存放被取消关注用户的idDelete attend_delete = new Delete(Bytes.toBytes(uid)); //根据当前用户ID,创建Delete对象,存储被取关用户的idfor(String attend_uid:attend_uids){attend_delete.addColumn(Bytes.toBytes("attends"),Bytes.toBytes(attend_uid)); //将取关用户的数据添加到删除对象attend_delete中Delete fan_delete = new Delete(Bytes.toBytes(attend_uid)); //根据被取关用户id,创建Delete对象,存储当前用户的idfan_delete.addColumn(Bytes.toBytes("fans"),Bytes.toBytes(uid)); //从被取关用户的关系表中获取当前用户的数据,添加到删除fan_deletedeletes.add(fan_delete); //将被取关用户要删除的数据添加到删除列表deletes中}deletes.add(attend_delete); //将当前用户要删除的数据添加到删除列表deletes中relation_table_con.delete(deletes); //通过连接,从取关用户和被取关用户的关系表中删除相应的数据//step 3:从当前用户的收件箱表删除被取关用户的"id: rowkey"(连接收件箱表)HTable receive_email_table_desc = new HTable(conf,TableName.valueOf(RECEIVE_EMAIL_TABLE)); //通过连接实现对收件箱表操作Delete receive_deletes = new Delete(Bytes.toBytes(uid)); //根据当前用户id,创建删除对象receive_delete,用来存放被取关用户的id和rowkey//遍历被取关用户id,将他们发布微博的相关数据添加到删除对象receive_deletefor(String attend_uid:attend_uids){receive_deletes.addColumn(Bytes.toBytes("info"),Bytes.toBytes(attend_uid)); //从当前用户收件箱表中删除被取关用户的发布微博数据}receive_email_table_desc.delete(receive_deletes); //通过连接从当前用户收件箱中删除取关用户发布微博的信息} catch (Exception e) {e.printStackTrace();}finally {if(null!=connection){try {connection.close();} catch (IOException e) {e.printStackTrace();}}}}/*** 8.获取关注的人的微博内容* step 1:根据收件箱表获取关注用户的rowkey{}* step 2:根据关注用户的id在他的微博内容表中获取他发布的微博内容--->List<Message>*/public List<Message> get_attends_contents(String uid) {HConnection connection = null; //创建连接,未使用try {//step 1:根据收件箱表获取关注用户发布微博的rowkey ---->GetHTable receive_email_table_con = new HTable(conf, TableName.valueOf(RECEIVE_EMAIL_TABLE)); //通过连接实现对收件箱表的操作Get get = new Get(Bytes.toBytes(uid)); //创建get对象,用来获取当前用户邮件箱表的数据Result result = receive_email_table_con.get(get); //从用户的邮件箱表中获取所有数据List<byte[]> rowkeys = new ArrayList<byte[]>(); //创建一个列表,用来存放关注用户发布微博的rowkey//遍历邮件箱中的单元格,将发布微博用户的rowkey添加到rowkeys 列表中for (Cell cell : result.rawCells()) {rowkeys.add(CellUtil.cloneValue(cell));}//step 2:根据关注用户发布微博的rowkey从他的微博内容表中获取具体的微博内容---->GetHTable content_table_con = new HTable(conf, TableName.valueOf(CONTENT_TABLE)); //通过连接实现对发布微博内容表的操作List<Get> gets = new ArrayList<Get>(); //创建Get对象,用来存放关注用户发布的微博内容for (byte[] rowkey : rowkeys) {Get row_get = new Get(rowkey); //根据每个发布微博的rowkey创建Get对象gets.add(row_get); //将rowkey_get添加到get列表}//step 3:将获得的内容整理到Message列表中Result[] results = content_table_con.get(gets); //通过连接获取gets列表中的rowkeys及每个rowkey所对应的微博内容,并存放于resultsList<Message> blog_contents = new ArrayList<Message>(); //创建Message列表,存储发布微博用户的数据:id,timestamp,contentfor (Result rs : results) {//遍历结果列表中每行数据的单元格,将发布微博用户的id,timestamp,content存储到blog_contents列表for (Cell cell : rs.rawCells()) {Message blog = new Message(); //对每一个发布微博用户的rowkey,创建一个Message对象,存放发布微博的数据String rowkey = Bytes.toString(CellUtil.cloneRow(cell)); //获取行键String blog_uid = rowkey.substring(0, rowkey.indexOf("_")); //获取发布微博用户的idString blog_timestamp = rowkey.substring(rowkey.indexOf("_") + 1); //获取发布微博的时间戳String blog_content = Bytes.toString(CellUtil.cloneValue(cell)); //获取发布的微博内容blog.setUid(blog_uid); //设置blog_content的用户ID为:blog_uidblog.setTimestamp(blog_timestamp); //设置blog_content的时间戳为:timestampblog.setContent(blog_content); //设置blog_content的内容为:contentblog_contents.add(blog); //将组装好的blog_content添加到Message列表blog_contents中}}return blog_contents; //返回Message列表,即可查看关注的用户发布的微博内容} catch (IOException ex) {ex.printStackTrace();} finally {if (null != connection) {try {connection.close(); // 关闭连接} catch (IOException e) {e.printStackTrace();}}}return null;}/*** 9.代码测试* a.发布微博内容* b.添加关注* c.取消关注* d.展示内容*///a.发布微博内容public void test_publish_content(WeiBo wb){wb.publish_content("0001","【声明】因工作调整,中国国际广播电台英语新闻直播节目The Beijing Hour官方微博自2018年6月16日起停止一切内容更新,包括每日节目预告,由衷感谢您多年的陪伴与支持。");wb.publish_content("0001","随时随地发现新鲜事!微博带你欣赏世界上每一个精彩瞬间,了解每一个幕后故事。分享你想表达的,让全世界都能听到你的心声!");}//b.添加关注public void test_add_attends(WeiBo wb){wb.publish_content("0003","人生最美是清欢");wb.publish_content("0007","Alawys believe that something wonderful is about to happen...");wb.publish_content("0009","人生有很多岔路口,不过是,你拐弯我直走。。。");wb.add_attends("0001","0003","0007","0009");}//c.取消关注public void test_remove_attends(WeiBo wb){wb.remove_attends("0001","0003");}//d.展示内容public void test_show_messages(WeiBo wb){List<Message> messages = wb.get_attends_contents("0001");for(Message message:messages){System.out.println(message);}}public static void main(String[] args){WeiBo weibo = new WeiBo();weibo.initTable();weibo.test_publish_content(weibo);weibo.test_add_attends(weibo);weibo.test_remove_attends(weibo);weibo.test_show_messages(weibo);}}

执行时出现的小插曲:

由于我在写代码时漏掉了一点儿,如

List<Get> gets = new ArrayList<>();   —— 后面<>里面忘记写 Get

List<byte[]> fan_uids = new ArrayList<>();  ——    后面<>里面忘记写 byte[]

List<Put> puts = new ArrayList<>();   ——后面<>里面忘记写  Put

。。。。。。

结果就显示以这句话开始的几句错误信息:

Exception in thread "main" java.lang.NullPointerException at org.apache.hado

通过搜查很多人反应是某个地方出现空值,于是仔细看了一遍代码终于发现漏洞,补上它们:

List<Get> gets = new ArrayList<Get>();

List<byte[]> fan_uids = new ArrayList<byte[]>();

List<Put> puts = new ArrayList<Put>();

。。。。。。

结果就完美地运行出来啦!

========================= 部 分 展 示 ============================

hbase(main):002:0> list

=> ["fruit", "student", "weibo:content", "weibo:receive_email", "weibo:relation"]

hbase(main):005:0> scan "weibo:relation"
ROW                          COLUMN+CELL                                                                       
 0001                        column=attends:0007, timestamp=1569227889548, value=0007                          
 0001                        column=attends:0009, timestamp=1569227889548, value=0009                          
 0007                        column=fans:0001, timestamp=1569227889548, value=0001                             
 0009                        column=fans:0001, timestamp=1569227889548, value=0001

Message[uid=0007,timestamp=1569227888527,content=Alawys believe that something wonderful is about to happen...]
Message[uid=0009,timestamp=1569227888638,content=人生有很多岔路口,不过是,你拐弯我直走。。。]

HBase 项目:微博业务需求相关推荐

  1. Cris 小哥哥的大数据项目之 HBase 模拟微博核心功能

    Cris 小哥哥的大数据项目之 HBase 模拟微博核心功能 Author:Cris 文章目录 Cris 小哥哥的大数据项目之 HBase 模拟微博核心功能 Author:Cris 0. 序 1. 需 ...

  2. 基于EasyNVR二次开发实现业务需求:直接集成EasyNVR播放页面到自身项目

    EasyNVR着重点是立足于视频能力层,但是自身也是可以作为一个产品使用的.这就更加方便了应用层的使用. 由于业务需求的缘故,无法使用实体项目展示. 案例描述 该业务系统是国内某大型显示屏生产企业内部 ...

  3. TOGAF:从业务架构到业务需求

    本文内容更新版本已转至  http://www.zhoujingen.cn/blog/3695.html -------------------------- 做管理型软件产品一般都要经历架构阶段,而 ...

  4. 软件需求包括3个不同的层次 - 业务需求、用户需求和功能需求

    首先有用户需求,然后由组织将用户需求转化为业务需求,再由开发者将业务需求转化为功能需求,功能需求映射到系统功能模块.业务需求也有可能是基于的业务发展需要,由组织首先提出来的. 业务需求(Busines ...

  5. 基于EasyNVR二次开发实现业务需求:用户、权限、设备管理

    许多接触到EasyNVR的用户.开发者都会提出关于EasyNVR设备分组和账户设备关系映射的问题,我们参考目前大部分的视频能力输出平台的做法,EasyNVR目前只做了唯一的用户/密码(类比appkey ...

  6. 我眼中BA(业务需求分析师)的技能广度和深度

    BA,或者称业务分析师,是企业数字能力和业务能力之间的沟通桥梁.随着企业数字转型的进一步深化,相信对BA这样的技能需求会越来越多,只是未必都用"BA/业务分析师"这样的Title. ...

  7. IT运维管理为重,从业务需求看网管系统的选择

    From [url]http://zhangzj.blog.51cto.com[/url] IT运维管理为重,从业务需求看网管系统的选择 2006-11-06 17:47:42 <?xml:na ...

  8. 【案例实战】餐饮企业分店财务数据分析系统解决方案:业务需求

    [案例实战]餐饮企业分店财务数据分析系统解决方案:业务需求 一.建设目的 某餐饮集团需要将每个分店的财务状况进行分析,目前使用的是excel来存储查看各区域的收入情况,每个区域各年月的收入情况汇总数据 ...

  9. spring boot / cloud (二十) 相同服务,发布不同版本,支撑并行的业务需求

    有半年多没有更新了,按照常规剧本,应该会说项目很忙,工作很忙,没空更新,吧啦吧啦,相关的话吧, 但是细想想,是真的么?,忙到这几个字都没时间打么?毕竟大家都很忙的,所以忙并不是啥理由. 那是因为啥呢? ...

最新文章

  1. Dojo QuickStart 快速入门教程 (1) Why Dojo
  2. 【技巧——windows】直接登陆到桌面,免去输入密码
  3. poj1273(最大网络流问题模版)
  4. 对比直立车模控制中的互补滤波、Karlman滤波和参考滤波方案
  5. 读《大道至简——失败的过程也是过程》有感
  6. 怎么看linux电脑是不是双核,Linux系统如何判断CPU是双核还是单核
  7. 8 使用SubMenu创建子菜单
  8. FD.io VPP用户文档:会话层架构与VPP应用
  9. Markdown编辑器:好看的字体颜色和各种表情符号
  10. 公司、办公司内如何限制上外网因特网、只能连内网局域网 - 注册表工具软件、批处理办法 - 注册表转换成批处理BAT,批处理如何修改注册表
  11. linux(ubuntu)系统什么叫:桌面管理器,窗口管理器?
  12. Python 爬虫:抓取豆瓣top250电影数据
  13. python怎么取共轭_python实现共轭梯度法
  14. vmware win7虚拟机运行异常卡顿问题解决
  15. 爬虫实战-链家北京房租数据
  16. 混合高斯模型(matlab)
  17. troubleshooting之解决YARN队列资源不足导致的application直接失败
  18. 倒计时1天!亮点抢先看,2022京东云产业融合新品发布会
  19. Vscode下载与配置(C语言)
  20. 操作系统与网络实现 之十八(丁)

热门文章

  1. 机器人10大流行编程语言
  2. 全球通讯录转换outl联系人
  3. 基于Google Earth Engine Explorer谷歌地球引擎GEE浏览界面实现遥感影像地物监督分类
  4. ESP32开发(1)----Espressif-IDE开发环境配置
  5. 刷脸支付享受便捷的同时兼顾安全
  6. JAVA 设计模式(全)
  7. t420i升级固态硬盘提升_给电脑升级那些事,加一块希捷酷鱼120固态硬盘很畅快...
  8. JS实现HTML实体与字符的相互转换(一)
  9. [Swift5]自定义UITableViewCell左滑操作,适配iOS11 ~ iOS13
  10. 2015年个人收获-成果、经验分享(项目经理、集成资质、网站开发、服务器等)