Skip to content

Commit

Permalink
Merge pull request #15 from manosriram/feat/merge
Browse files Browse the repository at this point in the history
Add Merge feature
  • Loading branch information
manosriram authored May 14, 2024
2 parents f357eeb + 8fd9aa9 commit 6e985e6
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 167 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build:

clean:
rm -rf ./nimbusdb_temp* benchmark/nimbusdb_temp*
rm -rf ~/nimbusdb/test_data

test:
go test -v -failfast
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ As time passes, expired or deleted keys take up space that is not useful. Hence,
<summary>
Supports Merge
</summary>
Supports `Sync` which can be called periodically to remove expired/deleted keys from disk and free-up more space.
Supports `Merge` which can be called periodically to remove expired/deleted keys from disk and free-up space.
</details>

<details>
Expand Down Expand Up @@ -103,6 +103,15 @@ if err != nil {
}
```

#### Merge

```go
err := d.Merge()
if err != nil {
// handle error
}
```

#### Batch Operations
```go
d, err := nimbusdb.Open(&nimbusdb.Options{Path: "/path/to/data/directory"})
Expand Down
16 changes: 0 additions & 16 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,12 @@ package nimbusdb

import (
"bytes"
"errors"
"sync"
"time"

"github.com/manosriram/nimbusdb/utils"
"github.com/segmentio/ksuid"
)

var (
ERROR_BATCH_CLOSED = errors.New("batch is closed")
ERROR_CANNOT_CLOSE_CLOSED_BATCH = errors.New("cannot close closed batch")
)

type Batch struct {
id ksuid.KSUID
db *Db
closed bool
batchlock sync.Mutex
mu sync.RWMutex
writeQueue []*KeyValuePair
}

func (db *Db) NewBatch() (*Batch, error) {
b := &Batch{
db: db,
Expand Down
Loading

0 comments on commit 6e985e6

Please sign in to comment.