MCPcopy Create free account
hub / github.com/deepflowio/deepflow / addBatch

Function addBatch

server/controller/prometheus/encoder/db_operation.go:26–47  ·  view source on GitHub ↗
(db *metadb.DB, toAdd []*T, resourceType string)

Source from the content-addressed store, hash-verified

24)
25
26func addBatch[T constraint.OperateBatchModel](db *metadb.DB, toAdd []*T, resourceType string) error {
27 count := len(toAdd)
28 offset := 1000
29 pages := count/offset + 1
30 if count%offset == 0 {
31 pages = count / offset
32 }
33 for i := 0; i < pages; i++ {
34 start := i * offset
35 end := (i + 1) * offset
36 if end > count {
37 end = count
38 }
39 oneP := toAdd[start:end]
40 err := db.Clauses(clause.Returning{}).Create(&oneP).Error
41 if err != nil {
42 return err
43 }
44 log.Infof("add %d %s success", len(oneP), resourceType, db.LogPrefixORGID)
45 }
46 return nil
47}

Callers 8

encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85
encodeMethod · 0.85

Calls 2

CreateMethod · 0.45
InfofMethod · 0.45

Tested by

no test coverage detected