Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
KANIOYH committed Aug 21, 2024
1 parent 28bc922 commit 39af1a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions bptree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
25 changes: 11 additions & 14 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 39af1a2

Please sign in to comment.