Basic file replication working with WAL

This commit is contained in:
Ben Johnson
2020-12-24 13:23:52 -07:00
parent 8d7f5b28a9
commit 341eac268c
3 changed files with 417 additions and 27 deletions

View File

@@ -22,6 +22,26 @@ const (
GenerationNameLen = 16
)
// Pos is a position in the WAL for a generation.
type Pos struct {
Generation string // generation name
Index int // wal file index
Offset int64 // offset within wal file
}
// String returns a string representation.
func (p Pos) String() string {
if p.IsZero() {
return "<>"
}
return fmt.Sprintf("<%s,%d,%d>", p.Generation, p.Index, p.Offset)
}
// IsZero returns true if p is the zero value.
func (p Pos) IsZero() bool {
return p == (Pos{})
}
// Checksum computes a running SQLite checksum over a byte slice.
func Checksum(bo binary.ByteOrder, s0, s1 uint32, b []byte) (uint32, uint32) {
assert(len(b)%8 == 0, "misaligned checksum byte slice")