Skip to content

Commit 4bbe751

Browse files
committed
update hbase, redis维表排版
1 parent 774da5c commit 4bbe751

File tree

2 files changed

+57
-53
lines changed

2 files changed

+57
-53
lines changed

docs/plugin/hbaseSide.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ CREATE TABLE sideTable (
8888
);
8989
```
9090

91+
## 6.hbase完整样例
92+
93+
### 数据说明
94+
95+
在hbase中,数据是以列簇的形式存储,其中rowKey作为主键,按字典排序。
96+
97+
在样例中,wtz为列族名,message, info为列名,数据在hbase中的存储情况为:
98+
```
99+
hbase(main):002:0> scan 'testFlinkStreamSql'
100+
ROW COLUMN+CELL
101+
0 column=wtz:info, timestamp=1587089266719, value=hadoop
102+
0 column=wtz:message, timestamp=1587089245780, value=hbase
103+
1 column=wtz:info, timestamp=1587088818432, value=flink
104+
1 column=wtz:message, timestamp=1587088796633, value=dtstack
105+
2 column=wtz:info, timestamp=1587088858564, value=sql
106+
2 column=wtz:message, timestamp=1587088840507, value=stream
107+
```
108+
91109
### hbase异步维表关联完整案例
92110
```
93111
CREATE TABLE MyTable(
@@ -150,18 +168,3 @@ into
150168
on a.id=b.rowkey;
151169
```
152170

153-
## 6.hbase中数据存储形式
154-
155-
在hbase中,数据是以列簇的形式存储,其中rowKey作为主键,按字典排序。
156-
157-
在样例中,wtz为列族名,message, info为列名,数据在hbase中的存储情况为:
158-
```
159-
hbase(main):002:0> scan 'testFlinkStreamSql'
160-
ROW COLUMN+CELL
161-
0 column=wtz:info, timestamp=1587089266719, value=hadoop
162-
0 column=wtz:message, timestamp=1587089245780, value=hbase
163-
1 column=wtz:info, timestamp=1587088818432, value=flink
164-
1 column=wtz:message, timestamp=1587088796633, value=dtstack
165-
2 column=wtz:info, timestamp=1587088858564, value=sql
166-
2 column=wtz:message, timestamp=1587088840507, value=stream
167-
```

docs/plugin/redisSide.md

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ CREATE TABLE MyRedis(
9393
partitionedJoin='false'
9494
);
9595
```
96+
97+
## 6.redis完整样例
98+
99+
### redis数据说明
100+
101+
redis使用散列类型 hash 数据结构,key=tableName_primaryKey1_primaryKey2,value={column1=value1, column2=value2}
102+
如果以班级class表为例,id和name作为联合主键,那么redis的结构为 <class_1_john ,{id=1, name=john, age=12}>
103+
104+
在样例中,tableName为sideTable,主键为id,column为id,message,所以对应的redis数据插入语句为<hset sideTable_5 id 5 message redis>
105+
106+
数据在redis中对应的数据存储情况为:
107+
```
108+
192.168.80.105:6379> hgetall sideTable_5
109+
1) "id"
110+
2) "5"
111+
3) "message"
112+
4) "redis"
113+
```
114+
96115
### redis异步维表关联完整案例
97116
```
98117
CREATE TABLE MyTable(
@@ -112,12 +131,12 @@ CREATE TABLE MyTable(
112131
);
113132
114133
CREATE TABLE MyRedis(
115-
id varchar,
116-
message varchar,
117-
PRIMARY KEY(id),
118-
PERIOD FOR SYSTEM_TIME
134+
id varchar,
135+
message varchar,
136+
PRIMARY KEY(id),
137+
PERIOD FOR SYSTEM_TIME
119138
)WITH(
120-
type='redis',
139+
type='redis',
121140
url='172.16.10.79:6379',
122141
password='abc123',
123142
database='0',
@@ -131,42 +150,24 @@ CREATE TABLE MyRedis(
131150
);
132151
133152
CREATE TABLE MyResult(
134-
id varchar,
135-
name varchar,
136-
address varchar,
137-
message varchar
153+
id varchar,
154+
name varchar,
155+
address varchar,
156+
message varchar
138157
)WITH(
139-
type = 'console'
158+
type = 'console'
140159
);
141160
142161
insert into MyResult
143-
select
144-
t1.id AS id,
145-
t1.name AS name,
146-
t1.address AS address,
147-
t2.message AS message
148-
from
149-
(
150-
select id, name, address
151-
from MyTable
152-
) t1 join MyRedis t2
153-
on t1.id = t2.id;
154-
```
155-
156-
## 6.redis的存储命名规则
157-
158-
redis使用散列类型 hash 数据结构,key=tableName_primaryKey1_primaryKey2,value={column1=value1, column2=value2}
159-
如果以班级class表为例,id和name作为联合主键,那么redis的结构为 <class_1_john ,{id=1, name=john, age=12}>
160-
161-
在样例中,tableName为sideTable,主键为id,column为id,message,所以对应的redis数据插入语句为<hset sideTable_5 id 5 message redis>
162-
163-
数据在redis中对应的数据存储情况为:
162+
select
163+
t1.id AS id,
164+
t1.name AS name,
165+
t1.address AS address,
166+
t2.message AS message
167+
from(
168+
select id, name, address
169+
from MyTable
170+
) t1 join MyRedis t2
171+
on t1.id = t2.id;
164172
```
165-
192.168.80.105:6379> hgetall sideTable_5
166-
1) "id"
167-
2) "5"
168-
3) "message"
169-
4) "redis"
170-
```
171-
172173

0 commit comments

Comments
 (0)