开发者学堂课程【分布式数据库 HBase 快速入门:取关用户】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/101/detail/1778
取关用户
/**
*1.用户关系表
*--删除操作者关注列族的待取关用户
*--删除待取关用户 fans 列族的操作者
*2.收件箱表
*--删除操作者的待取关用户的信息
*/
//取关用户
Public static void delAttend ( String uid , String -. uids ) throws IOException {
//获取连接
Connection connection = ConnectionFactory .createCornnection ( configuration );
//获取表对象
Table relaTable = connection . getTable ( TableNane . valueOf ( Constant . RELATIONS );
Table inboxTable connection . getTable ( TableName . valueOr ( Constant .INBOX);
//创建操作者的删除对象
Delete relaDel = new Delete ( Bytes . toBytes ( uid ));
ArrayList < Delete > deletes = new ArrayList< >();
for ( String s : uids ){
Delete fansDel = new Delete ( Bytes . toBytes ( s ));
fansDel . addColumns ( Bytes . toBytes ( s :" fans ").Bytes . toBytes ( uid ));
relaDel . addColumns ( Bytes . toBytes ( s :" attends ").Bytes . toBytes ( s ));
deletes.add(fansDel);
}
Deletes.add(reaDel);
//执行删除操作
relaTable . delete ( deletes );
//删除收件箱表相关内容
Delete inboxel = new Delete ( Bytes . toBytes ( uid ));
for ( String $: uids ){
inboxDel . addColunns ( Bytes , toBytes (:" info ").Bytes .toBytes ( s ));
}
// 执行收件箱表删除操作
inboxTable . delete (inboxDe1);
//关闭资源
inboxTable . close ();
relaTable .close();
connection . close();
}