-
Notifications
You must be signed in to change notification settings - Fork 8
/
log_segment.go
50 lines (45 loc) · 1.15 KB
/
log_segment.go
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
package deltago
import (
"time"
"github.com/csimplestring/delta-go/internal/util"
"github.com/csimplestring/delta-go/store"
"github.com/samber/mo"
)
type LogSegment struct {
LogPath string
Version int64
Deltas []*store.FileMeta
Checkpoints []*store.FileMeta
CheckpointVersion mo.Option[int64]
LastCommitTimestamp time.Time
}
func (l *LogSegment) equal(other *LogSegment) bool {
if other == nil {
return false
}
if l.LogPath != other.LogPath ||
l.Version != other.Version ||
l.LastCommitTimestamp.Unix() != other.LastCommitTimestamp.Unix() {
return false
}
if l.CheckpointVersion.OrEmpty() != other.CheckpointVersion.OrEmpty() {
return false
}
if util.MustHash(l.Deltas) != util.MustHash(other.Deltas) {
return false
}
if util.MustHash(l.Checkpoints) != util.MustHash(other.Checkpoints) {
return false
}
return true
}
func emptyLogSegment(logPath string) *LogSegment {
return &LogSegment{
LogPath: logPath,
Version: -1,
Deltas: nil,
Checkpoints: nil,
CheckpointVersion: mo.None[int64](),
LastCommitTimestamp: time.Time{},
}
}