Skip to content

Commit

Permalink
Merge branch 'master' into aman/vlog_threshold_dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-bansal committed Jan 21, 2021
2 parents 980be43 + d1125c4 commit 8d6887f
Show file tree
Hide file tree
Showing 70 changed files with 391 additions and 371 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ For more details on our version naming schema please read [Choosing a version](#
To start using Badger, install Go 1.12 or above. Badger v2 needs go modules. Run the following command to retrieve the library.

```sh
$ go get github.com/dgraph-io/badger/v2
$ go get github.com/dgraph-io/badger/v3
```
This will retrieve the library.

##### Note: Badger does not directly use CGO but it relies on https://github.com/DataDog/zstd for compression and it requires gcc/cgo. If you wish to use badger without gcc/cgo, you can run `CGO_ENABLED=0 go get github.com/dgraph-io/badger/v2` which will download badger without the support for ZSTD compression algorithm.
##### Note: Badger does not directly use CGO but it relies on https://github.com/DataDog/zstd for compression and it requires gcc/cgo. If you wish to use badger without gcc/cgo, you can run `CGO_ENABLED=0 go get github.com/dgraph-io/badger/v3` which will download badger without the support for ZSTD compression algorithm.

#### Installing Badger Command Line Tool

Expand Down
4 changes: 2 additions & 2 deletions backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"encoding/binary"
"io"

"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
"github.com/golang/protobuf/proto"
)
Expand Down
2 changes: 1 addition & 1 deletion backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v3/pb"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion badger/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"math"
"os"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v3"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions badger/cmd/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"sync/atomic"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
"github.com/spf13/cobra"
)
Expand Down
4 changes: 2 additions & 2 deletions badger/cmd/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"fmt"
"math"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/options"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down
53 changes: 38 additions & 15 deletions badger/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,27 @@ import (

"github.com/pkg/errors"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/table"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/options"
"github.com/dgraph-io/badger/v3/table"
"github.com/dgraph-io/badger/v3/y"
humanize "github.com/dustin/go-humanize"
"github.com/spf13/cobra"
)

type flagOptions struct {
showTables bool
showHistogram bool
showKeys bool
withPrefix string
keyLookup string
itemMeta bool
keyHistory bool
showInternal bool
readOnly bool
truncate bool
encryptionKey string
showTables bool
showHistogram bool
showKeys bool
withPrefix string
keyLookup string
itemMeta bool
keyHistory bool
showInternal bool
readOnly bool
truncate bool
encryptionKey string
checksumVerificationMode string
}

var (
Expand Down Expand Up @@ -76,6 +78,8 @@ func init() {
infoCmd.Flags().BoolVar(&opt.truncate, "truncate", false, "If set to true, it allows "+
"truncation of value log files if they have corrupt data.")
infoCmd.Flags().StringVar(&opt.encryptionKey, "enc-key", "", "Use the provided encryption key")
infoCmd.Flags().StringVar(&opt.checksumVerificationMode, "cv-mode", "none",
"[none, table, block, tableAndBlock] Specifies when the db should verify checksum for SST.")
}

var infoCmd = &cobra.Command{
Expand All @@ -95,13 +99,15 @@ func handleInfo(cmd *cobra.Command, args []string) error {
return y.Wrap(err, "failed to print information in MANIFEST file")
}

cvMode := checksumVerificationMode(opt.checksumVerificationMode)
// Open DB
db, err := badger.Open(badger.DefaultOptions(sstDir).
WithValueDir(vlogDir).
WithReadOnly(opt.readOnly).
WithBlockCacheSize(100 << 20).
WithIndexCacheSize(200 << 20).
WithEncryptionKey([]byte(opt.encryptionKey)))
WithEncryptionKey([]byte(opt.encryptionKey)).
WithChecksumVerificationMode(cvMode))
if err != nil {
return y.Wrap(err, "failed to open database")
}
Expand Down Expand Up @@ -477,3 +483,20 @@ func pluralFiles(count int) string {
}
return "files"
}

func checksumVerificationMode(cvMode string) options.ChecksumVerificationMode {
switch cvMode {
case "none":
return options.NoVerification
case "table":
return options.OnTableRead
case "block":
return options.OnBlockRead
case "tableAndblock":
return options.OnTableAndBlockRead
default:
fmt.Printf("Invalid checksum verification mode: %s\n", cvMode)
os.Exit(1)
}
return options.NoVerification
}
6 changes: 3 additions & 3 deletions badger/cmd/read_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
)

Expand Down
2 changes: 1 addition & 1 deletion badger/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"os"
"path"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v3"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion badger/cmd/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v3"

"github.com/spf13/cobra"
)
Expand Down
4 changes: 2 additions & 2 deletions badger/cmd/rotate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"os"
"testing"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/y"
"github.com/stretchr/testify/require"
)

Expand Down
6 changes: 3 additions & 3 deletions badger/cmd/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"math"
"os"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/options"
"github.com/dgraph-io/badger/v3/y"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down
8 changes: 4 additions & 4 deletions badger/cmd/write_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/spf13/cobra"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/options"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
)

Expand Down
2 changes: 1 addition & 1 deletion badger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
_ "net/http/pprof"
"runtime"

"github.com/dgraph-io/badger/v2/badger/cmd"
"github.com/dgraph-io/badger/v3/badger/cmd"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
"go.opencensus.io/zpages"
Expand Down
4 changes: 2 additions & 2 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"sync"
"sync/atomic"

"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
"github.com/pkg/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/y"

"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 2 additions & 2 deletions compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"math"
"sync"

"github.com/dgraph-io/badger/v2/table"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/table"
"github.com/dgraph-io/badger/v3/y"
)

type keyRange struct {
Expand Down
10 changes: 5 additions & 5 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
"sync/atomic"
"time"

"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/skl"
"github.com/dgraph-io/badger/v2/table"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/options"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/skl"
"github.com/dgraph-io/badger/v3/table"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto"
"github.com/dgraph-io/ristretto/z"
humanize "github.com/dustin/go-humanize"
Expand Down
8 changes: 4 additions & 4 deletions db2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v3/options"

"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/table"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/table"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
"github.com/stretchr/testify/require"
)
Expand Down
6 changes: 3 additions & 3 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (

"github.com/stretchr/testify/require"

"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/badger/v2/pb"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/options"
"github.com/dgraph-io/badger/v3/pb"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
)

Expand Down
2 changes: 1 addition & 1 deletion dir_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path/filepath"
"strings"

"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/y"
)

// directoryLockGuard holds a lock on a directory and a pid file inside. The pid file isn't part
Expand Down
2 changes: 1 addition & 1 deletion dir_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"os"
"path/filepath"

"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/y"
"golang.org/x/sys/unix"
)

Expand Down
2 changes: 1 addition & 1 deletion dir_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"path/filepath"
"syscall"

"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/y"
)

// FILE_ATTRIBUTE_TEMPORARY - A file that is being used for temporary storage.
Expand Down
2 changes: 1 addition & 1 deletion discard.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"sort"
"sync"

"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
)

Expand Down
4 changes: 2 additions & 2 deletions docs/content/get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aliases = ["/get-started"]
To start using Badger, install Go 1.12 or above. Badger v2 needs go modules. Run the following command to retrieve the library.

```sh
$ go get github.com/dgraph-io/badger/v2
$ go get github.com/dgraph-io/badger/v3
```
This will retrieve the library.

Expand Down Expand Up @@ -60,7 +60,7 @@ package main
import (
"log"
badger "github.com/dgraph-io/badger/v2"
badger "github.com/dgraph-io/badger/v3"
)
func main() {
Expand Down
4 changes: 0 additions & 4 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ var (
// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.
ErrZeroBandwidth = errors.New("Bandwidth must be greater than zero")

// ErrInvalidLoadingMode is returned when opt.ValueLogLoadingMode option is not
// within the valid range
ErrInvalidLoadingMode = errors.New("Invalid ValueLogLoadingMode, must be FileIO or MemoryMap")

// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows
ErrWindowsNotSupported = errors.New("Read-only mode is not supported on Windows")

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/dgraph-io/badger/v2
module github.com/dgraph-io/badger/v3

go 1.12

Expand Down
4 changes: 2 additions & 2 deletions integration/testgc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"sync/atomic"
"time"

"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/y"
"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v3/y"
"github.com/dgraph-io/ristretto/z"
)

Expand Down
Loading

0 comments on commit 8d6887f

Please sign in to comment.