From 774964fb37f9a1d57b7e6f51d7a176ee96a2ec03 Mon Sep 17 00:00:00 2001 From: Hamid Ghaf <83242695+hghaf099@users.noreply.github.com> Date: Wed, 8 Nov 2023 12:40:01 -0800 Subject: [PATCH] Fix segment path (#37) * fix segment path * remove a degug log * remove an interface --- segment/writer.go | 1 - wal.go | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/segment/writer.go b/segment/writer.go index c344de9..3e67cc6 100644 --- a/segment/writer.go +++ b/segment/writer.go @@ -413,7 +413,6 @@ func (w *Writer) appendIndex() error { // Record the file offset where the index starts (the actual index data so // after the frame header). w.writer.indexStart = uint64(w.writer.writeOffset) + uint64(startOff+frameHeaderLen) - fmt.Println("Hamid - in appendIndex - index start of the write is: ", w.writer.indexStart) return nil } diff --git a/wal.go b/wal.go index 0453b25..aba5760 100644 --- a/wal.go +++ b/wal.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "os" + "path/filepath" "sync" "sync/atomic" "time" @@ -349,10 +350,6 @@ func (w *WAL) GetLog(index uint64, log *raft.Log) error { return w.codec.Decode(raw.Bs, log) } -type ArchiverInterface interface { - GetSealedLogFiles(fromIndex uint64) ([]*SealedSegmentInfo, error) -} - type SealedSegmentInfo struct { Path string LogCount uint64 @@ -382,12 +379,10 @@ func (w *WAL) GetSealedLogFiles(fromIndex uint64) ([]*SealedSegmentInfo, error) for !it.Done() { _, seg, ok := it.Prev() if !ok { - fmt.Println("break ", seg.BaseIndex, seg.MaxIndex, seg.IndexStart) break } // if the segment sealTime is zero, it means that the segment has not been sealed yet if seg.SealTime.IsZero() { - fmt.Println("Continue....segment unseal", seg.BaseIndex, seg.MinIndex) continue } @@ -396,7 +391,7 @@ func (w *WAL) GetSealedLogFiles(fromIndex uint64) ([]*SealedSegmentInfo, error) // target index also include that. if ok && seg.MinIndex >= fromIndex || seg.MaxIndex >= fromIndex { sealedSegInfo = append(sealedSegInfo, &SealedSegmentInfo{ - Path: seg.FileName(), + Path: filepath.Join(w.dir, seg.FileName()), MinIndex: seg.MinIndex, LogCount: (seg.MaxIndex - seg.MinIndex) + 1, // including the maxIndex })