25
25
import org .apache .tsfile .compress .IUnCompressor ;
26
26
import org .apache .tsfile .encoding .decoder .Decoder ;
27
27
import org .apache .tsfile .enums .TSDataType ;
28
+ import org .apache .tsfile .exception .StopReadTsFileByInterruptException ;
28
29
import org .apache .tsfile .exception .TsFileRuntimeException ;
29
30
import org .apache .tsfile .exception .TsFileStatisticsMistakesException ;
30
31
import org .apache .tsfile .file .MetaMarker ;
@@ -298,6 +299,8 @@ public TsFileMetadata readFileMetadata() throws IOException {
298
299
}
299
300
}
300
301
}
302
+ } catch (StopReadTsFileByInterruptException e ) {
303
+ throw e ;
301
304
} catch (Exception e ) {
302
305
logger .error ("Something error happened while reading file metadata of file {}" , file );
303
306
throw e ;
@@ -523,6 +526,8 @@ public List<TimeseriesMetadata> readTimeseriesMetadata(
523
526
TimeseriesMetadata timeseriesMetadata ;
524
527
try {
525
528
timeseriesMetadata = TimeseriesMetadata .deserializeFrom (tsFileInput , true );
529
+ } catch (StopReadTsFileByInterruptException e ) {
530
+ throw e ;
526
531
} catch (Exception e1 ) {
527
532
logger .error (
528
533
"Something error happened while deserializing TimeseriesMetadata of file {}" , file );
@@ -728,6 +733,8 @@ public void getDevicesAndEntriesOfOneLeafNode(
728
733
ByteBuffer nextBuffer = readData (startOffset , endOffset );
729
734
MetadataIndexNode deviceLeafNode = MetadataIndexNode .deserializeFrom (nextBuffer );
730
735
getDevicesOfLeafNode (deviceLeafNode , measurementNodeOffsetQueue );
736
+ } catch (StopReadTsFileByInterruptException e ) {
737
+ throw e ;
731
738
} catch (Exception e ) {
732
739
logger .error ("Something error happened while getting all devices of file {}" , file );
733
740
throw e ;
@@ -795,6 +802,8 @@ private void getAllDeviceLeafNodeOffset(
795
802
getAllDeviceLeafNodeOffset (
796
803
MetadataIndexNode .deserializeFrom (nextBuffer ), leafDeviceNodeOffsets );
797
804
}
805
+ } catch (StopReadTsFileByInterruptException e ) {
806
+ throw e ;
798
807
} catch (Exception e ) {
799
808
logger .error ("Something error happened while getting all devices of file {}" , file );
800
809
throw e ;
@@ -926,6 +935,8 @@ private void getAllPaths(
926
935
metadataIndexNode .getNodeType (),
927
936
queue );
928
937
}
938
+ } catch (StopReadTsFileByInterruptException e ) {
939
+ throw e ;
929
940
} catch (Exception e ) {
930
941
logger .error ("Something error happened while getting all paths of file {}" , file );
931
942
throw e ;
@@ -1144,6 +1155,8 @@ private void generateMetadataIndex(
1144
1155
}
1145
1156
}
1146
1157
}
1158
+ } catch (StopReadTsFileByInterruptException e ) {
1159
+ throw e ;
1147
1160
} catch (Exception e ) {
1148
1161
logger .error ("Something error happened while generating MetadataIndex of file {}" , file );
1149
1162
throw e ;
@@ -1193,6 +1206,8 @@ private void generateMetadataIndexUsingTsFileInput(
1193
1206
needChunkMetadata );
1194
1207
}
1195
1208
}
1209
+ } catch (StopReadTsFileByInterruptException e ) {
1210
+ throw e ;
1196
1211
} catch (Exception e ) {
1197
1212
logger .error ("Something error happened while generating MetadataIndex of file {}" , file );
1198
1213
throw e ;
@@ -1314,6 +1329,8 @@ protected Pair<MetadataIndexEntry, Long> getMetadataAndEndOffset(
1314
1329
return getMetadataAndEndOffset (
1315
1330
MetadataIndexNode .deserializeFrom (buffer ), name , isDeviceLevel , exactSearch );
1316
1331
}
1332
+ } catch (StopReadTsFileByInterruptException e ) {
1333
+ throw e ;
1317
1334
} catch (Exception e ) {
1318
1335
logger .error ("Something error happened while deserializing MetadataIndex of file {}" , file );
1319
1336
throw e ;
@@ -1369,6 +1386,8 @@ public void readPlanIndex() throws IOException {
1369
1386
public ChunkHeader readChunkHeader (byte chunkType ) throws IOException {
1370
1387
try {
1371
1388
return ChunkHeader .deserializeFrom (tsFileInput .wrapAsInputStream (), chunkType );
1389
+ } catch (StopReadTsFileByInterruptException e ) {
1390
+ throw e ;
1372
1391
} catch (Throwable t ) {
1373
1392
logger .warn ("Exception {} happened while reading chunk header of {}" , t .getMessage (), file );
1374
1393
throw t ;
@@ -1383,6 +1402,8 @@ public ChunkHeader readChunkHeader(byte chunkType) throws IOException {
1383
1402
private ChunkHeader readChunkHeader (long position ) throws IOException {
1384
1403
try {
1385
1404
return ChunkHeader .deserializeFrom (tsFileInput , position );
1405
+ } catch (StopReadTsFileByInterruptException e ) {
1406
+ throw e ;
1386
1407
} catch (Throwable t ) {
1387
1408
logger .warn ("Exception {} happened while reading chunk header of {}" , t .getMessage (), file );
1388
1409
throw t ;
@@ -1399,6 +1420,8 @@ private ChunkHeader readChunkHeader(long position) throws IOException {
1399
1420
public ByteBuffer readChunk (long position , int dataSize ) throws IOException {
1400
1421
try {
1401
1422
return readData (position , dataSize );
1423
+ } catch (StopReadTsFileByInterruptException e ) {
1424
+ throw e ;
1402
1425
} catch (Throwable t ) {
1403
1426
logger .warn ("Exception {} happened while reading chunk of {}" , t .getMessage (), file );
1404
1427
throw t ;
@@ -1415,6 +1438,8 @@ public Chunk readMemChunk(long offset) throws IOException {
1415
1438
ChunkHeader header = readChunkHeader (offset );
1416
1439
ByteBuffer buffer = readChunk (offset + header .getSerializedSize (), header .getDataSize ());
1417
1440
return new Chunk (header , buffer );
1441
+ } catch (StopReadTsFileByInterruptException e ) {
1442
+ throw e ;
1418
1443
} catch (Throwable t ) {
1419
1444
logger .warn ("Exception {} happened while reading chunk of {}" , t .getMessage (), file );
1420
1445
throw t ;
@@ -1434,6 +1459,8 @@ public Chunk readMemChunk(ChunkMetadata metaData) throws IOException {
1434
1459
readChunk (
1435
1460
metaData .getOffsetOfChunkHeader () + header .getSerializedSize (), header .getDataSize ());
1436
1461
return new Chunk (header , buffer , metaData .getDeleteIntervalList (), metaData .getStatistics ());
1462
+ } catch (StopReadTsFileByInterruptException e ) {
1463
+ throw e ;
1437
1464
} catch (Throwable t ) {
1438
1465
logger .warn ("Exception {} happened while reading chunk of {}" , t .getMessage (), file );
1439
1466
throw t ;
@@ -1500,6 +1527,8 @@ public MeasurementSchema getMeasurementSchema(List<IChunkMetadata> chunkMetadata
1500
1527
public PageHeader readPageHeader (TSDataType type , boolean hasStatistic ) throws IOException {
1501
1528
try {
1502
1529
return PageHeader .deserializeFrom (tsFileInput .wrapAsInputStream (), type , hasStatistic );
1530
+ } catch (StopReadTsFileByInterruptException e ) {
1531
+ throw e ;
1503
1532
} catch (Throwable t ) {
1504
1533
logger .warn ("Exception {} happened while reading page header of {}" , t .getMessage (), file );
1505
1534
throw t ;
@@ -1618,6 +1647,8 @@ protected ByteBuffer readData(long position, int totalSize) throws IOException {
1618
1647
protected ByteBuffer readData (long start , long end ) throws IOException {
1619
1648
try {
1620
1649
return readData (start , (int ) (end - start ));
1650
+ } catch (StopReadTsFileByInterruptException e ) {
1651
+ throw e ;
1621
1652
} catch (Throwable t ) {
1622
1653
logger .warn ("Exception {} happened while reading data of {}" , t .getMessage (), file );
1623
1654
throw t ;
@@ -1947,6 +1978,8 @@ public long selfCheckWithInfo(
1947
1978
return TsFileCheckStatus .COMPLETE_FILE ;
1948
1979
}
1949
1980
}
1981
+ } catch (StopReadTsFileByInterruptException e ) {
1982
+ throw e ;
1950
1983
} catch (IOException e ) {
1951
1984
logger .error ("Error occurred while fast checking TsFile." );
1952
1985
throw e ;
@@ -1960,6 +1993,8 @@ public long selfCheckWithInfo(
1960
1993
long tscheckStatus = TsFileCheckStatus .COMPLETE_FILE ;
1961
1994
try {
1962
1995
tscheckStatus = checkChunkAndPagesStatistics (chunkMetadata );
1996
+ } catch (StopReadTsFileByInterruptException e ) {
1997
+ throw e ;
1963
1998
} catch (IOException e ) {
1964
1999
logger .error ("Error occurred while checking the statistics of chunk and its pages" );
1965
2000
throw e ;
@@ -2392,6 +2427,8 @@ private void collectEachLeafMeasurementNodeOffsetRange(
2392
2427
}
2393
2428
collectEachLeafMeasurementNodeOffsetRange (readData (startOffset , endOffset ), queue );
2394
2429
}
2430
+ } catch (StopReadTsFileByInterruptException e ) {
2431
+ throw e ;
2395
2432
} catch (Exception e ) {
2396
2433
logger .error (
2397
2434
"Error occurred while collecting offset ranges of measurement nodes of file {}" , file );
0 commit comments