Skip to content

Commit

Permalink
Merge pull request #3 from octu0/v1.2.1
Browse files Browse the repository at this point in the history
v1.2.1
  • Loading branch information
octu0 authored Jun 23, 2022
2 parents 424b7a4 + 5dc5c29 commit a05fa4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 9 additions & 3 deletions bitcask.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,16 +712,22 @@ func (b *Bitcask) reopen() error {
// and deleted keys removes. Duplicate key/value pairs are also removed.
// Call this function periodically to reclaim disk space.
func (b *Bitcask) Merge() error {
b.mu.Lock()
if b.isMerging {
b.mu.Unlock()
b.mu.RLock()
currentMerging := b.isMerging
b.mu.RUnlock()

if currentMerging {
return ErrMergeInProgress
}

b.mu.Lock()
b.isMerging = true
b.mu.Unlock()

defer func() {
b.mu.Lock()
b.isMerging = false
b.mu.Unlock()
}()

b.mu.Lock()
Expand Down
16 changes: 4 additions & 12 deletions indexer/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ func writeTTL(w io.Writer, expiry time.Time) error {

// ReadIndex reads a persisted from a io.Reader into a Tree
func readFilerIndex(ctx runtime.Context, r io.Reader, t art.Tree) error {
pool := ctx.Buffer().BufioReaderPool()
bfr := pool.Get(r)
defer pool.Put(bfr)

for {
key, done, err := readKeyBytes(ctx, bfr)
key, done, err := readKeyBytes(ctx, r)
if err != nil {
if errors.Is(err, io.EOF) {
break
Expand All @@ -131,7 +127,7 @@ func readFilerIndex(ctx runtime.Context, r io.Reader, t art.Tree) error {
}
defer done()

f, err := readFiler(bfr)
f, err := readFiler(r)
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -169,12 +165,8 @@ func writeFilerIndex(ctx runtime.Context, w io.Writer, t art.Tree) (lastErr erro
}

func readTTLIndex(ctx runtime.Context, r io.Reader, t art.Tree) error {
pool := ctx.Buffer().BufioReaderPool()
bfr := pool.Get(r)
defer pool.Put(bfr)

for {
key, done, err := readKeyBytes(ctx, bfr)
key, done, err := readKeyBytes(ctx, r)
if err != nil {
if errors.Is(err, io.EOF) {
break
Expand All @@ -183,7 +175,7 @@ func readTTLIndex(ctx runtime.Context, r io.Reader, t art.Tree) error {
}
defer done()

ttl, err := readTTL(bfr)
ttl, err := readTTL(r)
if err != nil {
return errors.WithStack(err)
}
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package bitcaskdb

const (
AppName string = "bitcaskdb"
Version string = "1.2.0"
Version string = "1.2.1"
)

0 comments on commit a05fa4f

Please sign in to comment.