Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d5d927d2
提交
d5d927d2
authored
12月 20, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ValueCollectionBase as base class for ValueArray and ValueRow
上级
245aa770
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
68 行增加
和
93 行删除
+68
-93
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+2
-46
ValueCollectionBase.java
h2/src/main/org/h2/value/ValueCollectionBase.java
+64
-0
ValueRow.java
h2/src/main/org/h2/value/ValueRow.java
+2
-47
没有找到文件。
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
d5d927d2
...
@@ -10,14 +10,12 @@ import java.sql.PreparedStatement;
...
@@ -10,14 +10,12 @@ import java.sql.PreparedStatement;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.MathUtils
;
/**
/**
* Implementation of the ARRAY data type.
* Implementation of the ARRAY data type.
*/
*/
public
class
ValueArray
extends
Value
{
public
class
ValueArray
extends
Value
CollectionBase
{
/**
/**
* Empty array.
* Empty array.
...
@@ -25,12 +23,10 @@ public class ValueArray extends Value {
...
@@ -25,12 +23,10 @@ public class ValueArray extends Value {
private
static
final
Object
EMPTY
=
get
(
new
Value
[
0
]);
private
static
final
Object
EMPTY
=
get
(
new
Value
[
0
]);
private
final
Class
<?>
componentType
;
private
final
Class
<?>
componentType
;
private
final
Value
[]
values
;
private
int
hash
;
private
ValueArray
(
Class
<?>
componentType
,
Value
[]
list
)
{
private
ValueArray
(
Class
<?>
componentType
,
Value
[]
list
)
{
super
(
list
);
this
.
componentType
=
componentType
;
this
.
componentType
=
componentType
;
this
.
values
=
list
;
}
}
/**
/**
...
@@ -65,19 +61,6 @@ public class ValueArray extends Value {
...
@@ -65,19 +61,6 @@ public class ValueArray extends Value {
return
(
ValueArray
)
EMPTY
;
return
(
ValueArray
)
EMPTY
;
}
}
@Override
public
int
hashCode
()
{
if
(
hash
!=
0
)
{
return
hash
;
}
int
h
=
1
;
for
(
Value
v
:
values
)
{
h
=
h
*
31
+
v
.
hashCode
();
}
hash
=
h
;
return
h
;
}
public
Value
[]
getList
()
{
public
Value
[]
getList
()
{
return
values
;
return
values
;
}
}
...
@@ -91,15 +74,6 @@ public class ValueArray extends Value {
...
@@ -91,15 +74,6 @@ public class ValueArray extends Value {
return
componentType
;
return
componentType
;
}
}
@Override
public
long
getPrecision
()
{
long
p
=
0
;
for
(
Value
v
:
values
)
{
p
+=
v
.
getPrecision
();
}
return
p
;
}
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
StringBuilder
builder
=
new
StringBuilder
().
append
(
'['
);
StringBuilder
builder
=
new
StringBuilder
().
append
(
'['
);
...
@@ -181,15 +155,6 @@ public class ValueArray extends Value {
...
@@ -181,15 +155,6 @@ public class ValueArray extends Value {
return
builder
.
append
(
']'
).
toString
();
return
builder
.
append
(
']'
).
toString
();
}
}
@Override
public
int
getDisplaySize
()
{
long
size
=
0
;
for
(
Value
v
:
values
)
{
size
+=
v
.
getDisplaySize
();
}
return
MathUtils
.
convertLongToInt
(
size
);
}
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
ValueArray
))
{
if
(!(
other
instanceof
ValueArray
))
{
...
@@ -211,15 +176,6 @@ public class ValueArray extends Value {
...
@@ -211,15 +176,6 @@ public class ValueArray extends Value {
return
true
;
return
true
;
}
}
@Override
public
int
getMemory
()
{
int
memory
=
32
;
for
(
Value
v
:
values
)
{
memory
+=
v
.
getMemory
()
+
Constants
.
MEMORY_POINTER
;
}
return
memory
;
}
@Override
@Override
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
if
(!
force
)
{
if
(!
force
)
{
...
...
h2/src/main/org/h2/value/ValueCollectionBase.java
0 → 100644
浏览文件 @
d5d927d2
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
value
;
import
org.h2.engine.Constants
;
import
org.h2.util.MathUtils
;
/**
* Base class for collection values.
*/
abstract
class
ValueCollectionBase
extends
Value
{
final
Value
[]
values
;
private
int
hash
;
ValueCollectionBase
(
Value
[]
values
)
{
this
.
values
=
values
;
}
@Override
public
int
hashCode
()
{
if
(
hash
!=
0
)
{
return
hash
;
}
int
h
=
getType
();
for
(
Value
v
:
values
)
{
h
=
h
*
31
+
v
.
hashCode
();
}
hash
=
h
;
return
h
;
}
@Override
public
long
getPrecision
()
{
long
p
=
0
;
for
(
Value
v
:
values
)
{
p
+=
v
.
getPrecision
();
}
return
p
;
}
@Override
public
int
getDisplaySize
()
{
long
size
=
0
;
for
(
Value
v
:
values
)
{
size
+=
v
.
getDisplaySize
();
}
return
MathUtils
.
convertLongToInt
(
size
);
}
@Override
public
int
getMemory
()
{
int
memory
=
32
;
for
(
Value
v
:
values
)
{
memory
+=
v
.
getMemory
()
+
Constants
.
MEMORY_POINTER
;
}
return
memory
;
}
}
h2/src/main/org/h2/value/ValueRow.java
浏览文件 @
d5d927d2
...
@@ -10,26 +10,21 @@ import java.sql.SQLException;
...
@@ -10,26 +10,21 @@ import java.sql.SQLException;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.util.MathUtils
;
/**
/**
* Row value.
* Row value.
*/
*/
public
class
ValueRow
extends
Value
{
public
class
ValueRow
extends
Value
CollectionBase
{
/**
/**
* Empty row.
* Empty row.
*/
*/
private
static
final
Object
EMPTY
=
get
(
new
Value
[
0
]);
private
static
final
Object
EMPTY
=
get
(
new
Value
[
0
]);
private
final
Value
[]
values
;
private
int
hash
;
private
ValueRow
(
Value
[]
list
)
{
private
ValueRow
(
Value
[]
list
)
{
this
.
values
=
list
;
super
(
list
)
;
}
}
/**
/**
...
@@ -52,19 +47,6 @@ public class ValueRow extends Value {
...
@@ -52,19 +47,6 @@ public class ValueRow extends Value {
return
(
ValueRow
)
EMPTY
;
return
(
ValueRow
)
EMPTY
;
}
}
@Override
public
int
hashCode
()
{
if
(
hash
!=
0
)
{
return
hash
;
}
int
h
=
1
;
for
(
Value
v
:
values
)
{
h
=
h
*
31
+
v
.
hashCode
();
}
hash
=
h
;
return
h
;
}
public
Value
[]
getList
()
{
public
Value
[]
getList
()
{
return
values
;
return
values
;
}
}
...
@@ -74,15 +56,6 @@ public class ValueRow extends Value {
...
@@ -74,15 +56,6 @@ public class ValueRow extends Value {
return
Value
.
ROW
;
return
Value
.
ROW
;
}
}
@Override
public
long
getPrecision
()
{
long
p
=
0
;
for
(
Value
v
:
values
)
{
p
+=
v
.
getPrecision
();
}
return
p
;
}
@Override
@Override
public
String
getString
()
{
public
String
getString
()
{
StringBuilder
builder
=
new
StringBuilder
(
"ROW ("
);
StringBuilder
builder
=
new
StringBuilder
(
"ROW ("
);
...
@@ -165,15 +138,6 @@ public class ValueRow extends Value {
...
@@ -165,15 +138,6 @@ public class ValueRow extends Value {
return
builder
.
append
(
')'
).
toString
();
return
builder
.
append
(
')'
).
toString
();
}
}
@Override
public
int
getDisplaySize
()
{
long
size
=
0
;
for
(
Value
v
:
values
)
{
size
+=
v
.
getDisplaySize
();
}
return
MathUtils
.
convertLongToInt
(
size
);
}
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(!(
other
instanceof
ValueRow
))
{
if
(!(
other
instanceof
ValueRow
))
{
...
@@ -195,15 +159,6 @@ public class ValueRow extends Value {
...
@@ -195,15 +159,6 @@ public class ValueRow extends Value {
return
true
;
return
true
;
}
}
@Override
public
int
getMemory
()
{
int
memory
=
32
;
for
(
Value
v
:
values
)
{
memory
+=
v
.
getMemory
()
+
Constants
.
MEMORY_POINTER
;
}
return
memory
;
}
@Override
@Override
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
public
Value
convertPrecision
(
long
precision
,
boolean
force
)
{
if
(!
force
)
{
if
(!
force
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论