mirror of
https://github.com/taigrr/bitcask
synced 2026-03-20 19:32:22 -07:00
Add LFU w/ Tests
This commit is contained in:
@@ -25,6 +25,7 @@ var (
|
||||
type Datafile interface {
|
||||
FileID() int
|
||||
Name() string
|
||||
Open() error
|
||||
Close() error
|
||||
Sync() error
|
||||
Size() int64
|
||||
@@ -97,6 +98,22 @@ func NewDatafile(path string, id int, readonly bool, maxKeySize uint32, maxValue
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (df *datafile) Open() error {
|
||||
var err error
|
||||
|
||||
df.r, err = os.Open(df.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
df.ra, err = mmap.Open(df.Name())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (df *datafile) FileID() int {
|
||||
return df.id
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
package mocks
|
||||
|
||||
import internal "github.com/prologic/bitcask/internal"
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
import (
|
||||
internal "github.com/prologic/bitcask/internal"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Datafile is an autogenerated mock type for the Datafile type
|
||||
type Datafile struct {
|
||||
@@ -52,6 +54,20 @@ func (_m *Datafile) Name() string {
|
||||
return r0
|
||||
}
|
||||
|
||||
// Open provides a mock function with given fields:
|
||||
func (_m *Datafile) Open() error {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Read provides a mock function with given fields:
|
||||
func (_m *Datafile) Read() (internal.Entry, int64, error) {
|
||||
ret := _m.Called()
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
package mocks
|
||||
|
||||
import art "github.com/plar/go-adaptive-radix-tree"
|
||||
import (
|
||||
art "github.com/plar/go-adaptive-radix-tree"
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Indexer is an autogenerated mock type for the Indexer type
|
||||
type Indexer struct {
|
||||
|
||||
Reference in New Issue
Block a user