Skip to content

Commit 30e211c

Browse files
committed
feat(unigraph-dgraph): merge to upstream
1 parent d62ed5f commit 30e211c

File tree

22 files changed

+300
-97
lines changed

22 files changed

+300
-97
lines changed

.github/workflows/build-dgraph.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: build-dgraph
2+
3+
on:
4+
push:
5+
branches:
6+
- dgraph-personal
7+
8+
jobs:
9+
10+
build-dgraph:
11+
runs-on: ubuntu-18.04
12+
steps:
13+
- name: Install Go
14+
uses: actions/setup-go@v2.1.5
15+
with:
16+
go-version: '^1.17.7'
17+
18+
- name: Install dgraph dependencies
19+
run: sudo apt-get update; sudo apt-get install gcc make
20+
21+
- name: Check Go installed
22+
run: go version
23+
24+
- name: Checkout dgraph
25+
uses: actions/checkout@v2
26+
with:
27+
repository: unigraph-dev/dgraph.git
28+
ref: dgraph-personal
29+
30+
- name: Install dgraph linux
31+
run: cd ./dgraph; make install; ls $(go env GOPATH)/bin;
32+
33+
# - name: Test install dgraph linux
34+
# run: cd ./dgraph; echo hello > $(go env GOPATH)/bin/dgraph;
35+
36+
- name: Correct linux build directory
37+
run: mkdir $(go env GOPATH)/bin/linux_amd64/; mv $(go env GOPATH)/bin/dgraph $(go env GOPATH)/bin/linux_amd64/; ls $(go env GOPATH)/bin; ls $(go env GOPATH)/bin/linux_amd64
38+
39+
- name: Install dgraph macOS
40+
run: GOOS=darwin make install; ls $(go env GOPATH)/bin
41+
42+
- name: Install dgraph macOS M1
43+
run: GOOS=darwin GOARCH=arm64 make install; ls $(go env GOPATH)/bin
44+
45+
- name: Install dgraph windows
46+
run: GOOS=windows make install; ls $(go env GOPATH)/bin
47+
48+
- name: Move dgraph builds to current dir
49+
run: mkdir dist; mv $(go env GOPATH)/bin/linux_amd64/dgraph ./dist/dgraph_linux_amd64; mv $(go env GOPATH)/bin/darwin_amd64/dgraph ./dist/dgraph_darwin_amd64; mv $(go env GOPATH)/bin/darwin_arm64/dgraph ./dist/dgraph_darwin_arm64; mv $(go env GOPATH)/bin/windows_amd64/dgraph.exe ./dist/dgraph_windows_amd64.exe; ls .;
50+
51+
- name: Upload linux build as artifact
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: dgraph_linux_amd64
55+
path: ./dist/dgraph_linux_amd64
56+
if-no-files-found: error
57+
58+
- name: Upload macOS build as artifact
59+
uses: actions/upload-artifact@v2
60+
with:
61+
name: dgraph_darwin_amd64
62+
path: ./dist/dgraph_darwin_amd64
63+
if-no-files-found: error
64+
65+
- name: Upload macOS M1 build as artifact
66+
uses: actions/upload-artifact@v2
67+
with:
68+
name: dgraph_darwin_arm64
69+
path: ./dist/dgraph_darwin_arm64
70+
if-no-files-found: error
71+
72+
- name: Upload Windows build as artifact
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: dgraph_windows_amd64
76+
path: ./dist/dgraph_windows_amd64.exe
77+
if-no-files-found: error
78+
79+
- name: Release
80+
uses: softprops/action-gh-release@v1
81+
with:
82+
files: |
83+
./dist/dgraph_linux_amd64
84+
./dist/dgraph_darwin_amd64
85+
./dist/dgraph_darwin_arm64
86+
./dist/dgraph_windows_amd64.exe
87+
fail_on_unmatched_files: true

.github/workflows/golangci-lint.yml

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

.github/workflows/label.yml

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

.github/workflows/main.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ sudo apt-get install gcc make
5959
Then clone the Dgraph repository and use `make install` to install the Dgraph binary to `$GOPATH/bin`.
6060

6161
```bash
62-
git clone https://github.com/dgraph-io/dgraph.git
62+
git clone https://github.com/unigraph-dev/dgraph.git
6363
cd ./dgraph
6464
make install
6565
```

contrib/Dockerfile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
# This gets built as part of release.sh. Must be run from /tmp/build, with the linux binaries
55
# already built and placed there.
66

7-
FROM ubuntu:20.04
8-
LABEL maintainer="Dgraph Labs <contact@dgraph.io>"
7+
FROM golang:1.17.3-bullseye AS build
98

109
RUN apt-get update && \
1110
apt-get install -y --no-install-recommends \
11+
gcc \
12+
make \
13+
git \
14+
bzip2 \
1215
ca-certificates \
1316
curl \
1417
htop \
@@ -18,9 +21,22 @@ RUN apt-get update && \
1821
sysstat && \
1922
curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
2023
apt-get install -y nodejs && \
24+
rm -rf /var/lib/apt/lists/* && \
25+
mkdir /dgraph
26+
27+
WORKDIR /dgraph
28+
COPY . .
29+
30+
RUN make install
31+
32+
FROM ubuntu:latest
33+
LABEL maintainer="Dgraph Labs <contact@dgraph.io>"
34+
35+
RUN apt-get update && \
36+
apt-get install -y --no-install-recommends ca-certificates curl iputils-ping && \
2137
rm -rf /var/lib/apt/lists/*
2238

23-
ADD linux /usr/local/bin
39+
COPY --from=build /go/bin/dgraph /usr/local/bin/dgraph
2440

2541
EXPOSE 8080
2642
EXPOSE 9080

dgraph/cmd/alpha/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ they form a Raft group and provide synchronous replication.
124124
flag.String("export", "export", "Folder in which to store exports.")
125125
flag.StringP("zero", "z", fmt.Sprintf("localhost:%d", x.PortZeroGrpc),
126126
"Comma separated list of Dgraph Zero addresses of the form IP_ADDRESS:PORT.")
127+
flag.Bool("expand-edge", true,
128+
"Enables the expand(_predicate_) feature. This is a bit expensive for large data loads because it"+
129+
" doubles the number of mutations going on in the system.")
127130

128131
// Useful for running multiple servers on the same machine.
129132
flag.IntP("port_offset", "o", 0,
@@ -842,6 +845,7 @@ func run() {
842845
ExportPath: Alpha.Conf.GetString("export"),
843846
ZeroAddr: strings.Split(Alpha.Conf.GetString("zero"), ","),
844847
Raft: raft,
848+
ExpandEdge: Alpha.Conf.GetBool("expand-edge"),
845849
WhiteListedIPRanges: ips,
846850
StrictMutations: opts.MutationsMode == worker.StrictMutations,
847851
AclEnabled: keys.AclKey != nil,

dgraph/cmd/bulk/loader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type options struct {
5959
TmpDir string
6060
NumGoroutines int
6161
MapBufSize uint64
62+
ExpandEdges bool
6263
PartitionBufSize int64
6364
SkipMapPhase bool
6465
CleanupTmp bool

dgraph/cmd/bulk/mapper.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ func (m *mapper) processNQuad(nq gql.NQuad) {
339339
m.addMapEntry(key, rev, shard)
340340
}
341341
m.addIndexMapEntries(nq, de)
342+
343+
if m.opt.ExpandEdges {
344+
nsAttr := x.NamespaceAttr(de.Namespace, "_predicate_")
345+
shard := m.state.shards.shardFor(nsAttr)
346+
key = x.DataKey(nsAttr, sid)
347+
pp := m.createPredicatePosting(de.Namespace, nq.Predicate)
348+
m.addMapEntry(key, pp, shard)
349+
}
342350
}
343351

344352
func (m *mapper) uid(xid string, ns uint64) uint64 {
@@ -388,6 +396,16 @@ func (m *mapper) lookupUid(xid string, ns uint64) uint64 {
388396
return uid
389397
}
390398

399+
func (m *mapper) createPredicatePosting(namespace uint64, predicate string) *pb.Posting {
400+
fp := farm.Fingerprint64([]byte(predicate))
401+
return &pb.Posting{
402+
Uid: fp,
403+
Value: []byte(x.NamespaceAttr(namespace, predicate)),
404+
ValType: pb.Posting_DEFAULT,
405+
PostingType: pb.Posting_VALUE,
406+
}
407+
}
408+
391409
func (m *mapper) createPostings(nq gql.NQuad,
392410
de *pb.DirectedEdge) (*pb.Posting, *pb.Posting) {
393411

dgraph/cmd/bulk/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ func init() {
8989
"Number of worker threads to use. MORE THREADS LEAD TO HIGHER RAM USAGE.")
9090
flag.Int64("mapoutput_mb", 2048,
9191
"The estimated size of each map file output. Increasing this increases memory usage.")
92+
flag.Bool("expand_edges", true,
93+
"Generate edges that allow nodes to be expanded using _predicate_ or expand(...). "+
94+
"Disable to increase loading speed.")
9295
flag.Int64("partition_mb", 4, "Pick a partition key every N megabytes of data.")
9396
flag.Bool("skip_map_phase", false,
9497
"Skip the map phase (assumes that map output files already exist).")
@@ -163,6 +166,7 @@ func run() {
163166
TmpDir: Bulk.Conf.GetString("tmp"),
164167
NumGoroutines: Bulk.Conf.GetInt("num_go_routines"),
165168
MapBufSize: uint64(Bulk.Conf.GetInt("mapoutput_mb")),
169+
ExpandEdges: Bulk.Conf.GetBool("expand_edges"),
166170
PartitionBufSize: int64(Bulk.Conf.GetInt("partition_mb")),
167171
SkipMapPhase: Bulk.Conf.GetBool("skip_map_phase"),
168172
CleanupTmp: Bulk.Conf.GetBool("cleanup_tmp"),

0 commit comments

Comments
 (0)