MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / makeRequests

Method makeRequests

dgraph/cmd/live/batch.go:392–459  ·  view source on GitHub ↗

makeRequests can receive requests from batchNquads or directly from BatchSetWithMark. It doesn't need to batch the requests anymore. Batching is already done for it by the caller functions.

()

Source from the content-addressed store, hash-verified

390// It doesn't need to batch the requests anymore. Batching is already done for it by the
391// caller functions.
392func (l *loader) makeRequests() {
393 defer l.requestsWg.Done()
394 atomic.AddInt32(&l.conc, 1)
395 defer atomic.AddInt32(&l.conc, -1)
396
397 buffer := make([]*request, 0, l.opts.bufferSize)
398 var loops int
399 drain := func() {
400 i := 0
401 for _, req := range buffer {
402 loops++
403 // If there is no conflict in req, we will use it
404 // and then it would shift all the other reqs in buffer
405 if !l.addConflictKeys(req) {
406 buffer[i] = req
407 i++
408 continue
409 }
410 // Req will no longer be part of a buffer
411 l.request(req)
412 }
413 buffer = buffer[:i]
414 }
415
416 t := time.Tick(5 * time.Second)
417
418loop:
419 for {
420 select {
421 case req, ok := <-l.reqs:
422 if !ok {
423 break loop
424 }
425 req.conflicts = l.conflictKeysForReq(req)
426 if l.addConflictKeys(req) {
427 l.request(req)
428 } else {
429 buffer = append(buffer, req)
430 }
431
432 case <-t:
433 for {
434 drain()
435 if len(buffer) < l.opts.bufferSize {
436 break
437 }
438 }
439 }
440 }
441
442 for req := range l.reqs {
443 req.conflicts = l.conflictKeysForReq(req)
444 if l.addConflictKeys(req) {
445 l.request(req)
446 } else {
447 buffer = append(buffer, req)
448 }
449

Callers 1

setupFunction · 0.95

Calls 4

addConflictKeysMethod · 0.95
requestMethod · 0.95
conflictKeysForReqMethod · 0.95
DoneMethod · 0.45

Tested by

no test coverage detected