Skip to content

Commit

Permalink
Merge pull request #11 from draganm/add-dump-and-filesize-to-sugared-tx
Browse files Browse the repository at this point in the history
add Dump() and FileSize() to sugared read tx
  • Loading branch information
draganm authored Jan 17, 2023
2 parents 2a8e14d + 465aa46 commit 8deb557
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sugared.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bolted

import (
"fmt"
"io"

"github.com/draganm/bolted/dbpath"
)
Expand All @@ -23,6 +24,8 @@ type SugaredReadTx interface {
IsMap(path dbpath.Path) bool
Size(path dbpath.Path) uint64
ID() uint64
Dump(w io.Writer) (n int64)
FileSize() int64
}

type SugaredIterator interface {
Expand Down Expand Up @@ -129,6 +132,22 @@ func (st sugaredReadTx) Size(path dbpath.Path) uint64 {
return sz
}

func (st sugaredReadTx) Dump(w io.Writer) int64 {
n, err := st.tx.Dump(w)
if err != nil {
panic(err)
}
return n
}

func (st sugaredReadTx) FileSize() int64 {
sz, err := st.tx.FileSize()
if err != nil {
panic(err)
}
return sz
}

type sugaredIterator struct {
it Iterator
}
Expand Down

0 comments on commit 8deb557

Please sign in to comment.