Skip to content

Commit

Permalink
ArrayDeviceTimeIndex does not update minStartTime and maxEndTime & Re…
Browse files Browse the repository at this point in the history
…ading old version resource file with mods file may cause error
  • Loading branch information
shuwenwei committed Jan 8, 2025
1 parent 2669666 commit f83d0a1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,12 @@ private boolean isOverlap(
TsFileResourceCandidate candidate2,
boolean loadDeviceTimeIndex)
throws IOException {
if (candidate1.resource.getFileStartTime() > candidate1.resource.getFileEndTime()) {
System.out.println("1");
}
if (candidate2.resource.getFileStartTime() > candidate2.resource.getFileEndTime()) {
System.out.println("1");
}
TimeRange timeRangeOfFile1 =
new TimeRange(
candidate1.resource.getFileStartTime(), candidate1.resource.getFileEndTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ public void deserialize() throws IOException {

if (inputStream.available() > 0) {
String modFilePath = ReadWriteIOUtils.readString(inputStream);
if (modFilePath != null && !modFilePath.isEmpty()) {
// ends with ".mods2" means it is a new version resource file
if (modFilePath != null && modFilePath.endsWith(ModificationFile.FILE_SUFFIX)) {
sharedModFileOffset = ReadWriteIOUtils.readLong(inputStream);
if (sharedModFilePathFuture != null) {
sharedModFilePathFuture.complete(modFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public ArrayDeviceTimeIndex(
this.startTimes = startTimes;
this.endTimes = endTimes;
this.deviceToIndex = deviceToIndex;
for (Integer index : deviceToIndex.values()) {
this.minStartTime = Math.min(minStartTime, startTimes[index]);
this.maxEndTime = Math.max(maxEndTime, endTimes[index]);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
Expand All @@ -54,6 +55,15 @@ public void tearDown() throws IOException, StorageEngineException {
super.tearDown();
}

@Test
public void test1() throws IOException {
File file =
new File(
"/Users/shuww/Downloads/0108/data/unsequence/root.local/1/2858/1728981000065-11-0-0.tsfile");
TsFileResource resource = new TsFileResource(file);
resource.deserialize();
}

@Test
public void testScanNormalFile() throws IOException {
TsFileResource resource = createEmptyFileAndResource(true);
Expand Down

0 comments on commit f83d0a1

Please sign in to comment.