Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
49c59044
Commit
49c59044
authored
9 years ago
by
Ashwin
Browse files
Options
Downloads
Patches
Plain Diff
Make getUid global
parent
90c93200
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
loader/loader.go
+32
-15
32 additions, 15 deletions
loader/loader.go
rdf/parse.go
+3
-3
3 additions, 3 deletions
rdf/parse.go
with
35 additions
and
18 deletions
loader/loader.go
+
32
−
15
View file @
49c59044
...
...
@@ -152,25 +152,42 @@ func (s *state) handleNQuads(wg *sync.WaitGroup) {
func
(
s
*
state
)
handleNQuadsWhileAssign
(
wg
*
sync
.
WaitGroup
)
{
for
nq
:=
range
s
.
cnq
{
if
farm
.
Fingerprint64
([]
byte
(
nq
.
Subject
))
%
s
.
mod
!=
0
{
//
Ignore due to mod sampl
ing
.
//
This instance shouldnt assign UID to this str
ing
atomic
.
AddUint64
(
&
s
.
ctr
.
ignored
,
1
)
continue
}
edge
,
err
:
=
n
q
.
ToEdge
()
for
err
!=
nil
{
// Just put in a retry loop to tackle temporary errors.
if
err
==
posting
.
E_TMP_ERROR
{
time
.
Sleep
(
time
.
Microsecond
)
}
else
{
glog
.
WithError
(
err
)
.
WithField
(
"nq"
,
nq
)
.
Error
(
"While converting to edge"
)
return
}
else
{
_
,
err
:=
rdf
.
GetUid
(
nq
.
Subject
)
for
err
!
=
n
il
{
// Just put in a retry loop to tackle temporary errors.
if
err
==
posting
.
E_TMP_ERROR
{
time
.
Sleep
(
time
.
Microsecond
)
}
else
{
glog
.
WithError
(
err
)
.
WithField
(
"nq.Subject"
,
nq
.
Subject
)
.
Error
(
"While getting UID"
)
return
}
_
,
err
=
rdf
.
GetUid
(
nq
.
Subject
)
}
edge
,
err
=
nq
.
ToEdge
()
}
glog
.
Info
(
edge
);
if
len
(
nq
.
ObjectId
)
==
0
||
farm
.
Fingerprint64
([]
byte
(
nq
.
ObjectId
))
%
s
.
mod
!=
0
{
// This instance shouldnt or cant assign UID to this string
atomic
.
AddUint64
(
&
s
.
ctr
.
ignored
,
1
)
continue
}
else
{
_
,
err
:=
rdf
.
GetUid
(
nq
.
ObjectId
)
for
err
!=
nil
{
// Just put in a retry loop to tackle temporary errors.
if
err
==
posting
.
E_TMP_ERROR
{
time
.
Sleep
(
time
.
Microsecond
)
}
else
{
glog
.
WithError
(
err
)
.
WithField
(
"nq.ObjectId"
,
nq
.
ObjectId
)
.
Error
(
"While getting UID"
)
return
}
_
,
err
=
rdf
.
GetUid
(
nq
.
ObjectId
)
}
}
}
wg
.
Done
()
}
...
...
This diff is collapsed.
Click to expand it.
rdf/parse.go
+
3
−
3
View file @
49c59044
...
...
@@ -36,7 +36,7 @@ type NQuad struct {
Language
string
}
func
g
etUid
(
s
string
)
(
uint64
,
error
)
{
func
G
etUid
(
s
string
)
(
uint64
,
error
)
{
if
strings
.
HasPrefix
(
s
,
"_uid_:"
)
{
return
strconv
.
ParseUint
(
s
[
6
:
],
0
,
64
)
}
...
...
@@ -44,13 +44,13 @@ func getUid(s string) (uint64, error) {
}
func
(
nq
NQuad
)
ToEdge
()
(
result
x
.
DirectedEdge
,
rerr
error
)
{
sid
,
err
:=
g
etUid
(
nq
.
Subject
)
sid
,
err
:=
G
etUid
(
nq
.
Subject
)
if
err
!=
nil
{
return
result
,
err
}
result
.
Entity
=
sid
if
len
(
nq
.
ObjectId
)
>
0
{
oid
,
err
:=
g
etUid
(
nq
.
ObjectId
)
oid
,
err
:=
G
etUid
(
nq
.
ObjectId
)
if
err
!=
nil
{
return
result
,
err
}
...
...
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