MCPcopy Create free account
hub / github.com/couchbase/cbft / execute

Function execute

pindex_bleve.go:2532–2578  ·  view source on GitHub ↗
(bdp []*BleveDestPartition, bdpMaxSeqNums []uint64,
	bindex bleve.Index, batch *bleve.Batch)

Source from the content-addressed store, hash-verified

2530}
2531
2532func execute(bdp []*BleveDestPartition, bdpMaxSeqNums []uint64,
2533 bindex bleve.Index, batch *bleve.Batch) (bool, error) {
2534 if batch == nil {
2535 return false, fmt.Errorf("pindex_bleve: executeBatch batch nil")
2536 }
2537
2538 if bindex == nil {
2539 return false, fmt.Errorf("pindex_bleve: executeBatch bindex already closed")
2540 }
2541
2542 batchTotalDocsSize := batch.TotalDocsSize()
2543 atomic.AddUint64(&BatchBytesAdded, batchTotalDocsSize)
2544
2545 err := cbgt.Timer(func() error {
2546 atomic.AddUint64(&aggregateBDPStats.TotExecuteBatchBeg, 1)
2547 err := bindex.Batch(batch)
2548 atomic.AddUint64(&aggregateBDPStats.TotExecuteBatchEnd, 1)
2549 if err != nil && err != bleve.ErrorIndexClosed {
2550 log.Errorf("pindex_bleve: executeBatch over `%v`, err: %+v ",
2551 bindex.Name(), err)
2552 }
2553 return err
2554 }, bdp[0].bdest.stats.TimerBatchStore)
2555
2556 if err != nil {
2557 return false, err
2558 }
2559
2560 atomic.AddUint64(&BatchBytesRemoved, batchTotalDocsSize)
2561
2562 for i, t := range bdp {
2563 t.m.Lock()
2564 if bdpMaxSeqNums[i] > atomic.LoadUint64(&t.seqMaxBatch) {
2565 atomic.StoreUint64(&t.seqMaxBatch, bdpMaxSeqNums[i])
2566 }
2567 for t.cwrQueue.Len() > 0 &&
2568 t.cwrQueue[0].ConsistencySeq <= atomic.LoadUint64(&t.seqMaxBatch) {
2569 cwr := heap.Pop(&t.cwrQueue).(*cbgt.ConsistencyWaitReq)
2570 if cwr != nil && cwr.DoneCh != nil {
2571 close(cwr.DoneCh)
2572 }
2573 }
2574 t.m.Unlock()
2575 }
2576
2577 return true, nil
2578}
2579
2580// ---------------------------------------------------------
2581

Callers 1

executeBatchFunction · 0.85

Calls 3

LenMethod · 0.80
BatchMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected