@@ -147,7 +147,7 @@ class SpecialEnv : public EnvWrapper {
147
147
148
148
Status s = target ()->NewWritableFile (f, r);
149
149
if (s.ok ()) {
150
- if (strstr (f.c_str (), " .sst " ) != NULL ) {
150
+ if (strstr (f.c_str (), " .ldb " ) != NULL ) {
151
151
*r = new SSTableFile (this , *r);
152
152
} else if (strstr (f.c_str (), " MANIFEST" ) != NULL ) {
153
153
*r = new ManifestFile (this , *r);
@@ -484,6 +484,24 @@ class DBTest {
484
484
}
485
485
return false ;
486
486
}
487
+
488
+ // Returns number of files renamed.
489
+ int RenameLDBToSST () {
490
+ std::vector<std::string> filenames;
491
+ ASSERT_OK (env_->GetChildren (dbname_, &filenames));
492
+ uint64_t number;
493
+ FileType type;
494
+ int files_renamed = 0 ;
495
+ for (size_t i = 0 ; i < filenames.size (); i++) {
496
+ if (ParseFileName (filenames[i], &number, &type) && type == kTableFile ) {
497
+ const std::string from = TableFileName (dbname_, number);
498
+ const std::string to = SSTTableFileName (dbname_, number);
499
+ ASSERT_OK (env_->RenameFile (from, to));
500
+ files_renamed++;
501
+ }
502
+ }
503
+ return files_renamed;
504
+ }
487
505
};
488
506
489
507
TEST (DBTest, Empty) {
@@ -1632,6 +1650,22 @@ TEST(DBTest, MissingSSTFile) {
1632
1650
<< s.ToString ();
1633
1651
}
1634
1652
1653
+ TEST (DBTest, StillReadSST) {
1654
+ ASSERT_OK (Put (" foo" , " bar" ));
1655
+ ASSERT_EQ (" bar" , Get (" foo" ));
1656
+
1657
+ // Dump the memtable to disk.
1658
+ dbfull ()->TEST_CompactMemTable ();
1659
+ ASSERT_EQ (" bar" , Get (" foo" ));
1660
+ Close ();
1661
+ ASSERT_GT (RenameLDBToSST (), 0 );
1662
+ Options options = CurrentOptions ();
1663
+ options.paranoid_checks = true ;
1664
+ Status s = TryReopen (&options);
1665
+ ASSERT_TRUE (s.ok ());
1666
+ ASSERT_EQ (" bar" , Get (" foo" ));
1667
+ }
1668
+
1635
1669
TEST (DBTest, FilesDeletedAfterCompaction) {
1636
1670
ASSERT_OK (Put (" foo" , " v2" ));
1637
1671
Compact (" a" , " z" );
0 commit comments