@@ -2766,10 +2766,21 @@ public void deleteByTable(RelationalDeleteDataNode node) throws IOException {
27662766 }
27672767 }
27682768
2769- List <File > matchedObjectDirs =
2769+ List <File > objectTableDirs =
27702770 TierManager .getInstance ().getAllMatchedObjectDirs (dataRegionIdString , tableName );
2771- if (!matchedObjectDirs .isEmpty ()) {
2772- deleteObjectFiles (matchedObjectDirs , modEntries );
2771+ if (!objectTableDirs .isEmpty ()) {
2772+ boolean droppingTable = false ;
2773+ for (TableDeletionEntry entry : modEntries ) {
2774+ if (entry .isDroppingTable ()) {
2775+ for (File objectTableDir : objectTableDirs ) {
2776+ droppingTable = true ;
2777+ FileUtils .deleteQuietly (objectTableDir );
2778+ }
2779+ }
2780+ }
2781+ if (!droppingTable ) {
2782+ deleteObjectFiles (objectTableDirs , modEntries );
2783+ }
27732784 }
27742785
27752786 List <List <TsFileResource >> sealedTsFileResourceLists = new ArrayList <>(modEntries .size ());
@@ -2943,54 +2954,50 @@ private List<WALFlushListener> logDeletionInWAL(
29432954 private void deleteObjectFiles (List <File > matchedObjectDirs , List <TableDeletionEntry > modEntries )
29442955 throws IOException {
29452956 for (File matchedObjectDir : matchedObjectDirs ) {
2946- try (Stream <Path > paths = Files .walk (matchedObjectDir .toPath ())) {
2947- paths
2948- .filter (Files ::isRegularFile )
2949- .filter (
2950- path -> {
2951- String name = path .getFileName ().toString ();
2952- return name .endsWith (".bin" );
2953- })
2954- .forEach (
2955- path -> {
2956- Path relativePath = matchedObjectDir .getParentFile ().toPath ().relativize (path );
2957- String [] ideviceIdSegments = new String [relativePath .getNameCount () - 2 ];
2958- for (int i = 0 ; i < ideviceIdSegments .length ; i ++) {
2959- ideviceIdSegments [i ] =
2960- config .getRestrictObjectLimit ()
2961- ? relativePath .getName (i ).toString ()
2962- : new String (
2963- BaseEncoding .base32 ()
2964- .omitPadding ()
2965- .decode (relativePath .getName (i ).toString ()),
2966- StandardCharsets .UTF_8 );
2967- }
2968- IDeviceID iDeviceID = Factory .DEFAULT_FACTORY .create (ideviceIdSegments );
2969- String measurementId =
2970- config .getRestrictObjectLimit ()
2971- ? relativePath .getName (relativePath .getNameCount () - 2 ).toString ()
2972- : new String (
2973- BaseEncoding .base32 ()
2974- .omitPadding ()
2975- .decode (
2976- relativePath
2977- .getName (relativePath .getNameCount () - 2 )
2978- .toString ()),
2979- StandardCharsets .UTF_8 );
2980- String fileName = path .getFileName ().toString ();
2981- long timestamp = Long .parseLong (fileName .substring (0 , fileName .lastIndexOf ('.' )));
2982- logger .info (
2983- "timestamp {}, measurementId {}, ideviceId {}" ,
2984- timestamp ,
2985- measurementId ,
2986- iDeviceID );
2987- for (TableDeletionEntry modEntry : modEntries ) {
2988- if (modEntry .affects (iDeviceID , timestamp , timestamp )
2989- && modEntry .affects (measurementId )) {
2990- ObjectTypeUtils .deleteObjectPath (path .toFile ());
2991- }
2992- }
2993- });
2957+ try (Stream <Path > paths =
2958+ Files .find (
2959+ matchedObjectDir .toPath (),
2960+ Integer .MAX_VALUE ,
2961+ (path , attrs ) ->
2962+ attrs .isRegularFile () && path .getFileName ().toString ().endsWith (".bin" ))) {
2963+ paths .forEach (
2964+ path -> {
2965+ Path relativePath = matchedObjectDir .getParentFile ().toPath ().relativize (path );
2966+ String [] ideviceIdSegments = new String [relativePath .getNameCount () - 2 ];
2967+ for (int i = 0 ; i < ideviceIdSegments .length ; i ++) {
2968+ ideviceIdSegments [i ] =
2969+ config .getRestrictObjectLimit ()
2970+ ? relativePath .getName (i ).toString ()
2971+ : new String (
2972+ BaseEncoding .base32 ()
2973+ .omitPadding ()
2974+ .decode (relativePath .getName (i ).toString ()),
2975+ StandardCharsets .UTF_8 );
2976+ }
2977+ IDeviceID iDeviceID = Factory .DEFAULT_FACTORY .create (ideviceIdSegments );
2978+ String measurementId =
2979+ config .getRestrictObjectLimit ()
2980+ ? relativePath .getName (relativePath .getNameCount () - 2 ).toString ()
2981+ : new String (
2982+ BaseEncoding .base32 ()
2983+ .omitPadding ()
2984+ .decode (
2985+ relativePath .getName (relativePath .getNameCount () - 2 ).toString ()),
2986+ StandardCharsets .UTF_8 );
2987+ String fileName = path .getFileName ().toString ();
2988+ long timestamp = Long .parseLong (fileName .substring (0 , fileName .lastIndexOf ('.' )));
2989+ logger .info (
2990+ "timestamp {}, measurementId {}, ideviceId {}" ,
2991+ timestamp ,
2992+ measurementId ,
2993+ iDeviceID );
2994+ for (TableDeletionEntry modEntry : modEntries ) {
2995+ if (modEntry .affects (iDeviceID , timestamp , timestamp )
2996+ && modEntry .affects (measurementId )) {
2997+ ObjectTypeUtils .deleteObjectPath (path .toFile ());
2998+ }
2999+ }
3000+ });
29943001 }
29953002 }
29963003 }
0 commit comments