该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

介绍

hbase-api

注意的事项 windows 下使用需要先装 hadoop 的环境变量 windows 下的导入导出orc Parquet需要删除 hadoop目录下的 hadoop.dll

打包命令

mvn clean install package -Dmaven.test.skip=true

位置

maven坐标

    <artifactId>hbase-common</artifactId>
    <groupId>paas.storage</groupId>
    <version>1.0.0</version>

之后生成在 ./hbase-common/target/hbase-common.jar

使用

配置使用扩展参数传递 参考 IConnectionTest 类 expendParams参数

单元测试执行顺序

IConnectionTest  创建连接
ITableTest  操作表 
IDataTest 操作数据
IManagementTest 测试导入导出 需要把exportfile下文件放d盘
每个类里面有个all方法 执行就可以了

在liunx测试

打包text模块  
外部配置文件
jar包目录下放置test.json
jar包同目录 放置 text.csv

运行jar 输入日志到目录
nohup java -jar hbase-test.jar  >log.log & 启动

img.png

测试截图

5.2.1.1创建数据库连接(create)

img.png img.png

5.2.2.1创建表(create)

创建表参数

5.2.2.1创建表参数,database=database,table=test1,columnFamilyList=[{
		"Name": "user1",
		"Version": 5,
		"Compression": "SNAPPY",
		"TimeToLive": 5184000,
		"BlockCache": "True"
	}, {
		"Name": "userhouse1",
		"Version": 5,
		"Compression": "SNAPPY",
		"TimeToLive": 5184000,
		"BlockCache": "True"
	}

],numRegions2,splitMethodHexStringSplit,regionReplicatio1

5.2.2.1创建表(create)

img.png img.png

5.2.2.1创建表返回结果,"TableCreateResponse(super=Response(super=paas.storage.result.TableCreateResponse@6924e1a, taskStatus=1, errorCode=0, errorMsg=null), table=test1)"

5.2.2.2删除表(delete)

img.png img.png

5.2.2.2删除创建的表参数,参数database=database,table=test1
5.2.2.2删除表结果,{}TableDeleteResponse(super=Response(super=paas.storage.result.TableDeleteResponse@6924e39, taskStatus=1, errorCode=0, errorMsg=null), tableList=[test1])

5.2.2.3修改表(update)

img.png

5.2.2.3修改表参数,database=database,table=test1,columnFamilyList=[{
		"Name": "user",
		"Version": 3,
		"Compression": "SNAPPY",
		"TimeToLive": 5184000,
		"BlockCache": "True"
	}, {
		"Name": "userhouse",
		"Version": 3,
		"Compression": "SNAPPY",
		"TimeToLive": 4184000,
		"BlockCache": "True"
	}

],numRegions2,splitMethodHexStringSplit,regionReplicatio1

5.2.2.3更新表结果,TableUpdateResponse(super=Response(super=paas.storage.result.TableUpdateResponse@6924e1a, taskStatus=1, errorCode=0, errorMsg=null), table=test1)
idea测试

####hbaseweb控制台 img.png

5.2.2.4获取表列表(list)

5.2.2.4获取数据库下所有表列表参数,database = database,table=
5.2.2.4返回数据库下所有表列表,TableListResponse(super=Response(super=paas.storage.result.TableListResponse@26022b7a, taskStatus=1, errorCode=0, errorMsg=null), tableList=[database:test1])
5.2.2.4根据表名正则获取匹配表参数,database = database,table=test[0-9]*
5.2.2.4根据表名正则获取所有表列表,TableListResponse(super=Response(super=paas.storage.result.TableListResponse@26022b7a, taskStatus=1, errorCode=0, errorMsg=null), tableList=[database:test1])

img.png img.png

5.2.2.5表信息查询(query)

img.png img.png

5.2.2.5获取表信息参数,database = database,table=test1
5.2.2.4获取表信息返回结果,TableQueryResponse(tableInfo=[{"database:test1":[{"BlockCache":true,"Compression":"snappy","Name":"database:test1","TimeToLive":2147483647,"Version":3},{"$ref":"$[0].database:test1[0]"}]}])

5.2.2.6判断表是否存在(exist)

判断表是否存在参数,database = database,table=test
判断表是否存在,TableExistResponse(super=Response(super=paas.storage.result.TableExistResponse@3b, taskStatus=1, errorCode=0, errorMsg=null), result=0)

img.png img.png

5.2.3.1数据插入(insert)

这个地方的列簇参数 不是正确的json 沟通后改成正确的json格式
与数据修改接口字段保持一致
正确格式[{"row_key":value, "columnfamily":value, "column":value, "value":value_new}]

img.png img.png

5.2.3.1数据插入参数,ca13c291-801a-481c-bd7e-7afd23fa2d89,database,test1,[{
		"row_key": "1",
		"columnfamily": "user: username ",
		"value": "用户11"
	},
	{
		"row_key": "2",
		"columnfamily": "user: username ",
		"value": "用户22"
	},
	{
		"row_key": "3",
		"columnfamily": "user: username ",
		"value": "用户33"
	},
	{
		"row_key": "4",
		"columnfamily": "user: age ",
		"value": "20"
	},
	{
		"row_key": "5",
		"columnfamily": "user: age ",
		"value": "30"
	},
	{
		"row_key": "6",
		"columnfamily": "user: age ",
		"value": "40"
	},
	{
		"row_key": "7",
		"columnfamily": "user: age ",
		"value": "60"
	},
	{
		"row_key": "1",
		"columnfamily": "user: age ",
		"value": "1888"
	}
]
5.2.3.1插入结果,DataInsertResponse(super=Response(super=paas.storage.result.DataInsertResponse@1, taskStatus=1, errorCode=0, errorMsg=null))
5.2.3.1插入查询结果DataQueryResponse(super=Response(super=paas.storage.result.DataQueryResponse@4d4ec202, taskStatus=1, errorCode=0, errorMsg=null), result=[{"column":" age ","columnfamily":"user","row_key":"1","value":"1888","version":"1614322464309"},{"column":" username ","columnfamily":"user","row_key":"1","value":"用户11","version":"1614322464309"},{"column":" username ","columnfamily":"user","row_key":"2","value":"用户22","version":"1614322464309"},{"column":" username ","columnfamily":"user","row_key":"3","value":"用户33","version":"1614322464309"},{"column":" age ","columnfamily":"user","row_key":"4","value":"20","version":"1614322464309"},{"column":" age ","columnfamily":"user","row_key":"5","value":"30","version":"1614322464309"},{"column":" age ","columnfamily":"user","row_key":"6","value":"40","version":"1614322464309"},{"column":" age ","columnfamily":"user","row_key":"7","value":"60","version":"1614322464309"}]),

5.2.3.2数据删除(delete)

img.png img.png


5.2.3.2删除数据参数ca13c291-801a-481c-bd7e-7afd23fa2d89,database,test1,1,["user:username"],,
5.2.3.2删除结果Response(super=paas.storage.result.Response@33007, taskStatus=1, errorCode=0, errorMsg=null),
5.2.3.2删除查询结果DataQueryResponse(super=Response(super=paas.storage.result.DataQueryResponse@79e3c17c, taskStatus=1, errorCode=0, errorMsg=null), result=[{"column":"username","columnfamily":"user","row_key":"2","value":"张三","version":"1614322847853"}]),

5.2.3.3数据修改(update)

img.png img.png 更新数据rowkey2 的用户列=张三

5.2.3.3修改数据参数c5da89dc-1d89-4449-bbb4-543586087648,database,test1,1,[{
	"version": "1614323408221",
	"row_key": "2",
	"columnfamily": "user",
	"column": "username",
	"value": "张三"
}],,
5.2.3.3修改结果Response(super=paas.storage.result.Response@33007, taskStatus=1, errorCode=0, errorMsg=null),

5.2.3.4数据查询(query)

img.png img.png

数据查询参数78cc5a6d-82ad-4c30-b3de-de15231126f4,database,test1,{
	"MaxVersions": 2,
	"TimeRange": "[1609552608000,1614326605491]",
	"filter": {
		"SingleColumnValueFilter": {
			"family": "user",
			"qualifier": "age",
			"compareOp": "LESS_OR_EQUAL",
			"value": "50"
		}
	}
},2,,,["user:age"]
查询结果"[{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"4\",\"value\":\"20\",\"version\":\"1614326605126\"},{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"4\",\"value\":\"20\",\"version\":\"1614326497083\"},{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"5\",\"value\":\"30\",\"version\":\"1614326605126\"},{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"5\",\"value\":\"30\",\"version\":\"1614326497083\"},{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"6\",\"value\":\"40\",\"version\":\"1614326605126\"},{\"column\":\"age\",\"columnfamily\":\"user\",\"row_key\":\"6\",\"value\":\"40\",\"version\":\"1614326497083\"}]",

5.2.3.5基于键值的数据查询(queryByKey)

img.png img.png

根据rowkey查询数据参数78cc5a6d-82ad-4c30-b3de-de15231126f4,database,test1,2,,,
返回结果["DataQueryVo(row_key=2, columnfamily=user, column= username , value=用户22, info=null, version=1614325259848)","DataQueryVo(row_key=2, columnfamily=user, column=username, value=张三, info=null, version=1614326605197)"]

5.2.3.6范围查询(queryByRange)

img.png img.png

根据范围查询多过滤器参数faab3953-bc75-4a3d-8635-bd723d69a71a,database,test1, {
	"SingleColumnValueFilter": {
		"family": "user",
		"qualifier": "age",
		"compareOp": "GREATER_OR_EQUAL",
		"value": "30"
	},
	"FamilyFilter": {
		"familyCompareOp": "EQUAL",
		"familyComparator": "user"
	}
},

5.2.4.1数据导入(importData)

img.png img.png img.png

5.2.4.1数据导出(exportData)

img.png

从hbase 导入到hadoop img.png

空文件

简介

暂无描述 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化