зеркало из https://github.com/golang/leveldb.git
leveldb: change the table file extension from .sst to .ldb, as per
the C++ leveldb project. https://groups.google.com/forum/#!topic/leveldb/u9izbG-pDis R=bradfitz, adg CC=golang-dev https://codereview.appspot.com/20170043
This commit is contained in:
Родитель
b173038db4
Коммит
c6c9caddd9
|
@ -644,7 +644,7 @@ func TestCompaction(t *testing.T) {
|
|||
t.Errorf("%q: mem: got %q, want %q", tc.key, gotMem, tc.wantMem)
|
||||
}
|
||||
if gotDisk != tc.wantDisk {
|
||||
t.Errorf("%q: sst: got %q, want %q", tc.key, gotDisk, tc.wantDisk)
|
||||
t.Errorf("%q: ldb: got %q, want %q", tc.key, gotDisk, tc.wantDisk)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ const (
|
|||
fileTypeLog fileType = iota
|
||||
fileTypeLock
|
||||
fileTypeTable
|
||||
fileTypeOldFashionedTable
|
||||
fileTypeManifest
|
||||
fileTypeCurrent
|
||||
)
|
||||
|
@ -34,6 +35,8 @@ func dbFilename(dirname string, fileType fileType, fileNum uint64) string {
|
|||
case fileTypeLock:
|
||||
return fmt.Sprintf("%s%cLOCK", dirname, os.PathSeparator)
|
||||
case fileTypeTable:
|
||||
return fmt.Sprintf("%s%c%06d.ldb", dirname, os.PathSeparator, fileNum)
|
||||
case fileTypeOldFashionedTable:
|
||||
return fmt.Sprintf("%s%c%06d.sst", dirname, os.PathSeparator, fileNum)
|
||||
case fileTypeManifest:
|
||||
return fmt.Sprintf("%s%cMANIFEST-%06d", dirname, os.PathSeparator, fileNum)
|
||||
|
@ -66,10 +69,12 @@ func parseDBFilename(filename string) (fileType fileType, fileNum uint64, ok boo
|
|||
break
|
||||
}
|
||||
switch filename[i+1:] {
|
||||
case "ldb":
|
||||
return fileTypeTable, u, true
|
||||
case "log":
|
||||
return fileTypeLog, u, true
|
||||
case "sst":
|
||||
return fileTypeTable, u, true
|
||||
return fileTypeOldFashionedTable, u, true
|
||||
}
|
||||
}
|
||||
return 0, 0, false
|
||||
|
|
|
@ -16,7 +16,9 @@ func TestParseDBFilename(t *testing.T) {
|
|||
"000000..log": false,
|
||||
"a000000.log": false,
|
||||
"abcdef.log": false,
|
||||
"000001.sst": true,
|
||||
"000001ldb": false,
|
||||
"000001.ldb": true,
|
||||
"000002.sst": true,
|
||||
"CURRENT": true,
|
||||
"CURRaNT": false,
|
||||
"LOCK": true,
|
||||
|
@ -42,9 +44,10 @@ func TestFilenameRoundTrip(t *testing.T) {
|
|||
fileTypeCurrent: false,
|
||||
fileTypeLock: false,
|
||||
// The remaining file types are numbered.
|
||||
fileTypeLog: true,
|
||||
fileTypeManifest: true,
|
||||
fileTypeTable: true,
|
||||
fileTypeLog: true,
|
||||
fileTypeManifest: true,
|
||||
fileTypeOldFashionedTable: true,
|
||||
fileTypeTable: true,
|
||||
}
|
||||
for fileType, numbered := range testCases {
|
||||
fileNums := []uint64{0}
|
||||
|
|
|
@ -637,7 +637,7 @@ func (d *DB) deleteObsoleteFiles() {
|
|||
keep = fileNum >= logNumber
|
||||
case fileTypeManifest:
|
||||
keep = fileNum >= manifestFileNumber
|
||||
case fileTypeTable:
|
||||
case fileTypeTable, fileTypeOldFashionedTable:
|
||||
_, keep = liveFileNums[fileNum]
|
||||
}
|
||||
if keep {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package leveldb
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"code.google.com/p/leveldb-go/leveldb/db"
|
||||
|
@ -148,7 +149,12 @@ type tableCacheNode struct {
|
|||
}
|
||||
|
||||
func (n *tableCacheNode) load(c *tableCache) {
|
||||
// Try opening the fileTypeTable first. If that file doesn't exist,
|
||||
// fall back onto the fileTypeOldFashionedTable.
|
||||
f, err := c.fs.Open(dbFilename(c.dirname, fileTypeTable, n.fileNum))
|
||||
if os.IsNotExist(err) {
|
||||
f, err = c.fs.Open(dbFilename(c.dirname, fileTypeOldFashionedTable, n.fileNum))
|
||||
}
|
||||
if err != nil {
|
||||
n.result <- tableReaderOrError{err: err}
|
||||
return
|
||||
|
|
Загрузка…
Ссылка в новой задаче