diff options
author | EuAndreh <eu@euandre.org> | 2025-01-24 20:34:56 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-01-24 20:34:56 -0300 |
commit | 848de20da06e2b53d2f3d5114f3a1c43bb0ff523 (patch) | |
tree | 6d67d3fcfdb43b2523e85991422364ea496456f2 | |
parent | src/dedo.go: Remove Stats-related code (diff) | |
download | dedo-848de20da06e2b53d2f3d5114f3a1c43bb0ff523.tar.gz dedo-848de20da06e2b53d2f3d5114f3a1c43bb0ff523.tar.xz |
src/dedo.go: Remove dbops type
-rw-r--r-- | src/dedo.go | 16 | ||||
-rw-r--r-- | tests/dedo.go | 2 |
2 files changed, 3 insertions, 15 deletions
diff --git a/src/dedo.go b/src/dedo.go index 948f579..e93beb3 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -65,10 +65,6 @@ type elemRef struct { index int } -type dbops struct { - writeAt func(b []byte, off int64) (n int, err error) -} - // DB represents a collection of buckets persisted to a file on disk. // All data access is performed through transactions which can be obtained through the DB. // All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called. @@ -123,8 +119,6 @@ type DB struct { rwlock sync.Mutex // Allows only one writer at a time. metalock sync.Mutex // Protects meta page access. mmaplock sync.RWMutex // Protects mmap access during remapping. - - ops dbops } type call struct { @@ -1461,7 +1455,6 @@ func newDB(path string, file *os.File) *DB { opened: true, path: path, file: file, - ops: dbops{writeAt: file.WriteAt}, } } @@ -1548,7 +1541,7 @@ func initDB(db *DB, size int64) error { p.count = 0 // Write the buffer to our data file. - if _, err := db.ops.writeAt(buf, 0); err != nil { + if _, err := db.file.WriteAt(buf, 0); err != nil { return err } if err := fdatasync(db); err != nil { @@ -1730,9 +1723,6 @@ func (db *DB) close() error { db.freelist = nil - // Clear ops. - db.ops.writeAt = nil - // Close the mmap. if err := db.munmap(); err != nil { return err @@ -3542,7 +3532,7 @@ func (tx *Tx) write() error { // Write chunk to disk. buf := ptr[:sz] - if _, err := tx.db.ops.writeAt(buf, offset); err != nil { + if _, err := tx.db.file.WriteAt(buf, offset); err != nil { return err } @@ -3590,7 +3580,7 @@ func (tx *Tx) writeMeta() error { tx.meta.write(p) // Write the meta page to file. - if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { + if _, err := tx.db.file.WriteAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { return err } diff --git a/tests/dedo.go b/tests/dedo.go index 3767d1d..a43a3d2 100644 --- a/tests/dedo.go +++ b/tests/dedo.go @@ -49,8 +49,6 @@ func test_newDB() { db1 := newDB("path", f1) db2 := newDB("path", f2) - g.TAssertEqual(db1.ops.writeAt == nil, false) - g.TAssertEqual(db2.ops.writeAt == nil, false) g.TAssertEqual(db1 == db2, false) }) } |