Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1484337a
Unverified
提交
1484337a
authored
5月 08, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 08, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1122 from katzyn/misc
Assorted changes
上级
19767b0d
e17fa58e
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
64 行增加
和
60 行删除
+64
-60
Parser.java
h2/src/main/org/h2/command/Parser.java
+4
-4
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-5
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+0
-1
JavaAggregate.java
h2/src/main/org/h2/expression/JavaAggregate.java
+0
-1
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+0
-33
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+2
-2
TransactionMap.java
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
+3
-1
ValueArray.java
h2/src/main/org/h2/value/ValueArray.java
+17
-12
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+13
-0
TestValue.java
h2/src/test/org/h2/test/unit/TestValue.java
+22
-0
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
1484337a
...
...
@@ -5320,7 +5320,7 @@ public class Parser {
if
(
isPersistent
)
{
db
.
addSchemaObject
(
targetSession
,
view
);
view
.
lock
(
targetSession
,
true
,
true
);
targetSession
.
getDatabase
()
.
removeSchemaObject
(
targetSession
,
view
);
db
.
removeSchemaObject
(
targetSession
,
view
);
}
else
{
session
.
removeLocalTempTable
(
view
);
}
...
...
@@ -5330,7 +5330,7 @@ public class Parser {
isPersistent
);
}
// both removeSchemaObject and removeLocalTempTable hold meta locks
targetSession
.
getDatabase
()
.
unlockMeta
(
targetSession
);
db
.
unlockMeta
(
targetSession
);
}
view
.
setTableExpression
(
true
);
view
.
setTemporary
(!
isPersistent
);
...
...
@@ -5929,8 +5929,8 @@ public class Parser {
boolean
isDualTable
(
String
tableName
)
{
return
((
schemaName
==
null
||
equalsToken
(
schemaName
,
"SYS"
))
&&
equalsToken
(
"DUAL"
,
tableName
))
||
(
database
.
getMode
().
sysDummy1
&&
(
schemaName
==
null
||
equalsToken
(
schemaName
,
"SYSIBM"
))
)
&&
equalsToken
(
"SYSDUMMY1"
,
tableName
);
||
(
database
.
getMode
().
sysDummy1
&&
(
schemaName
==
null
||
equalsToken
(
schemaName
,
"SYSIBM"
))
&&
equalsToken
(
"SYSDUMMY1"
,
tableName
)
)
;
}
private
Table
readTableOrView
()
{
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
1484337a
...
...
@@ -7,11 +7,9 @@ package org.h2.command.dml;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.Trigger
;
import
org.h2.command.CommandInterface
;
...
...
@@ -48,7 +46,6 @@ import org.h2.util.ColumnNamer;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.value.CompareMode
;
import
org.h2.value.Value
;
import
org.h2.value.ValueArray
;
import
org.h2.value.ValueNull
;
...
...
@@ -111,7 +108,7 @@ public class Select extends Query {
/**
* Maps an expression object to an index, to use in accessing the Object[] pointed to by groupByData.
*/
private
final
HashMap
<
Expression
,
Integer
>
exprToIndexInGroupByData
=
new
HashMap
<>();
final
HashMap
<
Expression
,
Integer
>
exprToIndexInGroupByData
=
new
HashMap
<>();
/**
* Map of group-by key to group-by expression data e.g. AggregateData
*/
...
...
@@ -119,7 +116,7 @@ public class Select extends Query {
/**
* Key into groupByData that produces currentGroupByExprData. Not used in lazy mode.
*/
private
ValueArray
currentGroupsKey
;
ValueArray
currentGroupsKey
;
private
int
havingIndex
;
private
boolean
isGroupQuery
,
isGroupSortedQuery
;
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
1484337a
...
...
@@ -5,7 +5,6 @@
*/
package
org
.
h2
.
expression
;
import
java.util.HashMap
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Parser
;
import
org.h2.command.dml.Select
;
...
...
h2/src/main/org/h2/expression/JavaAggregate.java
浏览文件 @
1484337a
...
...
@@ -7,7 +7,6 @@ package org.h2.expression;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
org.h2.api.Aggregate
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Parser
;
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
1484337a
...
...
@@ -1026,39 +1026,6 @@ public final class DataUtils {
}
}
/**
* An entry of a map.
*
* @param <K> the key type
* @param <V> the value type
*/
public
static
final
class
MapEntry
<
K
,
V
>
implements
Map
.
Entry
<
K
,
V
>
{
private
final
K
key
;
private
final
V
value
;
public
MapEntry
(
K
key
,
V
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
@Override
public
K
getKey
()
{
return
key
;
}
@Override
public
V
getValue
()
{
return
value
;
}
@Override
public
V
setValue
(
V
value
)
{
throw
newUnsupportedOperationException
(
"Updating the value is not supported"
);
}
}
/**
* Get the configuration parameter value, or default.
*
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
1484337a
...
...
@@ -673,7 +673,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
@Override
public
Entry
<
K
,
V
>
next
()
{
K
k
=
cursor
.
next
();
return
new
DataUtils
.
Map
Entry
<>(
k
,
cursor
.
getValue
());
return
new
SimpleImmutable
Entry
<>(
k
,
cursor
.
getValue
());
}
@Override
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
1484337a
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
mvstore
.
db
;
import
java.util.AbstractMap
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -18,7 +19,6 @@ import org.h2.index.BaseIndex;
import
org.h2.index.Cursor
;
import
org.h2.index.IndexType
;
import
org.h2.message.DbException
;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.tx.Transaction
;
import
org.h2.mvstore.tx.TransactionMap
;
import
org.h2.result.Row
;
...
...
@@ -261,7 +261,7 @@ public class MVPrimaryIndex extends BaseIndex {
Collections
.<
Entry
<
Value
,
Value
>>
emptyList
().
iterator
());
}
Value
value
=
map
.
get
(
v
);
Entry
<
Value
,
Value
>
e
=
new
DataUtils
.
Map
Entry
<
Value
,
Value
>(
v
,
value
);
Entry
<
Value
,
Value
>
e
=
new
AbstractMap
.
SimpleImmutable
Entry
<
Value
,
Value
>(
v
,
value
);
List
<
Entry
<
Value
,
Value
>>
list
=
Collections
.
singletonList
(
e
);
MVStoreCursor
c
=
new
MVStoreCursor
(
session
,
list
.
iterator
());
c
.
next
();
...
...
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
浏览文件 @
1484337a
...
...
@@ -9,6 +9,8 @@ import org.h2.mvstore.Cursor;
import
org.h2.mvstore.DataUtils
;
import
org.h2.mvstore.MVMap
;
import
org.h2.mvstore.type.DataType
;
import
java.util.AbstractMap
;
import
java.util.Iterator
;
import
java.util.Map
;
...
...
@@ -671,7 +673,7 @@ public class TransactionMap<K, V> {
if
(
data
!=
null
&&
data
.
value
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
final
V
value
=
(
V
)
data
.
value
;
current
=
new
DataUtils
.
Map
Entry
<>(
key
,
value
);
current
=
new
AbstractMap
.
SimpleImmutable
Entry
<>(
key
,
value
);
currentKey
=
key
;
return
;
}
...
...
h2/src/main/org/h2/value/ValueArray.java
浏览文件 @
1484337a
...
...
@@ -7,13 +7,12 @@ package org.h2.value;
import
java.lang.reflect.Array
;
import
java.sql.PreparedStatement
;
import
java.util.Array
List
;
import
java.util.Array
s
;
import
org.h2.engine.Constants
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.Utils
;
/**
* Implementation of the ARRAY data type.
...
...
@@ -29,10 +28,6 @@ public class ValueArray extends Value {
this
.
values
=
list
;
}
private
ValueArray
(
Value
[]
list
)
{
this
(
Object
.
class
,
list
);
}
/**
* Get or create a array value for the given value array.
* Do not clone the data.
...
...
@@ -41,7 +36,7 @@ public class ValueArray extends Value {
* @return the value
*/
public
static
ValueArray
get
(
Value
[]
list
)
{
return
new
ValueArray
(
list
);
return
new
ValueArray
(
Object
.
class
,
list
);
}
/**
...
...
@@ -211,18 +206,28 @@ public class ValueArray extends Value {
if
(!
force
)
{
return
this
;
}
ArrayList
<
Value
>
list
=
Utils
.
newSmallArrayList
();
for
(
Value
v
:
values
)
{
v
=
v
.
convertPrecision
(
precision
,
true
);
int
length
=
values
.
length
;
Value
[]
newValues
=
new
Value
[
length
];
int
i
=
0
;
boolean
modified
=
false
;
for
(;
i
<
length
;
i
++)
{
Value
old
=
values
[
i
];
Value
v
=
old
.
convertPrecision
(
precision
,
true
);
if
(
v
!=
old
)
{
modified
=
true
;
}
// empty byte arrays or strings have precision 0
// they count as precision 1 here
precision
-=
Math
.
max
(
1
,
v
.
getPrecision
());
if
(
precision
<
0
)
{
break
;
}
list
.
add
(
v
);
newValues
[
i
]
=
v
;
}
if
(
i
<
length
)
{
return
get
(
componentType
,
Arrays
.
copyOf
(
newValues
,
i
));
}
return
get
(
list
.
toArray
(
new
Value
[
0
]))
;
return
modified
?
get
(
componentType
,
newValues
)
:
this
;
}
}
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
1484337a
...
...
@@ -849,6 +849,19 @@ public abstract class TestBase {
assertFalse
(
message
,
rs1
.
next
());
}
/**
* Check if two objects are the same, and if not throw an exception.
*
* @param expected the expected value
* @param actual the actual value
* @throws AssertionError if the objects are not the same
*/
public
void
assertSame
(
Object
expected
,
Object
actual
)
{
if
(
expected
!=
actual
)
{
fail
(
" expected: "
+
expected
+
" != actual: "
+
actual
);
}
}
/**
* Check if the first value is larger or equal than the second value, and if
* not throw an exception.
...
...
h2/src/test/org/h2/test/unit/TestValue.java
浏览文件 @
1484337a
...
...
@@ -61,6 +61,7 @@ public class TestValue extends TestBase {
testCastTrim
();
testValueResultSet
();
testDataType
();
testArray
();
testUUID
();
testDouble
(
false
);
testDouble
(
true
);
...
...
@@ -330,6 +331,27 @@ public class TestValue extends TestBase {
assertEquals
(
123123123
,
ts
.
getNanos
());
}
private
void
testArray
()
{
ValueArray
src
=
ValueArray
.
get
(
String
.
class
,
new
Value
[]
{
ValueString
.
get
(
"1"
),
ValueString
.
get
(
"22"
),
ValueString
.
get
(
"333"
)});
assertEquals
(
6
,
src
.
getPrecision
());
assertSame
(
src
,
src
.
convertPrecision
(
5
,
false
));
assertSame
(
src
,
src
.
convertPrecision
(
6
,
true
));
ValueArray
exp
=
ValueArray
.
get
(
String
.
class
,
new
Value
[]
{
ValueString
.
get
(
"1"
),
ValueString
.
get
(
"22"
),
ValueString
.
get
(
"33"
)});
Value
got
=
src
.
convertPrecision
(
5
,
true
);
assertEquals
(
exp
,
got
);
assertEquals
(
String
.
class
,
((
ValueArray
)
got
).
getComponentType
());
exp
=
ValueArray
.
get
(
String
.
class
,
new
Value
[]
{
ValueString
.
get
(
"1"
),
ValueString
.
get
(
"22"
)});
got
=
src
.
convertPrecision
(
3
,
true
);
assertEquals
(
exp
,
got
);
assertEquals
(
String
.
class
,
((
ValueArray
)
got
).
getComponentType
());
exp
=
ValueArray
.
get
(
String
.
class
,
new
Value
[
0
]);
got
=
src
.
convertPrecision
(
0
,
true
);
assertEquals
(
exp
,
got
);
assertEquals
(
String
.
class
,
((
ValueArray
)
got
).
getComponentType
());
}
private
void
testUUID
()
{
long
maxHigh
=
0
,
maxLow
=
0
,
minHigh
=
-
1L
,
minLow
=
-
1L
;
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论