3030import org .apache .iotdb .db .exception .StorageEngineException ;
3131import org .apache .iotdb .db .schemaengine .table .DataNodeTableCache ;
3232import org .apache .iotdb .db .storageengine .dataregion .Base32ObjectPath ;
33+ import org .apache .iotdb .db .storageengine .dataregion .DataRegion ;
3334import org .apache .iotdb .db .storageengine .dataregion .IObjectPath ;
3435import org .apache .iotdb .db .storageengine .dataregion .PlainObjectPath ;
3536import org .apache .iotdb .db .storageengine .dataregion .compaction .AbstractCompactionTest ;
@@ -260,13 +261,17 @@ public void testSettleCompaction() throws IOException, WriteProcessException {
260261 }
261262
262263 @ Test
263- public void testTTLCheck () throws IOException {
264+ public void testBase32ObjectPathTTLCheck () throws IOException {
264265 config .setRestrictObjectLimit (false );
265266 try {
266- File file1 = generateBase32ObjectFile (regionDir , System .currentTimeMillis () + 100000 , false );
267- File file2 = generateBase32ObjectFile (regionDir , System .currentTimeMillis () + 200000 , true );
268- File file3 = generateBase32ObjectFile (regionDir , System .currentTimeMillis () - 100000 , true );
269- File file4 = generateBase32ObjectFile (regionDir , System .currentTimeMillis () - 200000 , false );
267+ File file1 =
268+ generateBase32PathObjectFile (regionDir , System .currentTimeMillis () + 100000 , false );
269+ File file2 =
270+ generateBase32PathObjectFile (regionDir , System .currentTimeMillis () + 200000 , true );
271+ File file3 =
272+ generateBase32PathObjectFile (regionDir , System .currentTimeMillis () - 100000 , true );
273+ File file4 =
274+ generateBase32PathObjectFile (regionDir , System .currentTimeMillis () - 200000 , false );
270275 Assert .assertTrue (file1 .exists ());
271276 Assert .assertTrue (file2 .exists ());
272277 Assert .assertTrue (file3 .exists ());
@@ -281,6 +286,39 @@ public void testTTLCheck() throws IOException {
281286 }
282287 }
283288
289+ @ Test
290+ public void testPlainObjectPathTTLCheck () throws IOException , InterruptedException {
291+ File file1 =
292+ generatePlainPathObjectFile (regionDir , System .currentTimeMillis () + 100000 , false , "d1" );
293+ File file2 =
294+ generatePlainPathObjectFile (
295+ regionDir ,
296+ System .currentTimeMillis () + 200000 ,
297+ true ,
298+ (System .currentTimeMillis () - 100000 ) + ".bin" );
299+ File file3 =
300+ generatePlainPathObjectFile (regionDir , System .currentTimeMillis () - 100000 , true , "d1" );
301+ File file4 =
302+ generatePlainPathObjectFile (regionDir , System .currentTimeMillis () - 200000 , false , "d1" );
303+ File file5 =
304+ generatePlainPathObjectFile (
305+ regionDir ,
306+ System .currentTimeMillis () + 300000 ,
307+ false ,
308+ (System .currentTimeMillis () - 300000 ) + ".bin" );
309+ Assert .assertTrue (file1 .exists ());
310+ Assert .assertTrue (file2 .exists ());
311+ Assert .assertTrue (file3 .exists ());
312+ Assert .assertTrue (file4 .exists ());
313+ Assert .assertTrue (file5 .exists ());
314+ new DataRegion (COMPACTION_TEST_SG , regionDir .getName ()).executeTTLCheckForObjectFiles ();
315+ Assert .assertTrue (file1 .exists ());
316+ Assert .assertTrue (file2 .exists ());
317+ Assert .assertFalse (file3 .exists ());
318+ Assert .assertFalse (file4 .exists ());
319+ Assert .assertTrue (file5 .exists ());
320+ }
321+
284322 @ Test
285323 public void testPlainObjectBinaryReplaceRegionId () {
286324 IObjectPath objectPath = new PlainObjectPath (1 , 0 , new StringArrayDeviceID ("t1.d1" ), "s1" );
@@ -375,7 +413,27 @@ private Pair<TsFileResource, File> generateTsFileAndObject(
375413 return new Pair <>(resource , testFile1 );
376414 }
377415
378- private File generateBase32ObjectFile (File regionDir , long timestamp , boolean internalLevel )
416+ private File generatePlainPathObjectFile (
417+ File regionDir , long timestamp , boolean internalLevel , String tagValue ) throws IOException {
418+ File dir =
419+ new File (
420+ regionDir .getPath ()
421+ + File .separator
422+ + "t1"
423+ + (internalLevel ? "" : (File .separator + tagValue ))
424+ + File .separator
425+ + "s1" );
426+ dir .mkdirs ();
427+ File testFile1 = new File (dir , timestamp + ".bin" );
428+ byte [] content = new byte [100 ];
429+ for (int i = 0 ; i < 100 ; i ++) {
430+ content [i ] = (byte ) i ;
431+ }
432+ Files .write (testFile1 .toPath (), content );
433+ return testFile1 ;
434+ }
435+
436+ private File generateBase32PathObjectFile (File regionDir , long timestamp , boolean internalLevel )
379437 throws IOException {
380438 File dir =
381439 new File (
0 commit comments