Skip to content

Commit

Permalink
refactor: remove useless fmt.Println
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Jul 10, 2021
1 parent 8a0b622 commit 63fa743
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions internal/storage/compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package storage

import (
"fmt"
"log"
)

Expand All @@ -41,15 +40,14 @@ func (s *Storage) pruneStaleTables() {
copy(s.tables[i:], s.tables[i+1:])
s.tables[len(s.tables)-1] = nil // or the zero value of T
s.tables = s.tables[:len(s.tables)-1]
fmt.Println(">> Pruned stale table", t.allocated)
break
}
}
}

func (s *Storage) CompactTables() bool {
if len(s.tables) == 1 {
return true
return true // break
}

defer s.pruneStaleTables()
Expand All @@ -65,7 +63,7 @@ func (s *Storage) CompactTables() bool {
// Create a new table and put the new k/v pair in it.
nt := newTable(s.Inuse() * 2)
s.tables = append(s.tables, nt)
return false
return false // means continue
}
if err != nil {
log.Printf("[ERROR] Failed to compact tables. HKey: %d: %v", hkey, err)
Expand All @@ -77,10 +75,10 @@ func (s *Storage) CompactTables() bool {
deleted++
if deleted > 1000 {
// It's enough. Don't block the instance.
return false
return false // means continue
}
}
}

return true
return true // means break
}
7 changes: 3 additions & 4 deletions internal/storage/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package storage

import (
"encoding/binary"

"github.com/pkg/errors"
)

Expand Down Expand Up @@ -147,9 +146,9 @@ func (t *table) getRaw(hkey uint64) ([]byte, bool) {
end += int(vlen) // value length

// Create a copy of the requested data.
rawval := make([]byte, (end-start)+1)
copy(rawval, t.memory[start:end])
return rawval, false
raw := make([]byte, (end-start)+1)
copy(raw, t.memory[start:end])
return raw, false
}

func (t *table) getRawKey(hkey uint64) ([]byte, bool) {
Expand Down

0 comments on commit 63fa743

Please sign in to comment.