From 912b7991751a0c05307230de71e56fce7d2cb5e1 Mon Sep 17 00:00:00 2001 From: siddontang Date: Mon, 3 Nov 2014 17:53:46 +0800 Subject: [PATCH] update, water many time...... --- bootstrap.sh | 7 +++---- rpl/file_store.go | 18 ++++++++---------- rpl/file_table.go | 19 +------------------ 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index f546a24..6a2a7a0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -10,20 +10,19 @@ if [ "$?" = 0 ]; then exit 0 fi -go get github.com/siddontang/goleveldb/leveldb - go get github.com/szferi/gomdb go get github.com/boltdb/bolt go get github.com/ugorji/go/codec go get github.com/BurntSushi/toml +go get github.com/edsrzf/mmap-go - +go get github.com/siddontang/goleveldb/leveldb go get github.com/siddontang/go/bson go get github.com/siddontang/go/log go get github.com/siddontang/go/snappy go get github.com/siddontang/go/num go get github.com/siddontang/go/filelock go get github.com/siddontang/go/sync2 -go get github.com/siddontang/go/arena \ No newline at end of file +go get github.com/siddontang/go/arena diff --git a/rpl/file_store.go b/rpl/file_store.go index 127dd19..1c85846 100644 --- a/rpl/file_store.go +++ b/rpl/file_store.go @@ -22,20 +22,18 @@ const ( /* File Store: - 0000001.data - 0000001.meta - 0000002.data - 0000002.meta + 00000001.log + 00000002.log - data: log1 data | log2 data | magic data - meta: log1 pos in data | log2 pos in data + log: log1 data | log2 data | split data | log1 offset | log 2 offset | offset start pos | offset length | magic data - log id can not be 0, we use here for magic log + log id can not be 0, we use here for split data 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 + split data = log0 data + log0: id 0, create time 0, compression 0, data "" + //sha1 of github.com/siddontang/ledisdb 20 bytes + magic data = "\x1c\x1d\xb8\x88\xff\x9e\x45\x55\x40\xf0\x4c\xda\xe0\xce\x47\xde\x65\x48\x71\x17" we must guarantee that the log id is monotonic increment strictly. if log1's id is 1, log2 must be 2 diff --git a/rpl/file_table.go b/rpl/file_table.go index 2a81ebf..92f1309 100644 --- a/rpl/file_table.go +++ b/rpl/file_table.go @@ -1,29 +1,12 @@ package rpl import ( - "fmt" "os" - "path" ) type table struct { - baseName string - - index int64 - - readonly bool - df *os.File - mf *os.File + f *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 -}