This commit is contained in:
siddontang 2014-11-03 11:22:13 +08:00
parent 014954c3b9
commit 6005467554
2 changed files with 36 additions and 0 deletions

View File

@ -30,7 +30,15 @@ const (
data: log1 data | log2 data | magic data
meta: log1 pos in data | log2 pos in data
log id can not be 0, we use here for magic log
if data has no magic data, it means that we don't close replication gracefully.
so we must repair the log data
magic data = log0 data
we use table to mangage data + meta pair
we must guarantee that the log id is monotonic increment strictly.
if log1's id is 1, log2 must be 2
*/
type FileStore struct {

View File

@ -1 +1,29 @@
package rpl
import (
"fmt"
"os"
"path"
)
type table struct {
baseName string
index int64
readonly bool
df *os.File
mf *os.File
first uint64
last uint64
}
func newReadTable(base string, index int64) (*table, error) {
t := new(table)
t.baseName = path.Join(base, fmt.Sprintf("%08d", index))
t.index = index
return t, nil
}