Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
2d469bd5
I
Iotdb
项目概览
apache
/
Iotdb
10 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
2d469bd5
编写于
7月 18, 2023
作者:
H
Haonan
提交者:
HTHou
7月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize the speed of delete by pattern (#10566)
上级
61c22f9f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
60 addition
and
13 deletion
+60
-13
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
.../apache/iotdb/db/storageengine/dataregion/DataRegion.java
+37
-7
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
...db/db/storageengine/dataregion/tsfile/TsFileResource.java
+3
-2
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/DeviceTimeIndex.java
...geengine/dataregion/tsfile/timeindex/DeviceTimeIndex.java
+16
-2
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/FileTimeIndex.java
...rageengine/dataregion/tsfile/timeindex/FileTimeIndex.java
+2
-1
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ITimeIndex.java
...storageengine/dataregion/tsfile/timeindex/ITimeIndex.java
+2
-1
未找到文件。
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java
浏览文件 @
2d469bd5
...
...
@@ -1851,14 +1851,26 @@ public class DataRegion implements IDataRegionForQuery {
List
<
TsFileResource
>
sealedTsFileResource
=
new
ArrayList
<>();
List
<
TsFileResource
>
unsealedTsFileResource
=
new
ArrayList
<>();
separateTsFile
(
sealedTsFileResource
,
unsealedTsFileResource
);
// deviceMatchInfo is used for filter the matched deviceId in TsFileResource
// deviceMatchInfo contains the DeviceId means this device matched the pattern
Set
<
String
>
deviceMatchInfo
=
new
HashSet
<>();
deleteDataInFiles
(
unsealedTsFileResource
,
deletion
,
devicePaths
,
updatedModFiles
,
timePartitionFilter
);
unsealedTsFileResource
,
deletion
,
devicePaths
,
updatedModFiles
,
timePartitionFilter
,
deviceMatchInfo
);
writeUnlock
();
hasReleasedLock
=
true
;
deleteDataInFiles
(
sealedTsFileResource
,
deletion
,
devicePaths
,
updatedModFiles
,
timePartitionFilter
);
sealedTsFileResource
,
deletion
,
devicePaths
,
updatedModFiles
,
timePartitionFilter
,
deviceMatchInfo
);
}
catch
(
Exception
e
)
{
// roll back
...
...
@@ -1916,16 +1928,32 @@ public class DataRegion implements IDataRegionForQuery {
Set
<
PartialPath
>
devicePaths
,
long
deleteStart
,
long
deleteEnd
,
TimePartitionFilter
timePartitionFilter
)
{
TimePartitionFilter
timePartitionFilter
,
Set
<
String
>
deviceMatchInfo
)
{
if
(
timePartitionFilter
!=
null
&&
!
timePartitionFilter
.
satisfy
(
databaseName
,
tsFileResource
.
getTimePartition
()))
{
return
true
;
}
long
fileStartTime
=
tsFileResource
.
getTimeIndex
().
getMinStartTime
();
long
fileEndTime
=
tsFileResource
.
getTimeIndex
().
getMaxEndTime
();
for
(
PartialPath
device
:
devicePaths
)
{
long
deviceStartTime
,
deviceEndTime
;
if
(
device
.
hasWildcard
())
{
Pair
<
Long
,
Long
>
startAndEndTime
=
tsFileResource
.
getPossibleStartTimeAndEndTime
(
device
);
if
(!
tsFileResource
.
isClosed
()
&&
fileEndTime
==
Long
.
MIN_VALUE
)
{
// unsealed seq file
if
(
deleteEnd
<
fileStartTime
)
{
// time range of file has not overlapped with the deletion
return
true
;
}
}
else
{
if
(
deleteEnd
<
fileStartTime
||
deleteStart
>
fileEndTime
)
{
// time range of file has not overlapped with the deletion
return
true
;
}
}
Pair
<
Long
,
Long
>
startAndEndTime
=
tsFileResource
.
getPossibleStartTimeAndEndTime
(
device
,
deviceMatchInfo
);
if
(
startAndEndTime
==
null
)
{
continue
;
}
...
...
@@ -1962,7 +1990,8 @@ public class DataRegion implements IDataRegionForQuery {
Deletion
deletion
,
Set
<
PartialPath
>
devicePaths
,
List
<
ModificationFile
>
updatedModFiles
,
TimePartitionFilter
timePartitionFilter
)
TimePartitionFilter
timePartitionFilter
,
Set
<
String
>
deviceMatchInfo
)
throws
IOException
{
for
(
TsFileResource
tsFileResource
:
tsFileResourceList
)
{
if
(
canSkipDelete
(
...
...
@@ -1970,7 +1999,8 @@ public class DataRegion implements IDataRegionForQuery {
devicePaths
,
deletion
.
getStartTime
(),
deletion
.
getEndTime
(),
timePartitionFilter
))
{
timePartitionFilter
,
deviceMatchInfo
))
{
continue
;
}
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/TsFileResource.java
浏览文件 @
2d469bd5
...
...
@@ -503,8 +503,9 @@ public class TsFileResource {
* Get the min start time and max end time of devices matched by given devicePattern. If there's
* no device matched by given pattern, return null.
*/
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
)
{
return
timeIndex
.
getPossibleStartTimeAndEndTime
(
devicePattern
);
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
,
Set
<
String
>
deviceMatchInfo
)
{
return
timeIndex
.
getPossibleStartTimeAndEndTime
(
devicePattern
,
deviceMatchInfo
);
}
public
boolean
isClosed
()
{
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/DeviceTimeIndex.java
浏览文件 @
2d469bd5
...
...
@@ -23,6 +23,7 @@ import org.apache.iotdb.commons.exception.IllegalPathException;
import
org.apache.iotdb.commons.path.PartialPath
;
import
org.apache.iotdb.commons.utils.SerializeUtils
;
import
org.apache.iotdb.db.exception.PartitionViolationException
;
import
org.apache.iotdb.db.queryengine.plan.analyze.cache.schema.DataNodeDevicePathCache
;
import
org.apache.iotdb.db.storageengine.StorageEngine
;
import
org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource
;
import
org.apache.iotdb.tsfile.utils.FilePathUtils
;
...
...
@@ -377,13 +378,14 @@ public class DeviceTimeIndex implements ITimeIndex {
}
@Override
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
)
{
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
,
Set
<
String
>
deviceMatchInfo
)
{
boolean
hasMatchedDevice
=
false
;
long
startTime
=
Long
.
MAX_VALUE
;
long
endTime
=
Long
.
MIN_VALUE
;
for
(
Entry
<
String
,
Integer
>
entry
:
deviceToIndex
.
entrySet
())
{
try
{
if
(
device
Pattern
.
matchFullPath
(
new
PartialPath
(
entry
.
getKey
()
)))
{
if
(
device
MatchInfo
.
contains
(
entry
.
getKey
(
)))
{
hasMatchedDevice
=
true
;
if
(
startTimes
[
entry
.
getValue
()]
<
startTime
)
{
startTime
=
startTimes
[
entry
.
getValue
()];
...
...
@@ -391,6 +393,18 @@ public class DeviceTimeIndex implements ITimeIndex {
if
(
endTimes
[
entry
.
getValue
()]
>
endTime
)
{
endTime
=
endTimes
[
entry
.
getValue
()];
}
}
else
{
if
(
devicePattern
.
matchFullPath
(
DataNodeDevicePathCache
.
getInstance
().
getPartialPath
(
entry
.
getKey
())))
{
deviceMatchInfo
.
add
(
entry
.
getKey
());
hasMatchedDevice
=
true
;
if
(
startTimes
[
entry
.
getValue
()]
<
startTime
)
{
startTime
=
startTimes
[
entry
.
getValue
()];
}
if
(
endTimes
[
entry
.
getValue
()]
>
endTime
)
{
endTime
=
endTimes
[
entry
.
getValue
()];
}
}
}
}
catch
(
IllegalPathException
e
)
{
// won't reach here
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/FileTimeIndex.java
浏览文件 @
2d469bd5
...
...
@@ -234,7 +234,8 @@ public class FileTimeIndex implements ITimeIndex {
}
@Override
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
)
{
public
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
,
Set
<
String
>
deviceMatchInfo
)
{
return
new
Pair
<>(
startTime
,
endTime
);
}
...
...
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/timeindex/ITimeIndex.java
浏览文件 @
2d469bd5
...
...
@@ -198,7 +198,8 @@ public interface ITimeIndex {
*/
long
[]
getStartAndEndTime
(
String
deviceId
);
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
);
Pair
<
Long
,
Long
>
getPossibleStartTimeAndEndTime
(
PartialPath
devicePattern
,
Set
<
String
>
deviceMatchInfo
);
/**
* Get TimeIndex Type
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录