Skip to content

Commit

Permalink
upgrade go and wal version
Browse files Browse the repository at this point in the history
  • Loading branch information
roseduan committed Oct 6, 2024
1 parent fb79d20 commit 5891889
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 49 deletions.
2 changes: 0 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func Open(options Options) (*DB, error) {
vlog, err := openValueLog(valueLogOptions{
dirPath: options.DirPath,
segmentSize: options.ValueLogFileSize,
blockCache: options.BlockCache,
partitionNum: uint32(options.PartitionNum),
hashKeyFunction: options.KeyHashFunction,
compactBatchCount: options.CompactBatchCount,
Expand Down Expand Up @@ -484,7 +483,6 @@ func (db *DB) Compact() error {
DirPath: db.vlog.options.dirPath,
SegmentSize: db.vlog.options.segmentSize,
SegmentFileExt: fmt.Sprintf(ext, part),
BlockCache: db.vlog.options.blockCache,
Sync: false, // we will sync manually
BytesPerSync: 0, // the same as Sync
})
Expand Down
1 change: 0 additions & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ func TestDBIterator(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
for i := 0; i < 3; i++ {
opts.tableID = uint32(i)
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/lotusdblabs/lotusdb/v2

go 1.19
go 1.21

require (
github.com/bwmarrin/snowflake v0.3.0
github.com/cespare/xxhash/v2 v2.2.0
github.com/dgraph-io/badger/v4 v4.2.0
github.com/gofrs/flock v0.8.1
github.com/rosedblabs/diskhash v0.0.0-20230910084041-289755737e2a
github.com/rosedblabs/wal v1.3.6
github.com/stretchr/testify v1.8.4
github.com/rosedblabs/wal v1.3.8
github.com/stretchr/testify v1.9.0
go.etcd.io/bbolt v1.3.8
golang.org/x/sync v0.5.0
)
Expand All @@ -20,7 +20,6 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/kr/text v0.2.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
Expand All @@ -42,14 +41,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rosedblabs/diskhash v0.0.0-20230910084041-289755737e2a h1:BNp46nsknQivr3Gxzc6ytzG7xtBscBnLYZIkr0UfCko=
github.com/rosedblabs/diskhash v0.0.0-20230910084041-289755737e2a/go.mod h1:3xvIg+7iOFUL/vMCE/6DwE6Yecb0okVYJBEfpdC/E+8=
github.com/rosedblabs/wal v1.3.6 h1:oxZYTPX/u4JuGDW98wQ1YamWqerlrlSUFKhgP6Gd/Ao=
github.com/rosedblabs/wal v1.3.6/go.mod h1:wdq54KJUyVTOv1uddMc6Cdh2d/YCIo8yjcwJAb1RCEM=
github.com/rosedblabs/wal v1.3.8 h1:tErpD9JT/ICiyV3mv5l7qUH6lybn5XF1TbI0e8kvH8M=
github.com/rosedblabs/wal v1.3.8/go.mod h1:DFvhrmTTeiXvn2btXXT2MW9Nvu99PU0g/pKGgh0+T+o=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -90,6 +89,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3 changes: 0 additions & 3 deletions memtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type (
memSize uint32 // max size of the memtable
walBytesPerSync uint32 // flush wal file to disk throughput BytesPerSync parameter
walSync bool // WAL flush immediately after each writing
walBlockCache uint32 // block cache size of wal
}
)

Expand Down Expand Up @@ -91,7 +90,6 @@ func openAllMemtables(options Options) ([]*memtable, error) {
memSize: options.MemtableSize,
walSync: options.Sync,
walBytesPerSync: options.BytesPerSync,
walBlockCache: options.BlockCache,
})
if errOpenMemtable != nil {
return nil, errOpenMemtable
Expand All @@ -116,7 +114,6 @@ func openMemtable(options memtableOptions) (*memtable, error) {
DirPath: options.dirPath,
SegmentSize: math.MaxInt, // no limit, guarantee that a wal file only contains one segment file
SegmentFileExt: fmt.Sprintf(walFileExt, options.tableID),
BlockCache: options.walBlockCache,
Sync: options.walSync,
BytesPerSync: options.walBytesPerSync,
})
Expand Down
12 changes: 0 additions & 12 deletions memtable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestMemtableOpen(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}

t.Run("open memtable", func(t *testing.T) {
Expand Down Expand Up @@ -56,7 +55,6 @@ func TestMemtableOpenAll(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err = openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -93,7 +91,6 @@ func TestMemTablePutAllKindsEntries(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -151,7 +148,6 @@ func TestMemTablePutBatch(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -193,7 +189,6 @@ func TestMemTablePutBatchReopen(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -242,7 +237,6 @@ func TestMemTableGet(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -303,7 +297,6 @@ func TestMemTableGetReopen(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}

writeOpts := WriteOptions{
Expand Down Expand Up @@ -385,7 +378,6 @@ func TestMemTableDelWal(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -418,7 +410,6 @@ func TestMemTableSync(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down Expand Up @@ -463,7 +454,6 @@ func TestMemtableClose(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}

table, err := openMemtable(opts)
Expand All @@ -489,7 +479,6 @@ func TestNewMemtableIterator(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}

table, err := openMemtable(opts)
Expand Down Expand Up @@ -524,7 +513,6 @@ func Test_memtableIterator(t *testing.T) {
memSize: DefaultOptions.MemtableSize,
walBytesPerSync: DefaultOptions.BytesPerSync,
walSync: DefaultBatchOptions.Sync,
walBlockCache: DefaultOptions.BlockCache,
}
table, err := openMemtable(opts)
require.NoError(t, err)
Expand Down
6 changes: 0 additions & 6 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ type Options struct {
// Default value is 15.
MemtableNums int

// BlockCache specifies the size of the block cache in number of bytes.
// A block cache is used to store recently accessed data blocks, improving read performance.
// If BlockCache is set to 0, no block cache will be used.
BlockCache uint32

// Sync is whether to synchronize writes through os buffer cache and down onto the actual disk.
// Setting sync is required for durability of a single write operation, but also results in slower writes.
//
Expand Down Expand Up @@ -119,7 +114,6 @@ var DefaultOptions = Options{
MemtableSize: 64 * MB,
//nolint:gomnd // default
MemtableNums: 15,
BlockCache: 0,
Sync: false,
BytesPerSync: 0,
//nolint:gomnd // default
Expand Down
6 changes: 0 additions & 6 deletions vlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ type valueLogOptions struct {
// segmentSize specifies the maximum size of each segment file in bytes.
segmentSize int64

// blockCache specifies the size of the block cache in number of bytes.
// A block cache is used to store recently accessed data blocks, improving read performance.
// If BlockCache is set to 0, no block cache will be used.
blockCache uint32

// value log are partitioned to several parts for concurrent writing and reading
partitionNum uint32

Expand All @@ -52,7 +47,6 @@ func openValueLog(options valueLogOptions) (*valueLog, error) {
DirPath: options.dirPath,
SegmentSize: options.segmentSize,
SegmentFileExt: fmt.Sprintf(valueLogFileExt, i),
BlockCache: options.blockCache,
Sync: false, // we will sync manually
BytesPerSync: 0, // the same as Sync
})
Expand Down
9 changes: 0 additions & 9 deletions vlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func TestOpenValueLog(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand All @@ -41,7 +40,6 @@ func TestValueLogWriteAllKindsEntries(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -103,7 +101,6 @@ func TestValueLogWriteBatch(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -143,7 +140,6 @@ func TestValueLogWriteBatchReopen(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -187,7 +183,6 @@ func TestValueLogRead(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -252,7 +247,6 @@ func TestValueLogReadReopen(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -299,7 +293,6 @@ func TestValueLogSync(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down Expand Up @@ -328,7 +321,6 @@ func TestValueLogClose(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: GB,
blockCache: DefaultOptions.BlockCache,
partitionNum: uint32(DefaultOptions.PartitionNum),
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand All @@ -352,7 +344,6 @@ func TestValueLogMultiSegmentFiles(t *testing.T) {
opts := valueLogOptions{
dirPath: path,
segmentSize: 100 * MB,
blockCache: DefaultOptions.BlockCache,
partitionNum: 1,
hashKeyFunction: DefaultOptions.KeyHashFunction,
}
Expand Down

0 comments on commit 5891889

Please sign in to comment.