diff --git a/internal/storage/compaction.go b/internal/storage/compaction.go index a716c266..3282289f 100644 --- a/internal/storage/compaction.go +++ b/internal/storage/compaction.go @@ -15,7 +15,6 @@ package storage import ( - "fmt" "log" ) @@ -41,7 +40,6 @@ 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 } } @@ -49,7 +47,7 @@ func (s *Storage) pruneStaleTables() { func (s *Storage) CompactTables() bool { if len(s.tables) == 1 { - return true + return true // break } defer s.pruneStaleTables() @@ -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) @@ -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 } diff --git a/internal/storage/table.go b/internal/storage/table.go index 00d6a840..b2183681 100644 --- a/internal/storage/table.go +++ b/internal/storage/table.go @@ -16,7 +16,6 @@ package storage import ( "encoding/binary" - "github.com/pkg/errors" ) @@ -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) {