Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
39a87090
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39a87090
编写于
4月 11, 2018
作者:
M
Michael Benz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding UUID display transformer for optimized UUID data stored in binary(16) column. #3302
上级
6214dbc4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
103 addition
and
0 deletion
+103
-0
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+10
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/UUIDOrderedAttributeTransformer.java
...pl/data/transformers/UUIDOrderedAttributeTransformer.java
+93
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
39a87090
...
...
@@ -3363,6 +3363,16 @@
custom=
"true"
>
<type
kind=
"BINARY"
/>
<type
kind=
"CONTENT"
/>
</transformer>
<transformer
class=
"org.jkiss.dbeaver.model.impl.data.transformers.UUIDOrderedAttributeTransformer"
id=
"org.jkiss.dbeaver.core.UUIDOrderedAttributeTransformer"
name=
"UUID (Ordered)"
description=
"Represents binary(16) value as UUID if optimized storage is used."
applyByDefault=
"false"
custom=
"true"
>
<type
kind=
"BINARY"
/>
<type
kind=
"CONTENT"
/>
</transformer>
<transformer
class=
"org.jkiss.dbeaver.model.impl.data.transformers.BinaryAttributeTransformer"
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/data/transformers/UUIDOrderedAttributeTransformer.java
0 → 100644
浏览文件 @
39a87090
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.model.impl.data.transformers
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBPDataKind
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
import
org.jkiss.dbeaver.model.data.DBDAttributeTransformer
;
import
org.jkiss.dbeaver.model.data.DBDDisplayFormat
;
import
org.jkiss.dbeaver.model.data.DBDValueHandler
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
import
org.jkiss.dbeaver.model.impl.data.ProxyValueHandler
;
import
org.jkiss.dbeaver.model.impl.jdbc.data.JDBCContentBytes
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
/**
* Transforms binary(16) attribute value into UUID.
* <p>
* This specific UUID storage format saves space and improves INSERT performance as described in the linked article.
* </p>
*
* @see <a href="https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/">Store UUID in an optimized way</a>
*/
public
class
UUIDOrderedAttributeTransformer
implements
DBDAttributeTransformer
{
@Override
public
void
transformAttribute
(
@NotNull
DBCSession
session
,
@NotNull
DBDAttributeBinding
attribute
,
@NotNull
List
<
Object
[]>
rows
,
@NotNull
Map
<
String
,
String
>
options
)
throws
DBException
{
attribute
.
setPresentationAttribute
(
new
TransformerPresentationAttribute
(
attribute
,
"UUID (Ordered)"
,
16
,
DBPDataKind
.
BINARY
));
attribute
.
setTransformHandler
(
new
UUIDValueHandler
(
attribute
.
getValueHandler
()));
}
private
class
UUIDValueHandler
extends
ProxyValueHandler
{
public
UUIDValueHandler
(
DBDValueHandler
target
)
{
super
(
target
);
}
@NotNull
@Override
public
String
getValueDisplayString
(
@NotNull
DBSTypedObject
column
,
@Nullable
Object
value
,
@NotNull
DBDDisplayFormat
format
)
{
byte
[]
bytes
=
null
;
if
(
value
instanceof
byte
[])
{
bytes
=
(
byte
[])
value
;
}
else
if
(
value
instanceof
JDBCContentBytes
)
{
bytes
=
((
JDBCContentBytes
)
value
).
getRawValue
();
}
if
(
bytes
!=
null
)
{
// byte shift operations from Ebean ORM project pull request #1308
long
mostSigBits
=
((
long
)
bytes
[
4
]
<<
56
)
// XXXXXXXX-____-____-...
+
((
long
)(
bytes
[
5
]
&
255
)
<<
48
)
+
((
long
)(
bytes
[
6
]
&
255
)
<<
40
)
+
((
long
)(
bytes
[
7
]
&
255
)
<<
32
)
+
((
long
)(
bytes
[
2
]
&
255
)
<<
24
)
// ________-XXXX-____-...
+
((
bytes
[
3
]
&
255
)
<<
16
)
+
((
bytes
[
0
]
&
255
)
<<
8
)
// ________-____-XXXX-...
+
((
bytes
[
1
]
&
255
)
<<
0
);
long
leastSigBits
=
((
long
)
bytes
[
8
]
<<
56
)
// ________-____-____-XXXX-...
+
((
long
)(
bytes
[
9
]
&
255
)
<<
48
)
+
((
long
)(
bytes
[
10
]
&
255
)
<<
40
)
// ________-____-____-____-XXXXXXXXXXXX
+
((
long
)(
bytes
[
11
]
&
255
)
<<
32
)
+
((
long
)(
bytes
[
12
]
&
255
)
<<
24
)
+
((
bytes
[
13
]
&
255
)
<<
16
)
+
((
bytes
[
14
]
&
255
)
<<
8
)
+
((
bytes
[
15
]
&
255
)
<<
0
);
return
new
UUID
(
mostSigBits
,
leastSigBits
).
toString
();
}
return
super
.
getValueDisplayString
(
column
,
value
,
format
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录