Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
764c9495
提交
764c9495
authored
1月 06, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting, javadocs, improve testability
上级
8f38fa77
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
138 行增加
和
72 行删除
+138
-72
JdbcArray.java
h2/src/main/org/h2/jdbc/JdbcArray.java
+6
-12
JdbcConnection.java
h2/src/main/org/h2/jdbc/JdbcConnection.java
+7
-1
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+3
-5
Cursor.java
h2/src/main/org/h2/mvstore/Cursor.java
+2
-2
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+4
-4
FileStore.java
h2/src/main/org/h2/mvstore/FileStore.java
+1
-1
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+2
-2
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+11
-0
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+87
-31
ResultTempTable.java
h2/src/main/org/h2/result/ResultTempTable.java
+1
-1
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+8
-8
FunctionTable.java
h2/src/main/org/h2/table/FunctionTable.java
+4
-3
TableView.java
h2/src/main/org/h2/table/TableView.java
+1
-1
没有找到文件。
h2/src/main/org/h2/jdbc/JdbcArray.java
浏览文件 @
764c9495
...
@@ -62,7 +62,7 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -62,7 +62,7 @@ public class JdbcArray extends TraceObject implements Array {
public
Object
getArray
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
public
Object
getArray
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
try
{
try
{
debugCode
(
"getArray("
+
quoteMap
(
map
)+
");"
);
debugCode
(
"getArray("
+
quoteMap
(
map
)+
");"
);
checkMap
(
map
);
JdbcConnection
.
checkMap
(
map
);
checkClosed
();
checkClosed
();
return
get
();
return
get
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -105,7 +105,7 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -105,7 +105,7 @@ public class JdbcArray extends TraceObject implements Array {
try
{
try
{
debugCode
(
"getArray("
+
index
+
", "
+
count
+
", "
+
quoteMap
(
map
)+
");"
);
debugCode
(
"getArray("
+
index
+
", "
+
count
+
", "
+
quoteMap
(
map
)+
");"
);
checkClosed
();
checkClosed
();
checkMap
(
map
);
JdbcConnection
.
checkMap
(
map
);
return
get
(
index
,
count
);
return
get
(
index
,
count
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -176,7 +176,7 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -176,7 +176,7 @@ public class JdbcArray extends TraceObject implements Array {
try
{
try
{
debugCode
(
"getResultSet("
+
quoteMap
(
map
)+
");"
);
debugCode
(
"getResultSet("
+
quoteMap
(
map
)+
");"
);
checkClosed
();
checkClosed
();
checkMap
(
map
);
JdbcConnection
.
checkMap
(
map
);
return
getResultSet
(
get
(),
0
);
return
getResultSet
(
get
(),
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
...
@@ -198,7 +198,7 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -198,7 +198,7 @@ public class JdbcArray extends TraceObject implements Array {
try
{
try
{
debugCode
(
"getResultSet("
+
index
+
", "
+
count
+
");"
);
debugCode
(
"getResultSet("
+
index
+
", "
+
count
+
");"
);
checkClosed
();
checkClosed
();
return
getResultSet
(
get
(
index
,
count
),
index
);
return
getResultSet
(
get
(
index
,
count
),
index
-
1
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -221,8 +221,8 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -221,8 +221,8 @@ public class JdbcArray extends TraceObject implements Array {
try
{
try
{
debugCode
(
"getResultSet("
+
index
+
", "
+
count
+
", "
+
quoteMap
(
map
)+
");"
);
debugCode
(
"getResultSet("
+
index
+
", "
+
count
+
", "
+
quoteMap
(
map
)+
");"
);
checkClosed
();
checkClosed
();
checkMap
(
map
);
JdbcConnection
.
checkMap
(
map
);
return
getResultSet
(
get
(
index
,
count
),
index
);
return
getResultSet
(
get
(
index
,
count
),
index
-
1
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
throw
logAndConvert
(
e
);
}
}
...
@@ -274,12 +274,6 @@ public class JdbcArray extends TraceObject implements Array {
...
@@ -274,12 +274,6 @@ public class JdbcArray extends TraceObject implements Array {
return
subset
;
return
subset
;
}
}
private
static
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
throw
DbException
.
getUnsupportedException
(
"map.size > 0"
);
}
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
...
h2/src/main/org/h2/jdbc/JdbcConnection.java
浏览文件 @
764c9495
...
@@ -1807,7 +1807,13 @@ public class JdbcConnection extends TraceObject implements Connection {
...
@@ -1807,7 +1807,13 @@ public class JdbcConnection extends TraceObject implements Connection {
}
}
//*/
//*/
private
static
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
/**
* Check that the given type map is either null or empty.
*
* @param map the type map
* @throws DbException if the map is not empty
*/
static
void
checkMap
(
Map
<
String
,
Class
<?>>
map
)
{
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
throw
DbException
.
getUnsupportedException
(
"map.size > 0"
);
throw
DbException
.
getUnsupportedException
(
"map.size > 0"
);
}
}
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
764c9495
...
@@ -212,13 +212,12 @@ public class JdbcDataSource extends TraceObject
...
@@ -212,13 +212,12 @@ public class JdbcDataSource extends TraceObject
debugCodeCall
(
"setURL"
,
url
);
debugCodeCall
(
"setURL"
,
url
);
this
.
url
=
url
;
this
.
url
=
url
;
}
}
/**
/**
* Get the current URL.
* Get the current URL.
* <p>
* This method does the same as getURL, but this methods signature conforms
* This method does the same as getURL, but this methods signature conforms
* the JavaBean naming convention.
* the JavaBean naming convention.
*
*
* @return the URL
* @return the URL
*/
*/
public
String
getUrl
()
{
public
String
getUrl
()
{
...
@@ -228,10 +227,9 @@ public class JdbcDataSource extends TraceObject
...
@@ -228,10 +227,9 @@ public class JdbcDataSource extends TraceObject
/**
/**
* Set the current URL.
* Set the current URL.
* <p>
* This method does the same as setURL, but this methods signature conforms
* This method does the same as setURL, but this methods signature conforms
* the JavaBean naming convention.
* the JavaBean naming convention.
*
*
* @param url the new URL
* @param url the new URL
*/
*/
public
void
setUrl
(
String
url
)
{
public
void
setUrl
(
String
url
)
{
...
...
h2/src/main/org/h2/mvstore/Cursor.java
浏览文件 @
764c9495
...
@@ -48,10 +48,10 @@ public class Cursor<K, V> implements Iterator<K> {
...
@@ -48,10 +48,10 @@ public class Cursor<K, V> implements Iterator<K> {
fetchNext
();
fetchNext
();
return
c
;
return
c
;
}
}
/**
/**
* Get the last read value if there was one.
* Get the last read value if there was one.
*
*
* @return the value or null
* @return the value or null
*/
*/
public
V
getValue
()
{
public
V
getValue
()
{
...
...
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
764c9495
...
@@ -854,7 +854,7 @@ public class DataUtils {
...
@@ -854,7 +854,7 @@ public class DataUtils {
return
errorValue
;
return
errorValue
;
}
}
}
}
/**
/**
* An entry of a map.
* An entry of a map.
*
*
...
@@ -862,10 +862,10 @@ public class DataUtils {
...
@@ -862,10 +862,10 @@ public class DataUtils {
* @param <V> the value type
* @param <V> the value type
*/
*/
public
static
class
MapEntry
<
K
,
V
>
implements
Map
.
Entry
<
K
,
V
>
{
public
static
class
MapEntry
<
K
,
V
>
implements
Map
.
Entry
<
K
,
V
>
{
private
final
K
key
;
private
final
K
key
;
private
V
value
;
private
V
value
;
public
MapEntry
(
K
key
,
V
value
)
{
public
MapEntry
(
K
key
,
V
value
)
{
this
.
key
=
key
;
this
.
key
=
key
;
this
.
value
=
value
;
this
.
value
=
value
;
...
@@ -886,7 +886,7 @@ public class DataUtils {
...
@@ -886,7 +886,7 @@ public class DataUtils {
throw
DataUtils
.
newUnsupportedOperationException
(
throw
DataUtils
.
newUnsupportedOperationException
(
"Updating the value is not supported"
);
"Updating the value is not supported"
);
}
}
}
}
}
}
h2/src/main/org/h2/mvstore/FileStore.java
浏览文件 @
764c9495
...
@@ -113,7 +113,7 @@ public class FileStore {
...
@@ -113,7 +113,7 @@ public class FileStore {
*/
*/
public
void
open
(
String
fileName
,
boolean
readOnly
,
char
[]
encryptionKey
)
{
public
void
open
(
String
fileName
,
boolean
readOnly
,
char
[]
encryptionKey
)
{
if
(
fileName
!=
null
)
{
if
(
fileName
!=
null
)
{
if
(
FilePath
.
get
(
fileName
)
instanceof
FilePathDisk
)
{
if
(
FilePath
.
get
(
fileName
)
instanceof
FilePathDisk
)
{
// NIO is used, unless a different file system is specified
// NIO is used, unless a different file system is specified
// the following line is to ensure the NIO file system is compiled
// the following line is to ensure the NIO file system is compiled
FilePathNio
.
class
.
getName
();
FilePathNio
.
class
.
getName
();
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
764c9495
...
@@ -753,10 +753,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
...
@@ -753,10 +753,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
return
new
Cursor
<
K
,
V
>(
this
,
root
,
from
);
return
new
Cursor
<
K
,
V
>(
this
,
root
,
from
);
}
}
/**
/**
* Get a cursor to iterate over a number of keys and values.
* Get a cursor to iterate over a number of keys and values.
*
*
* @param from the first key to return
* @param from the first key to return
* @return the cursor
* @return the cursor
*/
*/
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
764c9495
...
@@ -2166,7 +2166,7 @@ public class MVStore {
...
@@ -2166,7 +2166,7 @@ public class MVStore {
* KB for in-memory stores. This is not a limit in the page size, as
* KB for in-memory stores. This is not a limit in the page size, as
* pages with one entry can get larger. It is just the point where pages
* pages with one entry can get larger. It is just the point where pages
* that contain more than one entry are split.
* that contain more than one entry are split.
*
*
* @param pageSplitSize the page size
* @param pageSplitSize the page size
* @return this
* @return this
*/
*/
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
764c9495
...
@@ -39,8 +39,19 @@ import org.h2.value.ValueNull;
...
@@ -39,8 +39,19 @@ import org.h2.value.ValueNull;
*/
*/
public
class
MVPrimaryIndex
extends
BaseIndex
{
public
class
MVPrimaryIndex
extends
BaseIndex
{
/**
* The minimum long value.
*/
static
final
ValueLong
MIN
=
ValueLong
.
get
(
Long
.
MIN_VALUE
);
static
final
ValueLong
MIN
=
ValueLong
.
get
(
Long
.
MIN_VALUE
);
/**
* The maximum long value.
*/
static
final
ValueLong
MAX
=
ValueLong
.
get
(
Long
.
MAX_VALUE
);
static
final
ValueLong
MAX
=
ValueLong
.
get
(
Long
.
MAX_VALUE
);
/**
* The zero long value.
*/
static
final
ValueLong
ZERO
=
ValueLong
.
get
(
0
);
static
final
ValueLong
ZERO
=
ValueLong
.
get
(
0
);
private
final
MVTable
mvTable
;
private
final
MVTable
mvTable
;
...
...
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
764c9495
...
@@ -28,7 +28,7 @@ import org.h2.util.New;
...
@@ -28,7 +28,7 @@ import org.h2.util.New;
* A store that supports concurrent transactions.
* A store that supports concurrent transactions.
*/
*/
public
class
TransactionStore
{
public
class
TransactionStore
{
/**
/**
* Whether the concurrent maps should be used.
* Whether the concurrent maps should be used.
*/
*/
...
@@ -61,7 +61,7 @@ public class TransactionStore {
...
@@ -61,7 +61,7 @@ public class TransactionStore {
* The lock timeout in milliseconds. 0 means timeout immediately.
* The lock timeout in milliseconds. 0 means timeout immediately.
*/
*/
long
lockTimeout
;
long
lockTimeout
;
/**
/**
* The map of maps.
* The map of maps.
*/
*/
...
@@ -70,7 +70,7 @@ public class TransactionStore {
...
@@ -70,7 +70,7 @@ public class TransactionStore {
private
final
DataType
dataType
;
private
final
DataType
dataType
;
private
int
lastTransactionId
;
private
int
lastTransactionId
;
private
int
maxTransactionId
=
0xffff
;
private
int
maxTransactionId
=
0xffff
;
/**
/**
...
@@ -104,30 +104,49 @@ public class TransactionStore {
...
@@ -104,30 +104,49 @@ public class TransactionStore {
undoLog
=
store
.
openMap
(
"undoLog"
,
builder
);
undoLog
=
store
.
openMap
(
"undoLog"
,
builder
);
init
();
init
();
}
}
/**
/**
* Set the maximum transaction id, after which ids are re-used. If the old
* Set the maximum transaction id, after which ids are re-used. If the old
* transaction is still in use when re-using an old id, the new transaction
* transaction is still in use when re-using an old id, the new transaction
* fails.
* fails.
*
*
* @param max the maximum id
* @param max the maximum id
*/
*/
public
void
setMaxTransactionId
(
int
max
)
{
public
void
setMaxTransactionId
(
int
max
)
{
this
.
maxTransactionId
=
max
;
this
.
maxTransactionId
=
max
;
}
}
/**
* Combine the transaction id and the log id to an operation id.
*
* @param transactionId the transaction id
* @param logId the log id
* @return the operation id
*/
static
long
getOperationId
(
int
transactionId
,
long
logId
)
{
static
long
getOperationId
(
int
transactionId
,
long
logId
)
{
DataUtils
.
checkArgument
(
transactionId
>=
0
&&
transactionId
<
(
1
<<
24
),
DataUtils
.
checkArgument
(
transactionId
>=
0
&&
transactionId
<
(
1
<<
24
),
"Transaction id out of range: {0}"
,
transactionId
);
"Transaction id out of range: {0}"
,
transactionId
);
DataUtils
.
checkArgument
(
logId
>=
0
&&
logId
<
(
1L
<<
40
),
DataUtils
.
checkArgument
(
logId
>=
0
&&
logId
<
(
1L
<<
40
),
"Transaction log id out of range: {0}"
,
logId
);
"Transaction log id out of range: {0}"
,
logId
);
return
((
long
)
transactionId
<<
40
)
|
logId
;
return
((
long
)
transactionId
<<
40
)
|
logId
;
}
}
/**
* Get the transaction id for the given operation id.
*
* @param operationId the operation id
* @return the transaction id
*/
static
int
getTransactionId
(
long
operationId
)
{
static
int
getTransactionId
(
long
operationId
)
{
return
(
int
)
(
operationId
>>>
40
);
return
(
int
)
(
operationId
>>>
40
);
}
}
/**
* Get the log id for the given operation id.
*
* @param operationId the operation id
* @return the log id
*/
static
long
getLogId
(
long
operationId
)
{
static
long
getLogId
(
long
operationId
)
{
return
operationId
&
((
1L
<<
40
)
-
1
);
return
operationId
&
((
1L
<<
40
)
-
1
);
}
}
...
@@ -226,8 +245,8 @@ public class TransactionStore {
...
@@ -226,8 +245,8 @@ public class TransactionStore {
if
(
logId
==
0
)
{
if
(
logId
==
0
)
{
if
(
undoLog
.
containsKey
(
undoKey
))
{
if
(
undoLog
.
containsKey
(
undoKey
))
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTION_STILL_OPEN
,
DataUtils
.
ERROR_TRANSACTION_STILL_OPEN
,
"An old transaction with the same id is still open: {0}"
,
"An old transaction with the same id is still open: {0}"
,
t
.
getId
());
t
.
getId
());
}
}
}
}
...
@@ -247,7 +266,14 @@ public class TransactionStore {
...
@@ -247,7 +266,14 @@ public class TransactionStore {
undoLog
.
remove
(
undoKey
);
undoLog
.
remove
(
undoKey
);
}
}
}
}
/**
* Remove the given map.
*
* @param <K> the key type
* @param <V> the value type
* @param map the map
*/
synchronized
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
synchronized
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
maps
.
remove
(
map
.
mapId
);
maps
.
remove
(
map
.
mapId
);
store
.
removeMap
(
map
.
map
);
store
.
removeMap
(
map
.
map
);
...
@@ -301,8 +327,18 @@ public class TransactionStore {
...
@@ -301,8 +327,18 @@ public class TransactionStore {
}
}
endTransaction
(
t
);
endTransaction
(
t
);
}
}
synchronized
<
K
>
MVMap
<
K
,
VersionedValue
>
openMap
(
String
name
,
DataType
keyType
,
DataType
valueType
)
{
/**
* Open the map with the given name.
*
* @param <K> the key type
* @param name the map name
* @param keyType the key type
* @param valueType the value type
* @return the map
*/
synchronized
<
K
>
MVMap
<
K
,
VersionedValue
>
openMap
(
String
name
,
DataType
keyType
,
DataType
valueType
)
{
if
(
keyType
==
null
)
{
if
(
keyType
==
null
)
{
keyType
=
new
ObjectDataType
();
keyType
=
new
ObjectDataType
();
}
}
...
@@ -312,12 +348,12 @@ public class TransactionStore {
...
@@ -312,12 +348,12 @@ public class TransactionStore {
VersionedValueType
vt
=
new
VersionedValueType
(
valueType
);
VersionedValueType
vt
=
new
VersionedValueType
(
valueType
);
MVMap
<
K
,
VersionedValue
>
map
;
MVMap
<
K
,
VersionedValue
>
map
;
if
(
CONCURRENT
)
{
if
(
CONCURRENT
)
{
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>
builder
=
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>
builder
=
new
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>().
new
MVMapConcurrent
.
Builder
<
K
,
VersionedValue
>().
keyType
(
keyType
).
valueType
(
vt
);
keyType
(
keyType
).
valueType
(
vt
);
map
=
store
.
openMap
(
name
,
builder
);
map
=
store
.
openMap
(
name
,
builder
);
}
else
{
}
else
{
MVMap
.
Builder
<
K
,
VersionedValue
>
builder
=
MVMap
.
Builder
<
K
,
VersionedValue
>
builder
=
new
MVMap
.
Builder
<
K
,
VersionedValue
>().
new
MVMap
.
Builder
<
K
,
VersionedValue
>().
keyType
(
keyType
).
valueType
(
vt
);
keyType
(
keyType
).
valueType
(
vt
);
map
=
store
.
openMap
(
name
,
builder
);
map
=
store
.
openMap
(
name
,
builder
);
...
@@ -328,6 +364,12 @@ public class TransactionStore {
...
@@ -328,6 +364,12 @@ public class TransactionStore {
return
map
;
return
map
;
}
}
/**
* Open the map with the given id.
*
* @param mapId the id
* @return the map
*/
synchronized
MVMap
<
Object
,
VersionedValue
>
openMap
(
int
mapId
)
{
synchronized
MVMap
<
Object
,
VersionedValue
>
openMap
(
int
mapId
)
{
MVMap
<
Object
,
VersionedValue
>
map
=
maps
.
get
(
mapId
);
MVMap
<
Object
,
VersionedValue
>
map
=
maps
.
get
(
mapId
);
if
(
map
!=
null
)
{
if
(
map
!=
null
)
{
...
@@ -731,7 +773,7 @@ public class TransactionStore {
...
@@ -731,7 +773,7 @@ public class TransactionStore {
public
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
public
<
K
,
V
>
void
removeMap
(
TransactionMap
<
K
,
V
>
map
)
{
store
.
removeMap
(
map
);
store
.
removeMap
(
map
);
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
""
+
transactionId
;
return
""
+
transactionId
;
...
@@ -751,7 +793,7 @@ public class TransactionStore {
...
@@ -751,7 +793,7 @@ public class TransactionStore {
* The map id.
* The map id.
*/
*/
final
int
mapId
;
final
int
mapId
;
/**
/**
* If a record was read that was updated by this transaction, and the
* If a record was read that was updated by this transaction, and the
* update occurred before this log id, the older version is read. This
* update occurred before this log id, the older version is read. This
...
@@ -767,7 +809,7 @@ public class TransactionStore {
...
@@ -767,7 +809,7 @@ public class TransactionStore {
* Value: { transactionId, oldVersion, value }
* Value: { transactionId, oldVersion, value }
*/
*/
final
MVMap
<
K
,
VersionedValue
>
map
;
final
MVMap
<
K
,
VersionedValue
>
map
;
private
Transaction
transaction
;
private
Transaction
transaction
;
TransactionMap
(
Transaction
transaction
,
MVMap
<
K
,
VersionedValue
>
map
,
int
mapId
)
{
TransactionMap
(
Transaction
transaction
,
MVMap
<
K
,
VersionedValue
>
map
,
int
mapId
)
{
...
@@ -798,7 +840,7 @@ public class TransactionStore {
...
@@ -798,7 +840,7 @@ public class TransactionStore {
m
.
setSavepoint
(
savepoint
);
m
.
setSavepoint
(
savepoint
);
return
m
;
return
m
;
}
}
/**
/**
* Get the size of the raw map.
* Get the size of the raw map.
*
*
...
@@ -1060,7 +1102,15 @@ public class TransactionStore {
...
@@ -1060,7 +1102,15 @@ public class TransactionStore {
VersionedValue
data
=
map
.
get
(
key
);
VersionedValue
data
=
map
.
get
(
key
);
return
getValue
(
key
,
maxLog
,
data
);
return
getValue
(
key
,
maxLog
,
data
);
}
}
/**
* Get the versioned value for the given key.
*
* @param key the key
* @param maxLog the maximum log id of the entry
* @param data the value stored in the main map
* @return the value
*/
VersionedValue
getValue
(
K
key
,
long
maxLog
,
VersionedValue
data
)
{
VersionedValue
getValue
(
K
key
,
long
maxLog
,
VersionedValue
data
)
{
while
(
true
)
{
while
(
true
)
{
if
(
data
==
null
)
{
if
(
data
==
null
)
{
...
@@ -1085,13 +1135,13 @@ public class TransactionStore {
...
@@ -1085,13 +1135,13 @@ public class TransactionStore {
d
=
transaction
.
store
.
undoLog
.
get
(
id
);
d
=
transaction
.
store
.
undoLog
.
get
(
id
);
}
}
if
(
d
==
null
)
{
if
(
d
==
null
)
{
// this entry was committed or rolled back
// this entry was committed or rolled back
// in the meantime (the transaction might still be open)
// in the meantime (the transaction might still be open)
data
=
map
.
get
(
key
);
data
=
map
.
get
(
key
);
}
else
{
}
else
{
data
=
(
VersionedValue
)
d
[
2
];
data
=
(
VersionedValue
)
d
[
2
];
}
}
// verify this is either committed,
// verify this is either committed,
// or the same transaction and earlier
// or the same transaction and earlier
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
long
id2
=
data
.
operationId
;
long
id2
=
data
.
operationId
;
...
@@ -1109,7 +1159,7 @@ public class TransactionStore {
...
@@ -1109,7 +1159,7 @@ public class TransactionStore {
}
}
}
}
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTION_CORRUPT
,
DataUtils
.
ERROR_TRANSACTION_CORRUPT
,
"The transaction log might be corrupt for key {0}"
,
key
);
"The transaction log might be corrupt for key {0}"
,
key
);
}
}
...
@@ -1238,7 +1288,13 @@ public class TransactionStore {
...
@@ -1238,7 +1288,13 @@ public class TransactionStore {
Iterator
<
K
>
it
=
map
.
keyIterator
(
from
);
Iterator
<
K
>
it
=
map
.
keyIterator
(
from
);
return
wrapIterator
(
it
,
includeUncommitted
);
return
wrapIterator
(
it
,
includeUncommitted
);
}
}
/**
* Iterate over entries.
*
* @param from the first key to return
* @return the iterator
*/
public
Iterator
<
Entry
<
K
,
V
>>
entryIterator
(
K
from
)
{
public
Iterator
<
Entry
<
K
,
V
>>
entryIterator
(
K
from
)
{
final
Cursor
<
K
,
VersionedValue
>
cursor
=
map
.
cursor
(
from
);
final
Cursor
<
K
,
VersionedValue
>
cursor
=
map
.
cursor
(
from
);
return
new
Iterator
<
Entry
<
K
,
V
>>()
{
return
new
Iterator
<
Entry
<
K
,
V
>>()
{
...
@@ -1279,11 +1335,11 @@ public class TransactionStore {
...
@@ -1279,11 +1335,11 @@ public class TransactionStore {
public
void
remove
()
{
public
void
remove
()
{
throw
DataUtils
.
newUnsupportedOperationException
(
throw
DataUtils
.
newUnsupportedOperationException
(
"Removing is not supported"
);
"Removing is not supported"
);
}
}
};
};
}
}
/**
/**
* Iterate over keys.
* Iterate over keys.
*
*
...
@@ -1408,12 +1464,12 @@ public class TransactionStore {
...
@@ -1408,12 +1464,12 @@ public class TransactionStore {
* The value.
* The value.
*/
*/
public
Object
value
;
public
Object
value
;
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
value
+
(
operationId
==
0
?
""
:
(
return
value
+
(
operationId
==
0
?
""
:
(
" "
+
" "
+
getTransactionId
(
operationId
)
+
"/"
+
getTransactionId
(
operationId
)
+
"/"
+
getLogId
(
operationId
)));
getLogId
(
operationId
)));
}
}
...
...
h2/src/main/org/h2/result/ResultTempTable.java
浏览文件 @
764c9495
...
@@ -69,7 +69,7 @@ public class ResultTempTable implements ResultExternal {
...
@@ -69,7 +69,7 @@ public class ResultTempTable implements ResultExternal {
}
else
{
}
else
{
index
=
new
PageBtreeIndex
((
RegularTable
)
table
,
indexId
,
data
.
tableName
,
indexCols
,
indexType
,
true
,
session
);
index
=
new
PageBtreeIndex
((
RegularTable
)
table
,
indexId
,
data
.
tableName
,
indexCols
,
indexType
,
true
,
session
);
index
.
setTemporary
(
true
);
index
.
setTemporary
(
true
);
table
.
getIndexes
().
add
(
index
);
table
.
getIndexes
().
add
(
index
);
}
}
parent
=
null
;
parent
=
null
;
}
}
...
...
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
764c9495
...
@@ -45,7 +45,7 @@ import org.h2.value.ValueLobDb;
...
@@ -45,7 +45,7 @@ import org.h2.value.ValueLobDb;
* take a very long time. If we did them on a normal session, we would be
* take a very long time. If we did them on a normal session, we would be
* locking the LOB tables for long periods of time, which is extremely
* locking the LOB tables for long periods of time, which is extremely
* detrimental to the rest of the system. Perhaps when we shift to the MVStore
* detrimental to the rest of the system. Perhaps when we shift to the MVStore
* engine, we can revisit this design decision
* engine, we can revisit this design decision
* (using the StreamStore, that is, no connection at all).
* (using the StreamStore, that is, no connection at all).
* <p>
* <p>
* Locking
* Locking
...
@@ -783,20 +783,20 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -783,20 +783,20 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
}
}
/**
/**
* An input stream that reads the data from a reader.
* An input stream that reads the data from a reader.
*/
*/
public
static
class
CountingReaderInputStream
extends
InputStream
{
public
static
class
CountingReaderInputStream
extends
InputStream
{
private
final
Reader
reader
;
private
final
Reader
reader
;
private
final
CharBuffer
charBuffer
=
CharBuffer
.
allocate
(
Constants
.
IO_BUFFER_SIZE
);
private
final
CharBuffer
charBuffer
=
CharBuffer
.
allocate
(
Constants
.
IO_BUFFER_SIZE
);
private
final
CharsetEncoder
encoder
=
Constants
.
UTF8
.
newEncoder
().
private
final
CharsetEncoder
encoder
=
Constants
.
UTF8
.
newEncoder
().
onMalformedInput
(
CodingErrorAction
.
REPLACE
).
onMalformedInput
(
CodingErrorAction
.
REPLACE
).
onUnmappableCharacter
(
CodingErrorAction
.
REPLACE
);
onUnmappableCharacter
(
CodingErrorAction
.
REPLACE
);
private
ByteBuffer
byteBuffer
=
ByteBuffer
.
allocate
(
0
);
private
ByteBuffer
byteBuffer
=
ByteBuffer
.
allocate
(
0
);
private
long
length
;
private
long
length
;
private
long
remaining
;
private
long
remaining
;
...
@@ -823,7 +823,7 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -823,7 +823,7 @@ public class LobStorageBackend implements LobStorageInterface {
}
}
return
byteBuffer
.
get
()
&
255
;
return
byteBuffer
.
get
()
&
255
;
}
}
private
boolean
fetch
()
throws
IOException
{
private
boolean
fetch
()
throws
IOException
{
if
(
byteBuffer
!=
null
&&
byteBuffer
.
remaining
()
==
0
)
{
if
(
byteBuffer
!=
null
&&
byteBuffer
.
remaining
()
==
0
)
{
fillBuffer
();
fillBuffer
();
...
@@ -858,11 +858,11 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -858,11 +858,11 @@ public class LobStorageBackend implements LobStorageInterface {
charBuffer
.
flip
();
charBuffer
.
flip
();
charBuffer
.
position
(
charBuffer
.
limit
());
charBuffer
.
position
(
charBuffer
.
limit
());
}
}
/**
/**
* The number of characters read so far (but there might still be some bytes
* The number of characters read so far (but there might still be some bytes
* in the buffer).
* in the buffer).
*
*
* @return the number of characters
* @return the number of characters
*/
*/
public
long
getLength
()
{
public
long
getLength
()
{
...
...
h2/src/main/org/h2/table/FunctionTable.java
浏览文件 @
764c9495
...
@@ -70,8 +70,8 @@ public class FunctionTable extends Table {
...
@@ -70,8 +70,8 @@ public class FunctionTable extends Table {
int
columnCount
=
meta
.
getColumnCount
();
int
columnCount
=
meta
.
getColumnCount
();
Column
[]
cols
=
new
Column
[
columnCount
];
Column
[]
cols
=
new
Column
[
columnCount
];
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
cols
[
i
]
=
new
Column
(
meta
.
getColumnName
(
i
+
1
),
cols
[
i
]
=
new
Column
(
meta
.
getColumnName
(
i
+
1
),
DataType
.
getValueTypeFromResultSet
(
meta
,
i
+
1
),
DataType
.
getValueTypeFromResultSet
(
meta
,
i
+
1
),
meta
.
getPrecision
(
i
+
1
),
meta
.
getPrecision
(
i
+
1
),
meta
.
getScale
(
i
+
1
),
meta
.
getColumnDisplaySize
(
i
+
1
));
meta
.
getScale
(
i
+
1
),
meta
.
getColumnDisplaySize
(
i
+
1
));
}
}
...
@@ -173,7 +173,8 @@ public class FunctionTable extends Table {
...
@@ -173,7 +173,8 @@ public class FunctionTable extends Table {
}
}
/**
/**
* Read the result from the function. This method buffers the result in a temporary file.
* Read the result from the function. This method buffers the result in a
* temporary file.
*
*
* @param session the session
* @param session the session
* @return the result
* @return the result
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
764c9495
...
@@ -506,7 +506,7 @@ public class TableView extends Table {
...
@@ -506,7 +506,7 @@ public class TableView extends Table {
public
boolean
isTableExpression
()
{
public
boolean
isTableExpression
()
{
return
tableExpression
;
return
tableExpression
;
}
}
@Override
@Override
public
void
addDependencies
(
HashSet
<
DbObject
>
dependencies
)
{
public
void
addDependencies
(
HashSet
<
DbObject
>
dependencies
)
{
super
.
addDependencies
(
dependencies
);
super
.
addDependencies
(
dependencies
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论