Skip to content

Commit

Permalink
Replace mistaken test of memtable size before last flush
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hughes committed Aug 14, 2017
1 parent d27dcd5 commit afd5a33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (s *KV) Close() (err error) {
// and remove them completely, while the block / memtable writer is still
// trying to push stuff into the memtable. This will also resolve the value
// offset problem: as we push into memtable, we update value offsets there.
if s.mt.Size() > 0 {
if !s.mt.Empty() {
s.elog.Printf("Flushing memtable")
for {
pushedFlushTask := func() bool {
Expand Down
5 changes: 5 additions & 0 deletions skl/skl.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func (s *Skiplist) Put(key []byte, v y.ValueStruct) {
}
}

// Empty returns if the Skiplist is empty.
func (s *Skiplist) Empty() bool {
return s.findLast() == nil
}

// findLast returns the last element. If head (empty list), we return nil. All the find functions
// will NEVER return the head nodes.
func (s *Skiplist) findLast() *node {
Expand Down

0 comments on commit afd5a33

Please sign in to comment.