summaryrefslogtreecommitdiff
blob: 1c21dbe09ff5e7e4d8c346a4da37c16c649b7f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
diff -ur leveldb-1.9.0.orig/db/db_test.cc leveldb-1.9.0/db/db_test.cc
--- leveldb-1.9.0.orig/db/db_test.cc	2013-01-07 21:07:29.000000000 +0000
+++ leveldb-1.9.0/db/db_test.cc	2014-03-28 22:58:59.000000000 +0000
@@ -139,7 +139,7 @@
 
     Status s = target()->NewWritableFile(f, r);
     if (s.ok()) {
-      if (strstr(f.c_str(), ".sst") != NULL) {
+      if (strstr(f.c_str(), ".sst") != NULL || strstr(f.c_str(), ".ldb") != NULL) {
         *r = new SSTableFile(this, *r);
       } else if (strstr(f.c_str(), "MANIFEST") != NULL) {
         *r = new ManifestFile(this, *r);
diff -ur leveldb-1.9.0.orig/db/filename.cc leveldb-1.9.0/db/filename.cc
--- leveldb-1.9.0.orig/db/filename.cc	2013-01-07 21:07:29.000000000 +0000
+++ leveldb-1.9.0/db/filename.cc	2014-03-28 23:07:48.000000000 +0000
@@ -34,6 +34,11 @@
   return MakeFileName(name, number, "sst");
 }
 
+std::string LDBTableFileName(const std::string& name, uint64_t number) {
+  assert(number > 0);
+  return MakeFileName(name, number, "ldb");
+}
+
 std::string DescriptorFileName(const std::string& dbname, uint64_t number) {
   assert(number > 0);
   char buf[100];
@@ -106,7 +111,7 @@
     Slice suffix = rest;
     if (suffix == Slice(".log")) {
       *type = kLogFile;
-    } else if (suffix == Slice(".sst")) {
+    } else if (suffix == Slice(".sst") || suffix == Slice(".ldb")) {
       *type = kTableFile;
     } else if (suffix == Slice(".dbtmp")) {
       *type = kTempFile;
diff -ur leveldb-1.9.0.orig/db/filename.h leveldb-1.9.0/db/filename.h
--- leveldb-1.9.0.orig/db/filename.h	2013-01-07 21:07:29.000000000 +0000
+++ leveldb-1.9.0/db/filename.h	2014-03-28 23:07:43.000000000 +0000
@@ -36,6 +36,7 @@
 // in the db named by "dbname".  The result will be prefixed with
 // "dbname".
 extern std::string TableFileName(const std::string& dbname, uint64_t number);
+extern std::string LDBTableFileName(const std::string& dbname, uint64_t number);
 
 // Return the name of the descriptor file for the db named by
 // "dbname" and the specified incarnation number.  The result will be
diff -ur leveldb-1.9.0.orig/db/repair.cc leveldb-1.9.0/db/repair.cc
--- leveldb-1.9.0.orig/db/repair.cc	2013-01-07 21:07:29.000000000 +0000
+++ leveldb-1.9.0/db/repair.cc	2014-03-28 23:13:28.000000000 +0000
@@ -263,6 +263,14 @@
     std::string fname = TableFileName(dbname_, t->meta.number);
     int counter = 0;
     Status status = env_->GetFileSize(fname, &t->meta.file_size);
+    if (!status.ok()) {
+      // Try alternate file name.
+      fname = LDBTableFileName(dbname_, t->meta.number);
+      Status s2 = env_->GetFileSize(fname, &t->meta.file_size);
+      if (s2.ok()) {
+        status = Status::OK();
+      }
+    }
     if (status.ok()) {
       Iterator* iter = table_cache_->NewIterator(
           ReadOptions(), t->meta.number, t->meta.file_size);
diff -ur leveldb-1.9.0.orig/db/table_cache.cc leveldb-1.9.0/db/table_cache.cc
--- leveldb-1.9.0.orig/db/table_cache.cc	2013-01-07 21:07:29.000000000 +0000
+++ leveldb-1.9.0/db/table_cache.cc	2014-03-28 23:12:39.000000000 +0000
@@ -54,6 +54,12 @@
     RandomAccessFile* file = NULL;
     Table* table = NULL;
     s = env_->NewRandomAccessFile(fname, &file);
+    if (!s.ok()) {
+      std::string ldb_fname = LDBTableFileName(dbname_, file_number);
+      if (env_->NewRandomAccessFile(ldb_fname, &file).ok()) {
+        s = Status::OK();
+      }
+    }
     if (s.ok()) {
       s = Table::Open(*options_, file, file_size, &table);
     }