Skip to content
Snippets Groups Projects
Commit 49c59044 authored by Ashwin's avatar Ashwin
Browse files

Make getUid global

parent 90c93200
No related branches found
No related tags found
No related merge requests found
......@@ -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 sampling.
// This instance shouldnt assign UID to this string
atomic.AddUint64(&s.ctr.ignored, 1)
continue
}
edge, err := nq.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 != 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.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()
}
......
......@@ -36,7 +36,7 @@ type NQuad struct {
Language string
}
func getUid(s string) (uint64, error) {
func GetUid(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 := getUid(nq.Subject)
sid, err := GetUid(nq.Subject)
if err != nil {
return result, err
}
result.Entity = sid
if len(nq.ObjectId) > 0 {
oid, err := getUid(nq.ObjectId)
oid, err := GetUid(nq.ObjectId)
if err != nil {
return result, err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment