Showing with 12,911 additions and 14,629 deletions.
  1. +1 −0 README.md
  2. +3 −0 algo/uidlist.go
  3. +15 −0 client/client.go
  4. +44 −16 client/examples_test.go
  5. +13 −0 client/value.go
  6. +2 −58 cmd/dgraph/dashboard.go
  7. +142 −27 cmd/dgraph/main.go
  8. +295 −2 cmd/dgraph/main_test.go
  9. +10 −2 cmd/dgraphloader/main.go
  10. +3 −3 contrib/freebase/simple_test.go
  11. +3 −4 contrib/freebase/spielberg_test.go
  12. +1 −1 contrib/indextest/releasedate_geq.in
  13. +96 −0 contrib/reload/reload.sh
  14. +2 −2 dashboard/build/asset-manifest.json
  15. +1 −1 dashboard/build/index.html
  16. +0 −53 dashboard/build/static/js/main.7e044d7e.js
  17. +54 −0 dashboard/build/static/js/main.bd03be29.js
  18. +1 −0 dashboard/package.json
  19. +51 −79 dashboard/src/actions/index.js
  20. +4 −4 dashboard/src/components/Navbar.js
  21. +21 −4 dashboard/src/containers/App.js
  22. +4 −16 dashboard/src/containers/Editor.js
  23. +42 −5 dashboard/src/containers/Helpers.js
  24. +0 −1 dashboard/src/containers/NavbarContainer.js
  25. +1 −1 dashboard/src/index.js
  26. +3 −1 dashboard/src/reducers/index.js
  27. +0 −7 dashboard/src/reducers/query.js
  28. +32 −0 dashboard/src/reducers/regex.js
  29. +0 −6 dashboard/src/reducers/share.js
  30. +3 −0 docker/release/Dockerfile
  31. +1 −0 food/.gitignore
  32. +71 −0 food/main.go
  33. +10 −0 food/rest.csv
  34. +7 −7 gql/bench_test.go
  35. +330 −0 gql/math.go
  36. +259 −53 gql/parser.go
  37. +579 −19 gql/parser_test.go
  38. +91 −15 gql/state.go
  39. +2 −2 lex/iri.go
  40. +34 −2 posting/index.go
  41. +115 −55 posting/list.go
  42. +26 −0 posting/list_test.go
  43. +1 −1 protos/facetsp/facets.proto
  44. +207 −31 query/aggregator.go
  45. +1 −1 query/common_test.go
  46. +248 −0 query/math.go
  47. +93 −52 query/outputnode.go
  48. +315 −149 query/query.go
  49. +117 −39 query/query_facets_test.go
  50. +1,122 −387 query/query_test.go
  51. +15 −2 rdf/parse.go
  52. +22 −6 rdf/parse_test.go
  53. +9 −1 rdf/state.go
  54. +11 −3 schema/parse.go
  55. +26 −4 schema/parse_test.go
  56. +47 −0 tok/tok.go
  57. +26 −1 tok/tok_test.go
  58. +16 −1 types/sort.go
  59. +6 −6 types/sort_test.go
  60. +109 −8 vendor/github.com/golang/protobuf/proto/decode.go
  61. +12 −13 vendor/github.com/golang/protobuf/proto/encode.go
  62. +6 −2 vendor/github.com/golang/protobuf/proto/equal.go
  63. +32 −0 vendor/github.com/golang/protobuf/proto/extensions.go
  64. +1 −1 vendor/github.com/golang/protobuf/proto/lib.go
  65. +9 −1 vendor/github.com/golang/protobuf/proto/properties.go
  66. +19 −4 vendor/github.com/golang/protobuf/proto/text_parser.go
  67. +1 −1 vendor/{golang.org/x/text → github.com/google/codesearch}/LICENSE
  68. +344 −0 vendor/github.com/google/codesearch/index/merge.go
  69. +39 −0 vendor/github.com/google/codesearch/index/mmap_bsd.go
  70. +31 −0 vendor/github.com/google/codesearch/index/mmap_linux.go
  71. +37 −0 vendor/github.com/google/codesearch/index/mmap_windows.go
  72. +443 −0 vendor/github.com/google/codesearch/index/read.go
  73. +872 −0 vendor/github.com/google/codesearch/index/regexp.go
  74. +649 −0 vendor/github.com/google/codesearch/index/write.go
  75. +223 −0 vendor/github.com/google/codesearch/regexp/copy.go
  76. +473 −0 vendor/github.com/google/codesearch/regexp/match.go
  77. +59 −0 vendor/github.com/google/codesearch/regexp/regexp.go
  78. +268 −0 vendor/github.com/google/codesearch/regexp/utf.go
  79. +65 −0 vendor/github.com/google/codesearch/sparse/set.go
  80. +33 −2 vendor/golang.org/x/net/http2/client_conn_pool.go
  81. +1 −10 vendor/golang.org/x/net/http2/configure_transport.go
  82. +146 −0 vendor/golang.org/x/net/http2/databuffer.go
  83. +8 −0 vendor/golang.org/x/net/http2/errors.go
  84. +0 −60 vendor/golang.org/x/net/http2/fixed_buffer.go
  85. +114 −41 vendor/golang.org/x/net/http2/frame.go
  86. +43 −0 vendor/golang.org/x/net/http2/go16.go
  87. +90 −0 vendor/golang.org/x/net/http2/go17.go
  88. +36 −0 vendor/golang.org/x/net/http2/go17_not18.go
  89. +54 −0 vendor/golang.org/x/net/http2/go18.go
  90. +9 −20 vendor/golang.org/x/net/http2/hpack/encode.go
  91. +27 −79 vendor/golang.org/x/net/http2/hpack/hpack.go
  92. +188 −62 vendor/golang.org/x/net/http2/hpack/tables.go
  93. +53 −130 vendor/golang.org/x/net/http2/http2.go
  94. +34 −1 vendor/golang.org/x/net/http2/not_go16.go
  95. +66 −1 vendor/golang.org/x/net/http2/not_go17.go
  96. +27 −0 vendor/golang.org/x/net/http2/not_go18.go
  97. +7 −1 vendor/golang.org/x/net/http2/pipe.go
  98. +958 −399 vendor/golang.org/x/net/http2/server.go
  99. +641 −190 vendor/golang.org/x/net/http2/transport.go
  100. +147 −39 vendor/golang.org/x/net/http2/write.go
  101. +191 −232 vendor/golang.org/x/net/http2/writesched.go
  102. +452 −0 vendor/golang.org/x/net/http2/writesched_priority.go
  103. +72 −0 vendor/golang.org/x/net/http2/writesched_random.go
  104. +0 −22 vendor/golang.org/x/text/PATENTS
  105. +0 −661 vendor/golang.org/x/text/transform/transform.go
  106. +0 −514 vendor/golang.org/x/text/unicode/norm/composition.go
  107. +0 −256 vendor/golang.org/x/text/unicode/norm/forminfo.go
  108. +0 −105 vendor/golang.org/x/text/unicode/norm/input.go
  109. +0 −450 vendor/golang.org/x/text/unicode/norm/iter.go
  110. +0 −978 vendor/golang.org/x/text/unicode/norm/maketables.go
  111. +0 −576 vendor/golang.org/x/text/unicode/norm/normalize.go
  112. +0 −126 vendor/golang.org/x/text/unicode/norm/readwriter.go
  113. +0 −7,627 vendor/golang.org/x/text/unicode/norm/tables.go
  114. +0 −88 vendor/golang.org/x/text/unicode/norm/transform.go
  115. +0 −54 vendor/golang.org/x/text/unicode/norm/trie.go
  116. +0 −117 vendor/golang.org/x/text/unicode/norm/triegen.go
  117. +36 −21 vendor/vendor.json
  118. +67 −2 wiki/README.md
  119. +22 −13 wiki/config.toml
  120. +161 −0 wiki/content/_index.md
  121. +43 −19 wiki/content/clients/index.md
  122. +2 −0 wiki/content/design-concepts/index.md
  123. +4 −4 wiki/content/get-started/index.md
  124. +4 −1 wiki/content/performance/index.md
  125. +225 −458 wiki/content/query-language/index.md
  126. +4 −3 wiki/nginx/docs.conf
  127. +29 −3 wiki/scripts/build.sh
  128. +28 −0 wiki/scripts/local.sh
  129. +1 −1 worker/backup.go
  130. +2 −2 worker/compare.go
  131. +13 −5 worker/groups.go
  132. +8 −2 worker/mutation.go
  133. +3 −4 worker/sort.go
  134. +96 −0 worker/stringfilter.go
  135. +237 −57 worker/task.go
  136. +35 −20 worker/tokens.go
  137. +108 −0 worker/trigram.go
  138. +8 −8 worker/worker_test.go
  139. +1 −1 x/init.go
  140. +3 −2 x/values.go
  141. +2 −2 x/values_test.go
  142. +26 −0 x/x.go
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**Scalable, Distributed, Low Latency, High Throughput Graph Database.**

![logo](https://img.shields.io/badge/status-alpha-red.svg)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdgraph-io%2Fdgraph.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fdgraph-io%2Fdgraph?ref=badge_shield)
[![Wiki](https://img.shields.io/badge/res-wiki-blue.svg)](https://docs.dgraph.io)
[![Build Status](https://travis-ci.org/dgraph-io/dgraph.svg?branch=master)](https://travis-ci.org/dgraph-io/dgraph)
[![Coverage Status](https://coveralls.io/repos/github/dgraph-io/dgraph/badge.svg?branch=master)](https://coveralls.io/github/dgraph-io/dgraph?branch=master)
Expand Down
3 changes: 3 additions & 0 deletions algo/uidlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ func MergeSorted(lists []*taskp.List) *taskp.List {
maxSz := 0

for i, l := range lists {
if l == nil {
continue
}
lenList := len(l.Uids)
if lenList > 0 {
heap.Push(h, elem{
Expand Down
15 changes: 15 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/dgraph-io/dgraph/protos/graphp"
"github.com/dgraph-io/dgraph/types"
"github.com/dgraph-io/dgraph/types/facets"
"github.com/dgraph-io/dgraph/x"
)

Expand Down Expand Up @@ -104,6 +105,15 @@ func (req *Req) AddMutation(nq graphp.NQuad, op Op) error {
return nil
}

func AddFacet(key string, val string, nq *graphp.NQuad) error {
facet, err := facets.FacetFor(key, val)
if err != nil {
return err
}
nq.Facets = append(nq.Facets, facet)
return nil
}

func checkSchema(schema graphp.SchemaUpdate) error {
typ := types.TypeID(schema.ValueType)
if typ == types.UidID && schema.Directive == graphp.SchemaUpdate_INDEX {
Expand Down Expand Up @@ -257,6 +267,11 @@ func (batch *BatchMutation) AddMutation(nq graphp.NQuad, op Op) error {
if err := checkNQuad(nq); err != nil {
return err
}
if op == SET &&
((nq.ObjectType == int32(types.DefaultID) && nq.ObjectValue.GetDefaultVal() == "*") ||
(nq.ObjectType == int32(types.StringID) && nq.ObjectValue.GetStrVal() == "*")) {
return x.Errorf("Cannot set the value as '*'")
}
batch.nquads <- nquadOp{nq: nq, op: op}
atomic.AddUint64(&batch.rdfs, 1)
return nil
Expand Down
60 changes: 44 additions & 16 deletions client/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,50 @@ func ExampleReq_AddMutation_facets() {
dgraphClient := graphp.NewDgraphClient(conn)

req := client.Req{}
// Doing mutation and setting facets while using the raw query block.
req.SetQuery(`
mutation {
set {
<alice> <name> "alice" .
<alice> <mobile> "040123456" (since=2006-01-02T15:04:05) .
<alice> <car> "MA0123" (since=2006-02-02T13:01:09, first=true) .
}
}
{
data(id:alice) {
name
mobile @facets
car @facets
}
}`)
nq := graphp.NQuad{
Subject: "person1",
Predicate: "name",
}
client.Str("Steven Spielberg", &nq)

if err := client.AddFacet("since", "2006-01-02T15:04:05", &nq); err != nil {
log.Fatal(err)
}

if err := client.AddFacet("alias", `"Steve"`, &nq); err != nil {
log.Fatal(err)
}

req.AddMutation(nq, client.SET)

nq = graphp.NQuad{
Subject: "person2",
Predicate: "name",
}
client.Str("William Jones", &nq)
req.AddMutation(nq, client.SET)

// Lets connect the two nodes together and add a facet to the edge.
nq = graphp.NQuad{
Subject: "person1",
Predicate: "friend",
ObjectId: "person2",
}

if err := client.AddFacet("close", "true", &nq); err != nil {
log.Fatal(err)
}

req.AddMutation(nq, client.SET)
req.SetQuery(`{
me(id: person1) {
name @facets
friend @facets {
name
}
}
}`)

resp, err := dgraphClient.Run(context.Background(), req.Request())
if err != nil {
log.Fatalf("Error in getting response from server, %s", err)
Expand Down
13 changes: 13 additions & 0 deletions client/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,21 @@ func Datetime(dateTime time.Time, nq *graphp.NQuad) error {
return nil
}

func validateStr(val string) error {
for idx, c := range val {
if c == '"' && (idx == 0 || val[idx-1] != '\\') {
return fmt.Errorf(`" must be preceded by a \ in object value`)
}
}
return nil
}

// Str is a helper function to add a string to an NQuad.ObjectValue.
func Str(val string, nq *graphp.NQuad) error {
if err := validateStr(val); err != nil {
return err
}

v, err := types.ObjectValue(types.StringID, val)
if err != nil {
return err
Expand Down
60 changes: 2 additions & 58 deletions cmd/dgraph/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net/http"
"regexp"

"github.com/dgraph-io/dgraph/protos/graphp"
"github.com/dgraph-io/dgraph/x"
)

Expand Down Expand Up @@ -73,11 +72,11 @@ func keywordHandler(w http.ResponseWriter, r *http.Request) {
"first",
"fulltext",
"func",
"geq",
"ge",
"id",
"index",
"intersects",
"leq",
"le",
"mutation",
"near",
"offset",
Expand Down Expand Up @@ -107,58 +106,3 @@ func keywordHandler(w http.ResponseWriter, r *http.Request) {
}
w.Write(js)
}

func hasOnlySharePred(mutation *graphp.Mutation) bool {
for _, nq := range mutation.Set {
if nq.Predicate != INTERNAL_SHARE {
return false
}
}

for _, nq := range mutation.Del {
if nq.Predicate != INTERNAL_SHARE {
return false
}
}
return true
}

func hasSharePred(mutation *graphp.Mutation) bool {
for _, nq := range mutation.Set {
if nq.Predicate == INTERNAL_SHARE {
return true
}
}

for _, nq := range mutation.Del {
if nq.Predicate == INTERNAL_SHARE {
return true
}
}
return false
}

type dashboardState struct {
Share bool `json:"share"`
SharePred string `json:"share_pred"`
}

func initialState(w http.ResponseWriter, r *http.Request) {
addCorsHeaders(w)
if r.Method != "GET" {
http.Error(w, x.ErrorInvalidMethod, http.StatusBadRequest)
return
}

ds := dashboardState{
Share: !*noshare,
SharePred: INTERNAL_SHARE,
}

js, err := json.Marshal(ds)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(js)
}
Loading