Skip to content

Commit ed048d5

Browse files
author
Pawan Rawal
committed
Integrate badger. Remove RocksDB
1 parent 74afa9d commit ed048d5

File tree

1,335 files changed

+343
-451667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,335 files changed

+343
-451667
lines changed

.travis.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ matrix:
33
- os: osx
44
include:
55
- os: linux
6-
compiler: clang-3.9
76
go: 1.8
87
language: go
9-
env: CC=clang-3.9 CXX=clang++-3.9;
108
- os: osx
11-
compiler: clang
129
language: go
1310
go: 1.8
14-
env: CC=clang CXX=clang++;
1511

12+
install: contrib/install.sh
1613
git:
1714
depth: 1000
1815
dist: trusty
@@ -22,14 +19,7 @@ notifications:
2219
secure: uezT1E7kSVRDC2El9g5syXb1I4JrUUJHW4PXAf0IhXDFqS1ewkrNMurbkltrsJp0OtH7r2rzewuZsxjZ8pz0D+9YPorQzCPUgSqHuYnplh5WJMiaImXVvyApOpVEIm/0mFitrhfGjtMDXegRw1Rk95ujKNokulCSlLqGT1GSKQXmRjBgPYPqPmWQUbzkvwgL6NcMODv1GLyslGGTVKY/WiSjYkiNsQbDjxED3w5rAoX1FG3pvcHAXGxSWbTEk2VzvjGuNwflK92FZZXS/NxXPdEa4lPjlFBRRTHWwEXS4qbaGrdQNJ1DFI/QWrKtw6sHpqt22ovXEk4qkVthaf6Yq8YxoBQ80ajY6gw72ZMXreN3AaHCi7thNKtj/v2e1qlxggNCA8WDnXQmQ0iCg+BYD63LsVbJqlAGq151GGGJXSTcci1DhsuT3JeYx2Vd+wIHNTuYRqFJACnA45KRyExejyzdAYvdBgMnbMbtKctKtFthB5g5P1evBvx/PmZxpXPxIhLKjlCwZgutfR2jy1YSFjIHDR3hBJGsPj1z0XLo36kTOUM/CpTzbNFe2xr3dZrNH/LwWiYO9NBeCHc6kCi6DKi7X7bvnlpk8tazHep7VDQputNWgwEu4flld8jy7QRnIDVIj+4qwT+YhUDG/2lPJ5/Agxjq7rGgkIpPc8Kd8sQ=
2320
addons:
2421
apt:
25-
sources:
26-
- ubuntu-toolchain-r-test
27-
- llvm-toolchain-precise-3.9
2822
packages:
29-
- clang-3.9
30-
- libbz2-dev
31-
- libsnappy-dev
32-
- zlib1g-dev
3323
- jq
3424
- graphviz
3525
hosts:
@@ -45,8 +35,6 @@ cache:
4535
- "$HOME/build"
4636
- $HOME/Library/Caches/Homebrew
4737

48-
install:
49-
- bash contrib/build-rocksdb.sh $HOME/build
5038
before_script:
5139
- go get github.com/mattn/goveralls
5240
script:

cmd/dgraph/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"syscall"
4545
"time"
4646

47+
"github.com/dgraph-io/badger/badger"
4748
"golang.org/x/net/context"
4849
"golang.org/x/net/trace"
4950
"google.golang.org/grpc"
@@ -55,7 +56,6 @@ import (
5556
"github.com/dgraph-io/dgraph/query"
5657
"github.com/dgraph-io/dgraph/rdf"
5758
"github.com/dgraph-io/dgraph/schema"
58-
"github.com/dgraph-io/dgraph/store"
5959
"github.com/dgraph-io/dgraph/tok"
6060
"github.com/dgraph-io/dgraph/types"
6161
"github.com/dgraph-io/dgraph/worker"
@@ -1012,8 +1012,11 @@ func main() {
10121012

10131013
// All the writes to posting store should be synchronous. We use batched writers
10141014
// for posting lists, so the cost of sync writes is amortized.
1015-
ps, err := store.NewSyncStore(*postingDir)
1016-
x.Checkf(err, "Error initializing postings store")
1015+
opt := badger.DefaultOptions
1016+
opt.SyncWrites = true
1017+
opt.Dir = *postingDir
1018+
ps, err := badger.NewKV(&opt)
1019+
x.Checkf(err, "Error while creating badger KV posting store")
10171020
defer ps.Close()
10181021

10191022
x.Check(group.ParseGroupConfig(*gconf))

cmd/dgraph/main_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ import (
2929

3030
"github.com/stretchr/testify/require"
3131

32+
"github.com/dgraph-io/badger/badger"
3233
"github.com/dgraph-io/dgraph/gql"
3334
"github.com/dgraph-io/dgraph/group"
3435
"github.com/dgraph-io/dgraph/posting"
3536
"github.com/dgraph-io/dgraph/protos"
3637
"github.com/dgraph-io/dgraph/query"
3738
"github.com/dgraph-io/dgraph/schema"
38-
"github.com/dgraph-io/dgraph/store"
3939
"github.com/dgraph-io/dgraph/types"
4040
"github.com/dgraph-io/dgraph/worker"
4141
"github.com/dgraph-io/dgraph/x"
@@ -57,16 +57,16 @@ var m = `
5757
}
5858
`
5959

60-
func prepare() (dir1, dir2 string, ps *store.Store, rerr error) {
60+
func prepare() (dir1, dir2 string, ps *badger.KV, rerr error) {
6161
var err error
6262
dir1, err = ioutil.TempDir("", "storetest_")
6363
if err != nil {
6464
return "", "", nil, err
6565
}
66-
ps, err = store.NewStore(dir1)
67-
if err != nil {
68-
return "", "", nil, err
69-
}
66+
opt := badger.DefaultOptions
67+
opt.Dir = dir1
68+
ps, err = badger.NewKV(&opt)
69+
x.Check(err)
7070

7171
dir2, err = ioutil.TempDir("", "wal_")
7272
if err != nil {
@@ -730,12 +730,12 @@ func TestSchemaConversion(t *testing.T) {
730730
require.JSONEq(t, `{"user":[{"name2":1.5}]}`, output)
731731
}
732732

733-
var qErr = `
734-
mutation {
735-
set {
736-
<0x0> <name> "Alice" .
737-
}
738-
}
733+
var qErr = `
734+
mutation {
735+
set {
736+
<0x0> <name> "Alice" .
737+
}
738+
}
739739
`
740740

741741
func TestMutationError(t *testing.T) {
@@ -945,7 +945,8 @@ func TestExpandPred(t *testing.T) {
945945
}
946946
func TestMain(m *testing.M) {
947947
x.Init()
948-
dir1, dir2, _, _ := prepare()
948+
dir1, dir2, ps, _ := prepare()
949+
defer ps.Close()
949950
defer closeAll(dir1, dir2)
950951
time.Sleep(5 * time.Second) // Wait for ME to become leader.
951952

contrib/build-rocksdb.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

contrib/cover.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,8 @@ if [ -z "$OUT" ]; then
1515
fi
1616
rm -f $OUT
1717

18-
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
19-
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib;
20-
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include;
21-
else
22-
ROCKSDBDIR=$BUILD/rocksdb-5.1.4
23-
24-
# build flags needed for rocksdb
25-
export CGO_CPPFLAGS="-I${ROCKSDBDIR}/include"
26-
export CGO_LDFLAGS="-L${ROCKSDBDIR}"
27-
export LD_LIBRARY_PATH="${ROCKSDBDIR}:${LD_LIBRARY_PATH}"
28-
fi
29-
3018
set -e
3119

32-
# Lets install the dependencies that are not vendored in anymore.
33-
go get -d golang.org/x/net/context
34-
go get -d google.golang.org/grpc/...
35-
3620
pushd $SRC &> /dev/null
3721

3822
# create coverage output

contrib/install.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# Lets install the dependencies that are not vendored in anymore.
4+
go get -d golang.org/x/net/context
5+
go get -d google.golang.org/grpc/...
6+
go get -u github.com/dgraph-io/badger/...
7+
8+

contrib/loader.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ ls -la goldendata.rdf.gz
2222
benchmark=$(pwd)
2323
popd &> /dev/null
2424

25-
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
26-
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib;
27-
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include;
28-
else
29-
ROCKSDBDIR=$BUILD/rocksdb-5.1.4
30-
31-
# build flags needed for rocksdb
32-
export CGO_CPPFLAGS="-I${ROCKSDBDIR}/include"
33-
export CGO_LDFLAGS="-L${ROCKSDBDIR}"
34-
export LD_LIBRARY_PATH="${ROCKSDBDIR}:${LD_LIBRARY_PATH}"
35-
fi
36-
3725
pushd cmd/dgraph &> /dev/null
3826
go build .
3927
./dgraph -gentlecommit 1.0 &

contrib/queries.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
#!/bin/bash
2-
3-
SRC="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
4-
5-
BUILD=$1
6-
# If build variable is empty then we set it.
7-
if [ -z "$1" ]; then
8-
BUILD=$SRC/build
9-
fi
10-
11-
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
12-
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib;
13-
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include;
14-
else
15-
ROCKSDBDIR=$BUILD/rocksdb-5.1.4
16-
17-
# build flags needed for rocksdb
18-
export CGO_CPPFLAGS="-I${ROCKSDBDIR}/include"
19-
export CGO_LDFLAGS="-L${ROCKSDBDIR}"
20-
export LD_LIBRARY_PATH="${ROCKSDBDIR}:${LD_LIBRARY_PATH}"
21-
fi
22-
232
set -e
243

254
pushd cmd/dgraph &> /dev/null

contrib/releases/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ uiDir="main.uiDir"
4848
echo -e "\033[1;33mBuilding binaries\033[0m"
4949
echo "dgraph"
5050
cd $dgraph_cmd/dgraph && \
51-
go build -v -tags=embed -ldflags \
51+
go build -v -ldflags \
5252
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime' -X $uiDir=$ui" .;
5353
echo "dgraphloader"
5454
echo $release
5555
cd $dgraph_cmd/dgraphloader && \
56-
go build -v -tags=embed -ldflags \
56+
go build -v -ldflags \
5757
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime'" .;
5858

5959
echo -e "\n\033[1;33mCopying binaries to tmp folder\033[0m"

contrib/simple-e2e.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,12 @@ if [ -z "$1" ]; then
1010
BUILD=$SRC/build
1111
fi
1212

13-
ROCKSDBDIR=$BUILD/rocksdb-5.1.4
14-
1513
set -e
1614

1715
pushd $BUILD &> /dev/null
1816
benchmark=$(pwd)/benchmarks/data
1917
popd &> /dev/null
2018

21-
# build flags needed for rocksdb
22-
23-
export CGO_CPPFLAGS="-I${ROCKSDBDIR}/include"
24-
export CGO_LDFLAGS="-L${ROCKSDBDIR}"
25-
export LD_LIBRARY_PATH="${ROCKSDBDIR}:${LD_LIBRARY_PATH}"
26-
2719
pushd cmd/dgraph &> /dev/null
2820
go build .
2921
./dgraph --p ~/dgraph/p0 --w ~/dgraph/w0 &

0 commit comments

Comments
 (0)