Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
57006e2
complete basic arch
xingtanzjr Aug 7, 2023
3d230df
Time range tool (#10808)
caozj1011 Aug 8, 2023
2a70a04
Add Overlap check tool (#10811)
shuwenwei Aug 8, 2023
3fcff18
add chunkgroup level judgement
xingtanzjr Aug 9, 2023
82122e1
Time range tool (#10816)
caozj1011 Aug 9, 2023
a0b82d1
read TsFileResource to get chunk group time index
shuwenwei Aug 9, 2023
d1b8a83
add chunk group overlap judgement
shuwenwei Aug 9, 2023
26a481e
add device statistics in UnseqSpaceStatistics
shuwenwei Aug 9, 2023
8348b47
mvn spotless:apply
shuwenwei Aug 9, 2023
be53c23
modify tsfile overlap judgement
shuwenwei Aug 9, 2023
a0cb1c2
add time cost print
shuwenwei Aug 9, 2023
4c5b7ea
use File.separator instead of '/'
shuwenwei Aug 9, 2023
6f56df4
mvn spotless:apply
shuwenwei Aug 9, 2023
46c879b
add time partition percentage
shuwenwei Aug 9, 2023
f797a0a
fix print
shuwenwei Aug 9, 2023
388ca41
fix a bug of overlap judgement
shuwenwei Aug 9, 2023
fe20621
mvn spotless:apply
shuwenwei Aug 9, 2023
9dd123e
upgrade output log
shuwenwei Aug 9, 2023
b6b3df5
Merge remote-tracking branch 'sww_origin/sww/overlap_check_tool' into…
shuwenwei Aug 9, 2023
858748e
optimize output info
shuwenwei Aug 9, 2023
b89ea08
multi thread
shuwenwei Aug 9, 2023
af631f5
add time partition cost output
shuwenwei Aug 10, 2023
14ffe46
if chunk group not overlap, skip all chunk judgement of it
shuwenwei Aug 10, 2023
7ff3ade
close tsfile resource
shuwenwei Aug 10, 2023
675c565
change constructor when new TsFileResource
shuwenwei Aug 10, 2023
22e1001
add all stage cost output in task
shuwenwei Aug 10, 2023
4ff4a3e
mvn spotless:apply
shuwenwei Aug 10, 2023
6cb0c78
fix a bug
shuwenwei Aug 10, 2023
d3261d9
fix file async
caozj1011 Aug 10, 2023
4e8cf9d
fix file async
caozj1011 Aug 10, 2023
9dd896f
file async
caozj1011 Aug 10, 2023
81a419d
file async
caozj1011 Aug 10, 2023
8a9469e
delete useless line
shuwenwei Aug 14, 2023
d4decdf
fix time cost statistics
shuwenwei Aug 14, 2023
7450d3a
reuse thread executor
shuwenwei Aug 14, 2023
420b2fb
fix bug
shuwenwei Aug 15, 2023
3020e7e
fix bug
shuwenwei Aug 16, 2023
2df06f4
16g
shuwenwei Aug 16, 2023
529389f
modify output
shuwenwei Aug 16, 2023
9e817ba
modify output
shuwenwei Aug 16, 2023
d68027f
Xmx16G
shuwenwei Aug 16, 2023
51f788a
fix file count
shuwenwei Aug 17, 2023
fa032af
add args
shuwenwei Aug 18, 2023
207a29f
add args
shuwenwei Aug 18, 2023
01ab64b
fix
caozj1011 Aug 24, 2023
5fbcd19
format print
caozj1011 Sep 4, 2023
9dc9db3
fix file license header
caozj1011 Sep 4, 2023
47bfc1e
fix annotation
caozj1011 Sep 5, 2023
687d6e6
fix annotation
caozj1011 Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@REM
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM


@echo off
echo ````````````````````````
echo Starting Validating the TsFile
echo ````````````````````````

if "%OS%" == "Windows_NT" setlocal

pushd %~dp0..\..
if NOT DEFINED IOTDB_HOME set IOTDB_HOME=%CD%
popd

if NOT DEFINED MAIN_CLASS set MAIN_CLASS=org.apache.iotdb.db.storageengine.dataregion.compaction.tool.OverlapStatisticTool
if NOT DEFINED JAVA_HOME goto :err

@REM -----------------------------------------------------------------------------
@REM ***** CLASSPATH library setting *****
@REM Ensure that any user defined CLASSPATH variables are not used on startup
set CLASSPATH="%IOTDB_HOME%\lib\*"

goto okClasspath

:append
set CLASSPATH=%CLASSPATH%;%1
goto :eof

@REM -----------------------------------------------------------------------------
:okClasspath

"%JAVA_HOME%\bin\java" -Xmx16G -cp "%CLASSPATH%" %MAIN_CLASS% %*

goto finally


:err
echo JAVA_HOME environment variable must be set!
pause


@REM -----------------------------------------------------------------------------
:finally

ENDLOCAL
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

echo ---------------------
echo Starting Validating the TsFile
echo ---------------------

source "$(dirname "$0")/../../sbin/iotdb-common.sh"
#get_iotdb_include and checkAllVariables is in iotdb-common.sh
VARS=$(get_iotdb_include "$*")
checkAllVariables
export IOTDB_HOME="${IOTDB_HOME}/.."
eval set -- "$VARS"

if [ -n "$JAVA_HOME" ]; then
for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
if [ -x "$java" ]; then
JAVA="$java"
break
fi
done
else
JAVA=java
fi

CLASSPATH=""
for f in ${IOTDB_HOME}/lib/*.jar; do
CLASSPATH=${CLASSPATH}":"$f
done

MAIN_CLASS=org.apache.iotdb.db.storageengine.dataregion.compaction.tool.OverlapStatisticTool

"$JAVA" -Xmx16G -cp "$CLASSPATH" "$MAIN_CLASS" "$@"
exit $?
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.db.storageengine.dataregion.compaction.tool;

public interface ITimeRange {

// Add a time period to the current time range object. The increase process requires maintenance
// of the current TimeRange to facilitate efficient overlap check in the future
void addInterval(Interval interval);

// Determines whether the incoming time range overlaps with the current time range
boolean isOverlapped(Interval interval);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.db.storageengine.dataregion.compaction.tool;

public class Interval {
private long start;
private long end;

public Interval(long start, long end) {
this.start = start;
this.end = end;
if (end < start) {
throw new IllegalArgumentException("end must greater than start");
}
}

public long getStart() {
return start;
}

public long getEnd() {
return end;
}

public void setStart(long start) {
this.start = start;
}

public void setEnd(long end) {
this.end = end;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.db.storageengine.dataregion.compaction.tool;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ListTimeRangeImpl implements ITimeRange {

List<Interval> intervalList = new LinkedList<>();
// 0-10, 20-30, 50-70
// 25-60
// 0-10. 20-70

@Override
public void addInterval(Interval interval) {
List<Interval> mergedIntervals = new ArrayList<>();
int index = 0;

// 1. elements that do not overlap with the newly added element are placed directly in the
// result
while (index < intervalList.size() && intervalList.get(index).getEnd() < interval.getStart()) {
mergedIntervals.add(intervalList.get(index));
index++;
}

// 2. if the element overlaps with an existing element, start equals the minimum value of the
// overlap and end equals the maximum value of the overlap
while (index < intervalList.size() && intervalList.get(index).getStart() <= interval.getEnd()) {
interval.setStart(Math.min(intervalList.get(index).getStart(), interval.getStart()));
interval.setEnd(Math.max(intervalList.get(index).getEnd(), interval.getEnd()));
index++;
}
mergedIntervals.add(interval);

// 3. add the remaining elements to the result set
while (index < intervalList.size()) {
mergedIntervals.add(intervalList.get(index));
index++;
}

intervalList.clear();
intervalList.addAll(mergedIntervals);
}

public List<Interval> getIntervalList() {
return intervalList;
}

/**
* case 1: interval.getStart() <= currentInterval.getEnd()
*
* <p>currentInterval: [5,10], interval: [6,15],[1,7],[0,5],[10,15]
*
* <p>case 2: interval.getEnd() <= currentInterval.getEnd()
*
* <p>currentInterval: [5,10], interval:[1,9],[0,9],[1,10]
*/
@Override
public boolean isOverlapped(Interval interval) {
for (Interval currentInterval : intervalList) {
boolean isOverlap =
interval.getStart() <= currentInterval.getEnd()
&& interval.getEnd() >= currentInterval.getStart();
if (isOverlap) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.db.storageengine.dataregion.compaction.tool;

import java.util.HashSet;

public class OverlapStatistic {
long totalSequenceFile;
long totalSequenceFileSize;
long totalChunkGroupsInSequenceFile;
long totalChunksInSequenceFile;

HashSet<String> sequenceNumber = new HashSet<>();
long sequenceMinStartTime = Long.MAX_VALUE;
long sequenceMaxEndTime = Long.MIN_VALUE;

long totalUnsequenceFile;
long totalUnsequenceFileSize;
long totalChunkGroupsInUnSequenceFile;
long totalChunksInUnSequenceFile;
long unSequenceMinStartTime = Long.MAX_VALUE;
long unSequenceMaxEndTime = Long.MIN_VALUE;

long overlappedSequenceFiles;
long overlappedChunkGroupsInSequenceFile;
long overlappedChunksInSequenceFile;

public void merge(OverlapStatistic other) {
this.totalSequenceFile += other.totalSequenceFile;
this.totalSequenceFileSize += other.totalSequenceFileSize;
this.totalChunkGroupsInSequenceFile += other.totalChunkGroupsInSequenceFile;
this.totalChunksInSequenceFile += other.totalChunksInSequenceFile;
this.sequenceMinStartTime = Math.min(this.sequenceMinStartTime, other.sequenceMinStartTime);
this.sequenceMaxEndTime = Math.max(this.sequenceMaxEndTime, other.sequenceMaxEndTime);

this.totalUnsequenceFile += other.totalUnsequenceFile;
this.totalUnsequenceFileSize += other.totalUnsequenceFileSize;
this.totalChunkGroupsInUnSequenceFile += other.totalChunkGroupsInUnSequenceFile;
this.totalChunksInUnSequenceFile += other.totalChunksInUnSequenceFile;
this.unSequenceMinStartTime =
Math.min(this.unSequenceMinStartTime, other.unSequenceMinStartTime);
this.unSequenceMaxEndTime = Math.max(this.unSequenceMaxEndTime, other.unSequenceMaxEndTime);

this.overlappedSequenceFiles += other.overlappedSequenceFiles;
this.overlappedChunkGroupsInSequenceFile += other.overlappedChunkGroupsInSequenceFile;
this.overlappedChunksInSequenceFile += other.overlappedChunksInSequenceFile;
}

public void mergeSingleSequenceFileTaskResult(SequenceFileTaskSummary summary) {
if (summary.equals(new SequenceFileTaskSummary())) {
return;
}
if (summary.overlapChunkGroup > 0) {
this.overlappedSequenceFiles += 1;
}
this.overlappedChunkGroupsInSequenceFile += summary.overlapChunkGroup;
this.totalChunkGroupsInSequenceFile += summary.totalChunkGroups;
this.overlappedChunksInSequenceFile += summary.overlapChunk;
this.totalChunksInSequenceFile += summary.totalChunks;
this.totalSequenceFile += 1;
this.totalSequenceFileSize += summary.fileSize;
this.sequenceMinStartTime = Math.min(this.sequenceMinStartTime, summary.minStartTime);
this.sequenceMaxEndTime = Math.max(this.sequenceMaxEndTime, summary.maxEndTime);
}

public void mergeUnSeqSpaceStatistics(UnseqSpaceStatistics statistics) {
this.totalUnsequenceFile += statistics.unsequenceFileNum;
this.totalUnsequenceFileSize += statistics.unsequenceFileSize;
this.totalChunksInUnSequenceFile += statistics.unsequenceChunkNum;
this.totalChunkGroupsInUnSequenceFile += statistics.unsequenceChunkGroupNum;
this.unSequenceMinStartTime = Math.min(this.unSequenceMinStartTime, statistics.minStartTime);
this.unSequenceMaxEndTime = Math.max(this.unSequenceMaxEndTime, statistics.maxEndTime);
}
}
Loading