Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
68c01f36
Commit
68c01f36
authored
9 years ago
by
Ashwin
Browse files
Options
Downloads
Patches
Plain Diff
Add mod sharding for attributes
parent
90140682
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gql/parser.go
+0
-1
0 additions, 1 deletion
gql/parser.go
loader/loader.go
+10
-4
10 additions, 4 deletions
loader/loader.go
query/query.go
+5
-5
5 additions, 5 deletions
query/query.go
server/main.go
+1
-1
1 addition, 1 deletion
server/main.go
with
16 additions
and
11 deletions
gql/parser.go
+
0
−
1
View file @
68c01f36
...
@@ -23,7 +23,6 @@ import (
...
@@ -23,7 +23,6 @@ import (
"github.com/dgraph-io/dgraph/lex"
"github.com/dgraph-io/dgraph/lex"
"github.com/dgraph-io/dgraph/query"
"github.com/dgraph-io/dgraph/query"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/dgraph/x"
)
)
...
...
This diff is collapsed.
Click to expand it.
loader/loader.go
+
10
−
4
View file @
68c01f36
...
@@ -137,10 +137,16 @@ func (s *state) handleNQuads(wg *sync.WaitGroup, rwStore, rStore *store.Store) {
...
@@ -137,10 +137,16 @@ func (s *state) handleNQuads(wg *sync.WaitGroup, rwStore, rStore *store.Store) {
edge
,
err
=
nq
.
ToEdge
(
s
.
instanceIdx
,
s
.
numInstances
,
rStore
)
edge
,
err
=
nq
.
ToEdge
(
s
.
instanceIdx
,
s
.
numInstances
,
rStore
)
}
}
key
:=
posting
.
Key
(
edge
.
Entity
,
edge
.
Attribute
)
// Only handle this edge if the attribute satisfies the modulo rule
plist
:=
posting
.
GetOrCreate
(
key
,
rwStore
)
if
farm
.
Fingerprint64
([]
byte
(
nq
.
Attribute
))
%
s
.
numInstances
!=
s
.
instanceIdx
{
plist
.
AddMutation
(
edge
,
posting
.
Set
)
key
:=
posting
.
Key
(
edge
.
Entity
,
edge
.
Attribute
)
atomic
.
AddUint64
(
&
s
.
ctr
.
processed
,
1
)
plist
:=
posting
.
GetOrCreate
(
key
,
rwStore
)
plist
.
AddMutation
(
edge
,
posting
.
Set
)
atomic
.
AddUint64
(
&
s
.
ctr
.
processed
,
1
)
}
else
{
atomic
.
AddUint64
(
&
s
.
ctr
.
ignored
,
1
)
}
}
}
wg
.
Done
()
wg
.
Done
()
}
}
...
...
This diff is collapsed.
Click to expand it.
query/query.go
+
5
−
5
View file @
68c01f36
...
@@ -252,11 +252,11 @@ func (g *SubGraph) ToJson(l *Latency) (js []byte, rerr error) {
...
@@ -252,11 +252,11 @@ func (g *SubGraph) ToJson(l *Latency) (js []byte, rerr error) {
return
json
.
Marshal
(
r
)
return
json
.
Marshal
(
r
)
}
}
func
NewGraph
(
euid
uint64
,
exid
string
,
pstore
*
store
.
Store
)
(
*
SubGraph
,
error
)
{
func
NewGraph
(
euid
uint64
,
exid
string
)
(
*
SubGraph
,
error
)
{
// This would set the Result field in SubGraph,
// This would set the Result field in SubGraph,
// and populate the children for attributes.
// and populate the children for attributes.
if
len
(
exid
)
>
0
{
if
len
(
exid
)
>
0
{
u
,
err
:=
uid
.
GetOrAssign
(
exid
,
0
,
1
,
pstore
)
// instanceIdx = 0, numInstances = 1 by default
u
,
err
:=
uid
.
GetOrAssign
(
exid
,
0
,
1
)
// instanceIdx = 0, numInstances = 1 by default
if
err
!=
nil
{
if
err
!=
nil
{
x
.
Err
(
glog
,
err
)
.
WithField
(
"xid"
,
exid
)
.
Error
(
x
.
Err
(
glog
,
err
)
.
WithField
(
"xid"
,
exid
)
.
Error
(
"While GetOrAssign uid from external id"
)
"While GetOrAssign uid from external id"
)
...
@@ -382,11 +382,11 @@ func sortedUniqueUids(r *task.Result) (sorted []uint64, rerr error) {
...
@@ -382,11 +382,11 @@ func sortedUniqueUids(r *task.Result) (sorted []uint64, rerr error) {
return
sorted
,
nil
return
sorted
,
nil
}
}
func
ProcessGraph
(
sg
*
SubGraph
,
rch
chan
error
,
pstore
*
store
.
Store
)
{
func
ProcessGraph
(
sg
*
SubGraph
,
rch
chan
error
)
{
var
err
error
var
err
error
if
len
(
sg
.
query
)
>
0
&&
sg
.
Attr
!=
"_root_"
{
if
len
(
sg
.
query
)
>
0
&&
sg
.
Attr
!=
"_root_"
{
// This task execution would go over the wire in later versions.
// This task execution would go over the wire in later versions.
sg
.
result
,
err
=
posting
.
ProcessTask
(
sg
.
query
,
pstore
)
sg
.
result
,
err
=
posting
.
ProcessTask
(
sg
.
query
)
if
err
!=
nil
{
if
err
!=
nil
{
x
.
Err
(
glog
,
err
)
.
Error
(
"While processing task."
)
x
.
Err
(
glog
,
err
)
.
Error
(
"While processing task."
)
rch
<-
err
rch
<-
err
...
@@ -425,7 +425,7 @@ func ProcessGraph(sg *SubGraph, rch chan error, pstore *store.Store) {
...
@@ -425,7 +425,7 @@ func ProcessGraph(sg *SubGraph, rch chan error, pstore *store.Store) {
for
i
:=
0
;
i
<
len
(
sg
.
Children
);
i
++
{
for
i
:=
0
;
i
<
len
(
sg
.
Children
);
i
++
{
child
:=
sg
.
Children
[
i
]
child
:=
sg
.
Children
[
i
]
child
.
query
=
createTaskQuery
(
child
.
Attr
,
sorted
)
child
.
query
=
createTaskQuery
(
child
.
Attr
,
sorted
)
go
ProcessGraph
(
child
,
childchan
,
pstore
)
go
ProcessGraph
(
child
,
childchan
)
}
}
// Now get all the results back.
// Now get all the results back.
...
...
This diff is collapsed.
Click to expand it.
server/main.go
+
1
−
1
View file @
68c01f36
...
@@ -125,7 +125,7 @@ func main() {
...
@@ -125,7 +125,7 @@ func main() {
clog
.
Init
()
clog
.
Init
()
defer
clog
.
Close
()
defer
clog
.
Close
()
posting
.
Init
(
clog
)
posting
.
Init
(
ps
,
clog
)
http
.
HandleFunc
(
"/query"
,
queryHandler
)
http
.
HandleFunc
(
"/query"
,
queryHandler
)
glog
.
WithField
(
"port"
,
*
port
)
.
Info
(
"Listening for requests..."
)
glog
.
WithField
(
"port"
,
*
port
)
.
Info
(
"Listening for requests..."
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment