• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

common-hbase: hbase操作工具类库

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

common-hbase

开源软件地址:

https://gitee.com/cnsugar/common-hbase

开源软件介绍:

common-hbase

介绍

hbase操作工具类库

测试示例

@Testpublic void testCreateTable() {    HBaseUtils.createTable("SUGAR_TEST");}@Testpublic void testPut() {    TestEntity entity = new TestEntity();    entity.setServiceId(10002L);    entity.setDataType(2);    entity.setOnTime(new Date());    entity.setServiceCode("A2000100010001");    entity.setRow("0266e33d15264525258891");    HBaseUtils.put(entity);}@Testpublic void testPutMap() {    Map<String, Object> map = new HashMap<>();    map.put("SERVICE_ID", 10003L);    map.put("DATA_TYPE", 2);    map.put("AT_TIME", null);    map.put("SERVICE_CODE", "A3000100010001");    map.put("ROW", "0266e33d15264525258892");    HBaseUtils.putMap(map, "SUGAR_TEST");}@Testpublic void testGet() {    TestEntity entity = HBaseUtils.get("0266e33d15264525258890", TestEntity.class);    System.out.println(entity);}@Testpublic void testGetMap() {    Map<String, Object> map = HBaseUtils.get("SUGAR_TEST", "0266e33d15264525258890", new IValueMapper() {        @Override        public Object mapValue(String column, byte[] value) {            if (value == null || value.length == 0) {                return null;            }            switch (column) {                case "AT_TIME":                    return new Date(Bytes.toLong(value));                case "DEST_PORT":                case "DATA_TYPE":                    return Bytes.toInt(value);                case "SERVICE_ID":                    return Bytes.toLong(value);                default:                    return Bytes.toString(value);            }        }    });    System.out.println(map);}@Testpublic void testScan() {    List<TestEntity> list = HBaseUtils.scan(new Scan(), TestEntity.class);    System.out.println(list);}@Testpublic void testScanMap() {    List<Map<String, Object>> list = HBaseUtils.scan("SUGAR_TEST", new Scan(), new IValueMapper() {        @Override        public Object mapValue(String column, byte[] value) {            if (value == null || value.length == 0) {                return null;            }            switch (column) {                case "AT_TIME":                    return new Date(Bytes.toLong(value));                case "DEST_PORT":                case "DATA_TYPE":                    return Bytes.toInt(value);                case "SERVICE_ID":                    return Bytes.toLong(value);                default:                    return Bytes.toString(value);            }        }    });    System.out.println(list);}`

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap