Skip to content
Snippets Groups Projects
Commit 8a1b0c32 authored by Ashwin's avatar Ashwin
Browse files

Move code into a function

parent a44f7047
No related branches found
No related tags found
No related merge requests found
......@@ -144,48 +144,40 @@ func (s *state) handleNQuads(wg *sync.WaitGroup) {
wg.Done()
}
func (s *state) getUidForString(str string) {
_, err := rdf.GetUid(str, s.instanceIdx, s.numInstances)
for err != nil {
// Just put in a retry loop to tackle temporary errors.
if err == posting.E_TMP_ERROR {
time.Sleep(time.Microsecond)
glog.WithError(err).WithField("nq.Subject", str).
Error("Temporary error")
} else {
glog.WithError(err).WithField("nq.Subject", str).
Error("While getting UID")
return
}
_, err = rdf.GetUid(str, s.instanceIdx, s.numInstances)
}
}
func (s *state) handleNQuadsWhileAssign(wg *sync.WaitGroup) {
for nq := range s.cnq {
if farm.Fingerprint64([]byte(nq.Subject))%s.numInstances != s.instanceIdx {
// This instance shouldnt assign UID to this string
atomic.AddUint64(&s.ctr.ignored, 1)
} else {
_, err := rdf.GetUid(nq.Subject, s.instanceIdx, s.numInstances)
for err != nil {
// Just put in a retry loop to tackle temporary errors.
if err == posting.E_TMP_ERROR {
time.Sleep(time.Microsecond)
glog.WithError(err).WithField("nq.Subject", nq.Subject).
Error("Temporary error")
} else {
glog.WithError(err).WithField("nq.Subject", nq.Subject).
Error("While getting UID")
return
}
_, err = rdf.GetUid(nq.Subject, s.instanceIdx, s.numInstances)
}
s.getUidForString(nq.Subject)
}
if len(nq.ObjectId) == 0 || farm.Fingerprint64([]byte(nq.ObjectId))%s.numInstances != s.instanceIdx {
// This instance shouldnt or cant assign UID to this string
atomic.AddUint64(&s.ctr.ignored, 1)
} else {
_, err := rdf.GetUid(nq.ObjectId, s.instanceIdx, s.numInstances)
for err != nil {
// Just put in a retry loop to tackle temporary errors.
if err == posting.E_TMP_ERROR {
time.Sleep(time.Microsecond)
glog.WithError(err).WithField("nq.Subject", nq.Subject).
Error("Temporary error")
} else {
glog.WithError(err).WithField("nq.ObjectId", nq.ObjectId).
Error("While getting UID")
return
}
_, err = rdf.GetUid(nq.ObjectId, s.instanceIdx, s.numInstances)
}
s.getUidForString(nq.ObjectId)
}
}
wg.Done()
}
......
......@@ -255,7 +255,7 @@ func NewGraph(euid uint64, exid string) (*SubGraph, error) {
// This would set the Result field in SubGraph,
// and populate the children for attributes.
if len(exid) > 0 {
u, err := uid.GetOrAssign(exid, 0, 1) // mod = 0, numInstances = 1 by default
u, err := uid.GetOrAssign(exid, 0, 1) // instanceIdx = 0, numInstances = 1 by default
if err != nil {
x.Err(glog, err).WithField("xid", exid).Error(
"While GetOrAssign uid from external id")
......
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