Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
45e13e0b
提交
45e13e0b
authored
1月 10, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "remove STORE_LOCAL_TIME code" and change constant to parameter
This partially reverts commit
18602ef4
.
上级
8177350d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
72 行增加
和
19 行删除
+72
-19
Data.java
h2/src/main/org/h2/store/Data.java
+72
-19
没有找到文件。
h2/src/main/org/h2/store/Data.java
浏览文件 @
45e13e0b
...
...
@@ -114,9 +114,12 @@ public class Data {
*/
private
final
DataHandler
handler
;
private
Data
(
DataHandler
handler
,
byte
[]
data
)
{
private
final
boolean
storeLocalTime
;
private
Data
(
DataHandler
handler
,
byte
[]
data
,
boolean
storeLocalTime
)
{
this
.
handler
=
handler
;
this
.
data
=
data
;
this
.
storeLocalTime
=
storeLocalTime
;
}
/**
...
...
@@ -298,7 +301,7 @@ public class Data {
* @return the buffer
*/
public
static
Data
create
(
DataHandler
handler
,
int
capacity
)
{
return
new
Data
(
handler
,
new
byte
[
capacity
]);
return
new
Data
(
handler
,
new
byte
[
capacity
]
,
false
);
}
/**
...
...
@@ -310,7 +313,7 @@ public class Data {
* @return the buffer
*/
public
static
Data
create
(
DataHandler
handler
,
byte
[]
buff
)
{
return
new
Data
(
handler
,
buff
);
return
new
Data
(
handler
,
buff
,
false
);
}
/**
...
...
@@ -484,20 +487,48 @@ public class Data {
break
;
}
case
Value
.
TIME
:
writeByte
((
byte
)
type
);
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getTime
()));
if
(
storeLocalTime
)
{
writeByte
((
byte
)
LOCAL_TIME
);
ValueTime
t
=
(
ValueTime
)
v
;
long
nanos
=
t
.
getNanos
();
long
millis
=
nanos
/
1_000_000
;
nanos
-=
millis
*
1_000_000
;
writeVarLong
(
millis
);
writeVarLong
(
nanos
);
}
else
{
writeByte
((
byte
)
type
);
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getTime
()));
}
break
;
case
Value
.
DATE
:
{
writeByte
((
byte
)
type
);
long
x
=
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getDate
());
writeVarLong
(
x
/
MILLIS_PER_MINUTE
);
if
(
storeLocalTime
)
{
writeByte
((
byte
)
LOCAL_DATE
);
long
x
=
((
ValueDate
)
v
).
getDateValue
();
writeVarLong
(
x
);
}
else
{
writeByte
((
byte
)
type
);
long
x
=
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getDate
());
writeVarLong
(
x
/
MILLIS_PER_MINUTE
);
}
break
;
}
case
Value
.
TIMESTAMP
:
{
Timestamp
ts
=
v
.
getTimestamp
();
writeByte
((
byte
)
type
);
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeVarInt
(
ts
.
getNanos
()
%
1_000_000
);
if
(
storeLocalTime
)
{
writeByte
((
byte
)
LOCAL_TIMESTAMP
);
ValueTimestamp
ts
=
(
ValueTimestamp
)
v
;
long
dateValue
=
ts
.
getDateValue
();
writeVarLong
(
dateValue
);
long
nanos
=
ts
.
getTimeNanos
();
long
millis
=
nanos
/
1_000_000
;
nanos
-=
millis
*
1_000_000
;
writeVarLong
(
millis
);
writeVarLong
(
nanos
);
}
else
{
Timestamp
ts
=
v
.
getTimestamp
();
writeByte
((
byte
)
type
);
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeVarInt
(
ts
.
getNanos
()
%
1_000_000
);
}
break
;
}
case
Value
.
TIMESTAMP_TZ
:
{
...
...
@@ -702,8 +733,8 @@ public class Data {
}
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
}
assert
pos
-
start
==
getValueLen
(
v
,
handler
)
:
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
,
handler
);
assert
pos
-
start
==
getValueLen
(
v
)
:
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
);
}
/**
...
...
@@ -925,7 +956,7 @@ public class Data {
* @return the number of bytes required to store this value
*/
public
int
getValueLen
(
Value
v
)
{
return
getValueLen
(
v
,
handler
);
return
getValueLen
(
v
,
handler
,
storeLocalTime
);
}
/**
...
...
@@ -933,9 +964,12 @@ public class Data {
*
* @param v the value
* @param handler the data handler for lobs
* @param storeLocalTime
* calculate size of DATE, TIME, and TIMESTAMP values with local
* time storage format
* @return the number of bytes required to store this value
*/
public
static
int
getValueLen
(
Value
v
,
DataHandler
handler
)
{
public
static
int
getValueLen
(
Value
v
,
DataHandler
handler
,
boolean
storeLocalTime
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
return
1
;
}
...
...
@@ -1020,12 +1054,31 @@ public class Data {
return
1
+
getVarIntLen
(
scale
)
+
getVarIntLen
(
bytes
.
length
)
+
bytes
.
length
;
}
case
Value
.
TIME
:
if
(
storeLocalTime
)
{
long
nanos
=
((
ValueTime
)
v
).
getNanos
();
long
millis
=
nanos
/
1_000_000
;
nanos
-=
millis
*
1_000_000
;
return
1
+
getVarLongLen
(
millis
)
+
getVarLongLen
(
nanos
);
}
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getTime
()));
case
Value
.
DATE
:
{
if
(
storeLocalTime
)
{
long
dateValue
=
((
ValueDate
)
v
).
getDateValue
();
return
1
+
getVarLongLen
(
dateValue
);
}
long
x
=
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getDate
());
return
1
+
getVarLongLen
(
x
/
MILLIS_PER_MINUTE
);
}
case
Value
.
TIMESTAMP
:
{
if
(
storeLocalTime
)
{
ValueTimestamp
ts
=
(
ValueTimestamp
)
v
;
long
dateValue
=
ts
.
getDateValue
();
long
nanos
=
ts
.
getTimeNanos
();
long
millis
=
nanos
/
1_000_000
;
nanos
-=
millis
*
1_000_000
;
return
1
+
getVarLongLen
(
dateValue
)
+
getVarLongLen
(
millis
)
+
getVarLongLen
(
nanos
);
}
Timestamp
ts
=
v
.
getTimestamp
();
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
))
+
getVarIntLen
(
ts
.
getNanos
()
%
1_000_000
);
...
...
@@ -1096,7 +1149,7 @@ public class Data {
Value
[]
list
=
((
ValueCollectionBase
)
v
).
getList
();
int
len
=
1
+
getVarIntLen
(
list
.
length
);
for
(
Value
x
:
list
)
{
len
+=
getValueLen
(
x
,
handler
);
len
+=
getValueLen
(
x
,
handler
,
storeLocalTime
);
}
return
len
;
}
...
...
@@ -1118,7 +1171,7 @@ public class Data {
Value
[]
row
=
result
.
currentRow
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Value
val
=
row
[
i
];
len
+=
getValueLen
(
val
,
handler
);
len
+=
getValueLen
(
val
,
handler
,
storeLocalTime
);
}
}
len
++;
...
...
@@ -1360,7 +1413,7 @@ public class Data {
public
static
void
copyString
(
Reader
source
,
OutputStream
target
)
throws
IOException
{
char
[]
buff
=
new
char
[
Constants
.
IO_BUFFER_SIZE
];
Data
d
=
new
Data
(
null
,
new
byte
[
3
*
Constants
.
IO_BUFFER_SIZE
]);
Data
d
=
new
Data
(
null
,
new
byte
[
3
*
Constants
.
IO_BUFFER_SIZE
]
,
false
);
while
(
true
)
{
int
l
=
source
.
read
(
buff
);
if
(
l
<
0
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论