Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e3246873
提交
e3246873
authored
4月 03, 2010
作者:
Sergi Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed methods visibility in Data
上级
cc401fdd
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
54 行增加
和
24 行删除
+54
-24
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+1
-1
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+2
-2
PageDataNode.java
h2/src/main/org/h2/index/PageDataNode.java
+4
-4
Data.java
h2/src/main/org/h2/store/Data.java
+47
-17
没有找到文件。
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
e3246873
...
...
@@ -377,7 +377,7 @@ public class PageBtreeIndex extends PageIndex {
* @return the number of bytes
*/
int
getRowSize
(
Data
dummy
,
SearchRow
row
,
boolean
onlyPosition
)
{
int
rowsize
=
dummy
.
getVarLongLen
(
row
.
getKey
());
int
rowsize
=
Data
.
getVarLongLen
(
row
.
getKey
());
if
(!
onlyPosition
)
{
for
(
Column
col
:
columns
)
{
Value
v
=
row
.
getValue
(
col
.
getColumnId
());
...
...
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
e3246873
...
...
@@ -154,7 +154,7 @@ public class PageDataLeaf extends PageData {
int
rowLength
=
getRowLength
(
row
);
int
pageSize
=
index
.
getPageStore
().
getPageSize
();
int
last
=
entryCount
==
0
?
pageSize
:
offsets
[
entryCount
-
1
];
int
keyOffsetPairLen
=
2
+
d
ata
.
getVarLongLen
(
row
.
getKey
());
int
keyOffsetPairLen
=
2
+
D
ata
.
getVarLongLen
(
row
.
getKey
());
if
(
entryCount
>
0
&&
last
-
rowLength
<
start
+
keyOffsetPairLen
)
{
int
x
=
findInsertionPoint
(
row
.
getKey
());
if
(
entryCount
>
1
)
{
...
...
@@ -271,7 +271,7 @@ public class PageDataLeaf extends PageData {
firstOverflowPageId
=
0
;
overflowRowSize
=
0
;
rowRef
=
null
;
int
keyOffsetPairLen
=
2
+
d
ata
.
getVarLongLen
(
keys
[
i
]);
int
keyOffsetPairLen
=
2
+
D
ata
.
getVarLongLen
(
keys
[
i
]);
int
[]
newOffsets
=
new
int
[
entryCount
];
long
[]
newKeys
=
new
long
[
entryCount
];
Row
[]
newRows
=
new
Row
[
entryCount
];
...
...
h2/src/main/org/h2/index/PageDataNode.java
浏览文件 @
e3246873
...
...
@@ -131,12 +131,12 @@ public class PageDataNode extends PageData {
keys
=
newKeys
;
childPageIds
=
newChildPageIds
;
entryCount
++;
length
+=
4
+
d
ata
.
getVarLongLen
(
key
);
length
+=
4
+
D
ata
.
getVarLongLen
(
key
);
}
int
addRowTry
(
Row
row
)
{
index
.
getPageStore
().
logUndo
(
this
,
data
);
int
keyOffsetPairLen
=
4
+
d
ata
.
getVarLongLen
(
row
.
getKey
());
int
keyOffsetPairLen
=
4
+
D
ata
.
getVarLongLen
(
row
.
getKey
());
while
(
true
)
{
int
x
=
find
(
row
.
getKey
());
PageData
page
=
index
.
getPage
(
childPageIds
[
x
],
getPos
());
...
...
@@ -213,7 +213,7 @@ public class PageDataNode extends PageData {
entryCount
=
1
;
childPageIds
=
new
int
[]
{
page1
.
getPos
(),
page2
.
getPos
()
};
keys
=
new
long
[]
{
pivot
};
length
+=
4
+
d
ata
.
getVarLongLen
(
pivot
);
length
+=
4
+
D
ata
.
getVarLongLen
(
pivot
);
check
();
}
...
...
@@ -362,7 +362,7 @@ public class PageDataNode extends PageData {
changeCount
=
index
.
getPageStore
().
getChangeCount
();
entryCount
--;
int
removedKeyIndex
=
i
<
keys
.
length
?
i
:
i
-
1
;
length
-=
4
+
d
ata
.
getVarLongLen
(
keys
[
removedKeyIndex
]);
length
-=
4
+
D
ata
.
getVarLongLen
(
keys
[
removedKeyIndex
]);
if
(
entryCount
<
0
)
{
DbException
.
throwInternalError
();
}
...
...
h2/src/main/org/h2/store/Data.java
浏览文件 @
e3246873
...
...
@@ -80,7 +80,7 @@ public class Data {
/**
* The data itself.
*/
pr
ivate
byte
[]
data
;
pr
otected
byte
[]
data
;
/**
* The current write or read position.
...
...
@@ -92,7 +92,7 @@ public class Data {
*/
private
final
DataHandler
handler
;
pr
ivate
Data
(
DataHandler
handler
,
byte
[]
data
)
{
pr
otected
Data
(
DataHandler
handler
,
byte
[]
data
)
{
this
.
handler
=
handler
;
this
.
data
=
data
;
}
...
...
@@ -146,12 +146,12 @@ public class Data {
* @param s the value
* @return the length
*/
public
int
getStringLen
(
String
s
)
{
public
static
int
getStringLen
(
String
s
)
{
int
len
=
s
.
length
();
return
getStringWithoutLengthLen
(
s
,
len
)
+
getVarIntLen
(
len
);
}
p
rivate
int
getStringWithoutLengthLen
(
String
s
,
int
len
)
{
p
ublic
static
int
getStringWithoutLengthLen
(
String
s
,
int
len
)
{
int
plus
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
...
...
@@ -299,6 +299,15 @@ public class Data {
pos
+=
len
;
}
/**
* Append a number of bytes to this buffer.
*
* @param buff the data
*/
public
void
write
(
byte
[]
buff
)
{
write
(
buff
,
0
,
buff
.
length
);
}
/**
* Copy a number of bytes to the given buffer from the current position. The
* current position is incremented accordingly.
...
...
@@ -312,6 +321,16 @@ public class Data {
pos
+=
len
;
}
/**
* Copy a number of bytes to the given buffer from the current position. The
* current position is incremented accordingly.
*
* @param buff the output buffer
*/
public
void
read
(
byte
[]
buff
)
{
read
(
buff
,
0
,
buff
.
length
);
}
/**
* Append one single byte.
*
...
...
@@ -326,7 +345,7 @@ public class Data {
*
* @return the value
*/
public
int
readByte
()
{
public
byte
readByte
()
{
return
data
[
pos
++];
}
...
...
@@ -563,9 +582,9 @@ public class Data {
DbException
.
throwInternalError
(
"type="
+
v
.
getType
());
}
if
(
SysProperties
.
CHECK2
)
{
if
(
pos
-
start
!=
getValueLen
(
v
))
{
if
(
pos
-
start
!=
getValueLen
(
v
,
handler
))
{
throw
DbException
.
throwInternalError
(
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
));
.
throwInternalError
(
"value size error: got "
+
(
pos
-
start
)
+
" expected "
+
getValueLen
(
v
,
handler
));
}
}
}
...
...
@@ -596,9 +615,9 @@ public class Data {
case
Value
.
LONG
:
return
ValueLong
.
get
(
readVarLong
());
case
Value
.
BYTE
:
return
ValueByte
.
get
(
(
byte
)
readByte
());
return
ValueByte
.
get
(
readByte
());
case
Value
.
SHORT
:
return
ValueShort
.
get
(
(
short
)
readShortInt
());
return
ValueShort
.
get
(
readShortInt
());
case
DECIMAL_0_1:
return
(
ValueDecimal
)
ValueDecimal
.
ZERO
;
case
DECIMAL_0_1
+
1
:
...
...
@@ -724,10 +743,21 @@ public class Data {
* @return the number of bytes required to store this value
*/
public
int
getValueLen
(
Value
v
)
{
return
getValueLen2
(
v
)
+
TEST_OFFSET
;
return
getValueLen
(
v
,
handler
);
}
/**
* Calculate the number of bytes required to encode the given value.
*
* @param v the value
* @param handler the data handler for lobs
* @return the number of bytes required to store this value
*/
public
static
int
getValueLen
(
Value
v
,
DataHandler
handler
)
{
return
getValueLen2
(
v
,
handler
)
+
TEST_OFFSET
;
}
private
int
getValueLen2
(
Value
v
)
{
private
static
int
getValueLen2
(
Value
v
,
DataHandler
handler
)
{
if
(
v
==
ValueNull
.
INSTANCE
)
{
return
1
;
}
...
...
@@ -868,7 +898,7 @@ public class Data {
Value
[]
list
=
((
ValueArray
)
v
).
getList
();
int
len
=
1
+
getVarIntLen
(
list
.
length
);
for
(
Value
x
:
list
)
{
len
+=
getValueLen
(
x
);
len
+=
getValueLen
(
x
,
handler
);
}
return
len
;
}
...
...
@@ -904,9 +934,9 @@ public class Data {
*
* @return the value
*/
public
in
t
readShortInt
()
{
public
shor
t
readShortInt
()
{
byte
[]
buff
=
data
;
return
(
(
buff
[
pos
++]
&
0xff
)
<<
8
)
+
(
buff
[
pos
++]
&
0xff
);
return
(
short
)
(((
buff
[
pos
++]
&
0xff
)
<<
8
)
+
(
buff
[
pos
++]
&
0xff
)
);
}
/**
...
...
@@ -929,7 +959,7 @@ public class Data {
* @param x the value
* @return the len
*/
p
rivate
int
getVarIntLen
(
int
x
)
{
p
ublic
static
int
getVarIntLen
(
int
x
)
{
if
((
x
&
(-
1
<<
7
))
==
0
)
{
return
1
;
}
else
if
((
x
&
(-
1
<<
14
))
==
0
)
{
...
...
@@ -995,7 +1025,7 @@ public class Data {
* @param x the value
* @return the len
*/
public
int
getVarLongLen
(
long
x
)
{
public
static
int
getVarLongLen
(
long
x
)
{
int
i
=
1
;
while
(
true
)
{
x
>>>=
7
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论