@@ -1024,7 +1024,7 @@ void testCommitHookClear() throws TidesDBException {
10241024 return 0 ;
10251025 });
10261026
1027- // First commit — hook should fire
1027+ // First commit - hook should fire
10281028 try (Transaction txn = db .beginTransaction ()) {
10291029 txn .put (cf , "key1" .getBytes (), "value1" .getBytes ());
10301030 txn .commit ();
@@ -1034,7 +1034,7 @@ void testCommitHookClear() throws TidesDBException {
10341034 // Clear the hook
10351035 cf .clearCommitHook ();
10361036
1037- // Second commit — hook should NOT fire
1037+ // Second commit - hook should NOT fire
10381038 try (Transaction txn = db .beginTransaction ()) {
10391039 txn .put (cf , "key2" .getBytes (), "value2" .getBytes ());
10401040 txn .commit ();
@@ -1505,21 +1505,91 @@ void testTransactionResetNullIsolation() throws TidesDBException {
15051505 .blockCacheSize (64 * 1024 * 1024 )
15061506 .maxOpenSSTables (256 )
15071507 .build ();
1508-
1508+
15091509 try (TidesDB db = TidesDB .open (config )) {
15101510 ColumnFamilyConfig cfConfig = ColumnFamilyConfig .defaultConfig ();
15111511 db .createColumnFamily ("test_cf" , cfConfig );
1512-
1512+
15131513 ColumnFamily cf = db .getColumnFamily ("test_cf" );
1514-
1514+
15151515 Transaction txn = db .beginTransaction ();
15161516 txn .put (cf , "key1" .getBytes (), "value1" .getBytes ());
15171517 txn .commit ();
1518-
1518+
15191519 // Null isolation level should throw IllegalArgumentException
15201520 assertThrows (IllegalArgumentException .class , () -> txn .reset (null ));
1521-
1521+
15221522 txn .free ();
15231523 }
15241524 }
1525+
1526+ @ Test
1527+ @ Order (42 )
1528+ void testTransactionSingleDelete () throws TidesDBException {
1529+ Config config = Config .builder (tempDir .resolve ("testdb_single_delete" ).toString ())
1530+ .numFlushThreads (2 )
1531+ .numCompactionThreads (2 )
1532+ .logLevel (LogLevel .INFO )
1533+ .blockCacheSize (64 * 1024 * 1024 )
1534+ .maxOpenSSTables (256 )
1535+ .build ();
1536+
1537+ try (TidesDB db = TidesDB .open (config )) {
1538+ ColumnFamilyConfig cfConfig = ColumnFamilyConfig .defaultConfig ();
1539+ db .createColumnFamily ("test_cf" , cfConfig );
1540+
1541+ ColumnFamily cf = db .getColumnFamily ("test_cf" );
1542+
1543+ byte [] key = "single_key" .getBytes (StandardCharsets .UTF_8 );
1544+ byte [] value = "single_value" .getBytes (StandardCharsets .UTF_8 );
1545+
1546+ try (Transaction txn = db .beginTransaction ()) {
1547+ txn .put (cf , key , value );
1548+ txn .commit ();
1549+ }
1550+
1551+ try (Transaction txn = db .beginTransaction ()) {
1552+ byte [] result = txn .get (cf , key );
1553+ assertNotNull (result );
1554+ assertArrayEquals (value , result );
1555+ }
1556+
1557+ try (Transaction txn = db .beginTransaction ()) {
1558+ txn .singleDelete (cf , key );
1559+ txn .commit ();
1560+ }
1561+
1562+ try (Transaction txn = db .beginTransaction ()) {
1563+ assertThrows (TidesDBException .class , () -> txn .get (cf , key ));
1564+ }
1565+ }
1566+ }
1567+
1568+ @ Test
1569+ @ Order (43 )
1570+ void testTransactionSingleDeleteNullArgs () throws TidesDBException {
1571+ Config config = Config .builder (tempDir .resolve ("testdb_single_delete_null" ).toString ())
1572+ .numFlushThreads (2 )
1573+ .numCompactionThreads (2 )
1574+ .logLevel (LogLevel .INFO )
1575+ .blockCacheSize (64 * 1024 * 1024 )
1576+ .maxOpenSSTables (256 )
1577+ .build ();
1578+
1579+ try (TidesDB db = TidesDB .open (config )) {
1580+ ColumnFamilyConfig cfConfig = ColumnFamilyConfig .defaultConfig ();
1581+ db .createColumnFamily ("test_cf" , cfConfig );
1582+
1583+ ColumnFamily cf = db .getColumnFamily ("test_cf" );
1584+
1585+ try (Transaction txn = db .beginTransaction ()) {
1586+ assertThrows (IllegalArgumentException .class ,
1587+ () -> txn .singleDelete (null , "k" .getBytes ()));
1588+ assertThrows (IllegalArgumentException .class ,
1589+ () -> txn .singleDelete (cf , null ));
1590+ assertThrows (IllegalArgumentException .class ,
1591+ () -> txn .singleDelete (cf , new byte [0 ]));
1592+ }
1593+ }
1594+ }
15251595}
0 commit comments