Skip to content

Commit 9565c1e

Browse files
Merge branch 'main' into unsafe_slice
2 parents aeedcb9 + 4120211 commit 9565c1e

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[![GitHub Repo stars](https://img.shields.io/github/stars/dgraph-io/dgraph)](https://github.com/dgraph-io/dgraph/stargazers)
1414
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/dgraph-io/dgraph)](https://github.com/dgraph-io/dgraph/commits/main/)
1515
[![Go Report Card](https://goreportcard.com/badge/github.com/dgraph-io/dgraph)](https://goreportcard.com/report/github.com/dgraph-io/dgraph)
16+
[![Docker Pulls](https://img.shields.io/docker/pulls/dgraph/dgraph)](https://hub.docker.com/r/dgraph/dgraph)
1617

1718
Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It provides
1819
ACID transactions, consistent replication, and linearizable reads. It's built from the ground up to
@@ -29,9 +30,7 @@ and [Protocol Buffers](https://developers.google.com/protocol-buffers/) over
2930
## Status
3031

3132
Dgraph is at [version v25][rel] and is production-ready. Apart from the vast open source community,
32-
it is being used in production at multiple Fortune 500 companies, and by
33-
[Intuit Katlas](https://github.com/intuit/katlas) and
34-
[VMware Purser](https://github.com/vmware/purser).
33+
it is being used in production at multiple Fortune 500 companies.
3534

3635
[rel]: https://github.com/dgraph-io/dgraph/releases/tag/v25.0.0
3736

@@ -84,6 +83,7 @@ the GOPATH environment variable is not set.
8483
```bash
8584
git clone https://github.com/dgraph-io/dgraph.git
8685
cd dgraph
86+
make setup
8787
make install
8888
```
8989

worker/task.go

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -823,9 +823,9 @@ func (qs *queryState) handleUidPostings(
823823
needFiltering := needsStringFiltering(srcFn, q.Langs, q.Attr)
824824
isList := schema.State().IsList(q.Attr)
825825

826-
errCh := make(chan error, numGo)
827826
outputs := make([]*pb.Result, numGo)
828827

828+
eg, egCtx := errgroup.WithContext(ctx)
829829
calculate := func(start, end int) error {
830830
x.AssertTrue(start%width == 0)
831831
out := &pb.Result{}
@@ -834,8 +834,8 @@ func (qs *queryState) handleUidPostings(
834834
for i := start; i < end; i++ {
835835
if i%100 == 0 {
836836
select {
837-
case <-ctx.Done():
838-
return ctx.Err()
837+
case <-egCtx.Done():
838+
return egCtx.Err()
839839
default:
840840
}
841841
}
@@ -978,14 +978,12 @@ func (qs *queryState) handleUidPostings(
978978
if end > srcFn.n {
979979
end = srcFn.n
980980
}
981-
go func(start, end int) {
982-
errCh <- calculate(start, end)
983-
}(start, end)
981+
eg.Go(func() error {
982+
return calculate(start, end)
983+
})
984984
}
985-
for range numGo {
986-
if err := <-errCh; err != nil {
987-
return err
988-
}
985+
if err := eg.Wait(); err != nil {
986+
return err
989987
}
990988
// All goroutines are done. Now attach their results.
991989
out := args.out
@@ -1635,11 +1633,20 @@ func (qs *queryState) filterGeoFunction(ctx context.Context, arg funcArgs) error
16351633
attribute.Int("num_go", numGo),
16361634
attribute.Int("width", width)))
16371635

1636+
eg, egCtx := errgroup.WithContext(ctx)
16381637
filtered := make([]*pb.List, numGo)
16391638
filter := func(idx, start, end int) error {
16401639
filtered[idx] = &pb.List{}
16411640
out := filtered[idx]
1642-
for _, uid := range uids.Uids[start:end] {
1641+
for i := start; i < end; i++ {
1642+
uid := uids.Uids[i]
1643+
if i%100 == 0 {
1644+
select {
1645+
case <-egCtx.Done():
1646+
return egCtx.Err()
1647+
default:
1648+
}
1649+
}
16431650
pl, err := qs.cache.Get(x.DataKey(attr, uid))
16441651
if err != nil {
16451652
return err
@@ -1661,21 +1668,19 @@ func (qs *queryState) filterGeoFunction(ctx context.Context, arg funcArgs) error
16611668
return nil
16621669
}
16631670

1664-
errCh := make(chan error, numGo)
16651671
for i := range numGo {
16661672
start := i * width
16671673
end := start + width
16681674
if end > len(uids.Uids) {
16691675
end = len(uids.Uids)
16701676
}
1671-
go func(idx, start, end int) {
1672-
errCh <- filter(idx, start, end)
1673-
}(i, start, end)
1677+
idx := i
1678+
eg.Go(func() error {
1679+
return filter(idx, start, end)
1680+
})
16741681
}
1675-
for range numGo {
1676-
if err := <-errCh; err != nil {
1677-
return err
1678-
}
1682+
if err := eg.Wait(); err != nil {
1683+
return err
16791684
}
16801685
final := &pb.List{}
16811686
for _, out := range filtered {

x/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ jemalloc enabled : %v
5353
GOMAXPROCS : %v
5454
Num CPUs : %v
5555
56-
For Dgraph official documentation, visit https://dgraph.io/docs.
57-
For discussions about Dgraph , visit https://discuss.dgraph.io.
56+
For Dgraph official documentation, visit https://docs.dgraph.io
57+
For discussions about Dgraph , visit https://github.com/orgs/dgraph-io/discussions
5858
5959
%s.
6060
© Istari Digital, Inc.

0 commit comments

Comments
 (0)