Skip to content

Commit

Permalink
Merge pull request #407 from ahrtr/refactor_inode_20230215
Browse files Browse the repository at this point in the history
Refactor: move inode to internal/common package
  • Loading branch information
ptabor authored Mar 6, 2023
2 parents 1d1d756 + f68adfe commit 17b1858
Show file tree
Hide file tree
Showing 36 changed files with 1,518 additions and 1,350 deletions.
10 changes: 6 additions & 4 deletions allocate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package bbolt

import (
"testing"

"go.etcd.io/bbolt/internal/common"
)

func TestTx_allocatePageStats(t *testing.T) {
f := newTestFreelist()
ids := []pgid{2, 3}
ids := []common.Pgid{2, 3}
f.readIDs(ids)

tx := &Tx{
db: &DB{
freelist: f,
pageSize: defaultPageSize,
pageSize: common.DefaultPageSize,
},
meta: &meta{},
pages: make(map[pgid]*page),
meta: &common.Meta{},
pages: make(map[common.Pgid]*common.Page),
}

txStats := tx.Stats()
Expand Down
4 changes: 3 additions & 1 deletion bolt_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"unsafe"

"golang.org/x/sys/unix"

"go.etcd.io/bbolt/internal/common"
)

// flock acquires an advisory lock on a file descriptor.
Expand All @@ -36,7 +38,7 @@ func flock(db *DB, exclusive bool, timeout time.Duration) error {

// If we timed out then return an error.
if timeout != 0 && time.Since(t) > timeout-flockRetryTimeout {
return ErrTimeout
return common.ErrTimeout
}

// Wait for a bit and try again.
Expand Down
6 changes: 4 additions & 2 deletions bolt_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"unsafe"

"golang.org/x/sys/windows"

"go.etcd.io/bbolt/internal/common"
)

// fdatasync flushes written data to a file descriptor.
Expand Down Expand Up @@ -42,7 +44,7 @@ func flock(db *DB, exclusive bool, timeout time.Duration) error {

// If we timed oumercit then return an error.
if timeout != 0 && time.Since(t) > timeout-flockRetryTimeout {
return ErrTimeout
return common.ErrTimeout
}

// Wait for a bit and try again.
Expand Down Expand Up @@ -93,7 +95,7 @@ func mmap(db *DB, sz int) error {
}

// Convert to a byte array.
db.data = ((*[maxMapSize]byte)(unsafe.Pointer(addr)))
db.data = (*[maxMapSize]byte)(unsafe.Pointer(addr))
db.datasz = sz

return nil
Expand Down
Loading

0 comments on commit 17b1858

Please sign in to comment.