diff --git a/bptree.go b/bptree.go index f274e2a..2725412 100644 --- a/bptree.go +++ b/bptree.go @@ -128,6 +128,7 @@ func (bt *BPTree) PutBatch(positions []*KeyPosition, _ ...diskhash.MatchKeyFunc) default: uidBytes,_ := record.uid.MarshalBinary() encPos := record.position.Encode() + //nolint:gocritic // Need to combine uidbytes with encPos and place them in bptree valueBytes := append(uidBytes, encPos...) if err := bucket.Put(record.key, valueBytes); err != nil { if errors.Is(err, bbolt.ErrKeyRequired) { diff --git a/db.go b/db.go index 2a00e39..f119985 100644 --- a/db.go +++ b/db.go @@ -384,7 +384,7 @@ func (db *DB) waitMemtableSpace() error { // 4. Add deleted uuid, and delete the deleted keys from index. // 5. Delete the wal. // -//nolint:gocognit +//nolint:gocognit,funlen func (db *DB) flushMemtable(table *memtable) { db.flushLock.Lock() defer db.flushLock.Unlock() @@ -549,24 +549,21 @@ func (db *DB) listenAutoCompact() { for { select { case state, ok := <-db.compactChan: + var err error + err = nil if ok { if state.thresholdState == ThresholdState(ArriveUpperThreshold) { // compact right now log.Println("ArriveUpperThreshold") - err := db.CompactWithDeprecatedtable() - if err != nil { - panic(err) - } + err = db.CompactWithDeprecatedtable() } else if state.thresholdState == ThresholdState(ArriveLowerThreshold) { // determine whether to do compact based on the current IO state - // TODO: since the IO state module has not been implemented yet, we just compare it here log.Println("ArriveLowerThreshold") - if true { - err := db.CompactWithDeprecatedtable() - if err != nil { - panic(err) - } - } + // TODO: since the IO state module has not been implemented yet, we just compare it here + err = db.CompactWithDeprecatedtable() + } + if err != nil { + panic(err) } for len(db.compactChan) > 0 { // discard squeezed messages @@ -584,7 +581,7 @@ func (db *DB) listenAutoCompact() { // Compact will iterate all values in vlog, and write the valid values to a new vlog file. // Then replace the old vlog file with the new one, and delete the old one. // -//nolint:gocognit +//nolint:gocognit,funlen func (db *DB) Compact() error { db.flushLock.Lock() defer db.flushLock.Unlock() @@ -709,7 +706,7 @@ func (db *DB) Compact() error { // and write the valid values to a new vlog file. // Then replace the old vlog file with the new one, and delete the old one. // -//nolint:gocognit +//nolint:gocognit,funlen func (db *DB) CompactWithDeprecatedtable() error { db.flushLock.Lock() defer db.flushLock.Unlock() diff --git a/db_test.go b/db_test.go index 9b21a77..8b4c945 100644 --- a/db_test.go +++ b/db_test.go @@ -680,6 +680,7 @@ func getRecordFromVlog(db *DB, key []byte) (*ValueLogRecord, error) { return record, nil } +//nolint:gocognit func TestDBMultiClients(t *testing.T) { type testLog struct { key []byte diff --git a/options.go b/options.go index f589406..339f7d7 100644 --- a/options.go +++ b/options.go @@ -138,8 +138,8 @@ var DefaultOptions = Options{ IndexType: BTree, //nolint:gomnd // default CompactBatchCount: 10000, - deprecatedtableLowerThreshold: 204800, // 200K - deprecatedtableUpperThreshold: 409600, // 400K + deprecatedtableLowerThreshold: 2 * 100 * KB, // 200K + deprecatedtableUpperThreshold: 4 * 100 * KB, // 400K autoCompact: true, //nolint:gomnd // default WaitMemSpaceTimeout: 100 * time.Millisecond,