Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
988fa69b
提交
988fa69b
authored
7 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move compareNotNullSigned() and compareNotNullUnsigned() to Bits
to utilize vectorized implementation on Java 9+
上级
2f4fbec0
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
112 行增加
和
60 行删除
+112
-60
Bits.class
h2/src/java9/precompiled/org/h2/util/Bits.class
+0
-0
Bits.java
h2/src/java9/src/org/h2/util/Bits.java
+41
-0
Bits.java
h2/src/main/org/h2/util/Bits.java
+62
-0
Utils.java
h2/src/main/org/h2/util/Utils.java
+0
-54
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+3
-2
ValueJavaObject.java
h2/src/main/org/h2/value/ValueJavaObject.java
+2
-2
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+2
-1
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-1
没有找到文件。
h2/src/java9/precompiled/org/h2/util/Bits.class
浏览文件 @
988fa69b
No preview for this file type
This diff is collapsed.
Click to expand it.
h2/src/java9/src/org/h2/util/Bits.java
浏览文件 @
988fa69b
...
...
@@ -8,6 +8,7 @@ package org.h2.util;
import
java.lang.invoke.MethodHandles
;
import
java.lang.invoke.VarHandle
;
import
java.nio.ByteOrder
;
import
java.util.Arrays
;
import
java.util.UUID
;
/**
...
...
@@ -28,6 +29,46 @@ public final class Bits {
*/
private
static
final
VarHandle
LONG_VH
=
MethodHandles
.
byteArrayViewVarHandle
(
long
[].
class
,
ByteOrder
.
BIG_ENDIAN
);
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
return
Integer
.
signum
(
Arrays
.
compare
(
data1
,
data2
));
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
return
Integer
.
signum
(
Arrays
.
compareUnsigned
(
data1
,
data2
));
}
/**
* Reads a int value from the byte array at the given position in big-endian
* order.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Bits.java
浏览文件 @
988fa69b
...
...
@@ -20,6 +20,68 @@ public final class Bits {
* h2/src/java9/precompiled/org/h2/util/Bits.class.
*/
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
byte
b
=
data1
[
i
];
byte
b2
=
data2
[
i
];
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
b
=
data1
[
i
]
&
0xff
;
int
b2
=
data2
[
i
]
&
0xff
;
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Reads a int value from the byte array at the given position in big-endian
* order.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Utils.java
浏览文件 @
988fa69b
...
...
@@ -138,60 +138,6 @@ public class Utils {
return
bits
==
0
;
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as signed.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
byte
b
=
data1
[
i
];
byte
b2
=
data2
[
i
];
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as unsigned.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
b
=
data1
[
i
]
&
0xff
;
int
b2
=
data2
[
i
]
&
0xff
;
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Copy the contents of the source array to the target array. If the size if
* the target array is too small, a larger array is created.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
988fa69b
...
...
@@ -10,6 +10,7 @@ import java.sql.SQLException;
import
java.util.Arrays
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.Bits
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
...
...
@@ -93,9 +94,9 @@ public class ValueBytes extends Value {
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
if
(
mode
.
isBinaryUnsigned
())
{
return
Util
s
.
compareNotNullUnsigned
(
value
,
v2
);
return
Bit
s
.
compareNotNullUnsigned
(
value
,
v2
);
}
return
Util
s
.
compareNotNullSigned
(
value
,
v2
);
return
Bit
s
.
compareNotNullSigned
(
value
,
v2
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueJavaObject.java
浏览文件 @
988fa69b
...
...
@@ -11,6 +11,7 @@ import java.sql.Types;
import
org.h2.engine.SysProperties
;
import
org.h2.store.DataHandler
;
import
org.h2.util.Bits
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.Utils
;
...
...
@@ -131,8 +132,7 @@ public class ValueJavaObject extends ValueBytes {
if
(
o1
.
equals
(
o2
))
{
return
0
;
}
return
Utils
.
compareNotNullSigned
(
getBytesNoCopy
(),
v
.
getBytesNoCopy
());
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v
.
getBytesNoCopy
());
}
return
h1
>
h2
?
1
:
-
1
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
988fa69b
...
...
@@ -26,6 +26,7 @@ import org.h2.store.FileStoreOutputStream;
import
org.h2.store.RangeInputStream
;
import
org.h2.store.RangeReader
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.Bits
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.SmallLRUCache
;
...
...
@@ -674,7 +675,7 @@ public class ValueLob extends Value {
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
}
byte
[]
v2
=
v
.
getBytesNoCopy
();
return
Utils
.
compareNotNullSigned
(
getBytes
(),
v2
);
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v2
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
988fa69b
...
...
@@ -27,6 +27,7 @@ import org.h2.store.LobStorageFrontend;
import
org.h2.store.LobStorageInterface
;
import
org.h2.store.RangeReader
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.Bits
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StringUtils
;
...
...
@@ -363,7 +364,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
}
byte
[]
v2
=
v
.
getBytesNoCopy
();
return
Utils
.
compareNotNullSigned
(
getBytes
(),
v2
);
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v2
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论