// processOwned creates vindex entries for the values of an owned column for InsertSharded.
434781
func (ins *Insert) processOwned(vcursor VCursor, vindexColumnsKeys [][]sqltypes.Value, colVindex *vindexes.ColumnVindex, bv map[string]*querypb.BindVariable, ksids [][]byte) error {
	for rowNum, rowColumnKeys := range vindexColumnsKeys {
		for colIdx, vindexKey := range rowColumnKeys {
			col := colVindex.Columns[colIdx]
			bv[insertVarName(col, rowNum)] = sqltypes.ValueBindVariable(vindexKey)
		}
	}
	return colVindex.Vindex.(vindexes.Lookup).Create(vcursor, vindexColumnsKeys, ksids, false /* ignoreMode */)
}
350551
func (b *Builder) Done() *Table {
	if len(b.t.colNames) == 0 {
		return new(Table)
	}
	t := b.t
	b.t = Table{}
	return &t
}
407409
func (w *Waiter) Done() {
	w.Lock()
	w.cnt--
	if w.cnt < 0 {
		panic("wait count dropped < 0")
	}
	if w.cnt == 0 {
		w.cv.Broadcast()
	}
	w.Unlock()
}
1111814
func (s *CACertificateDescription) SetOwnedBy(v string) *CACertificateDescription {
	s.OwnedBy = &v
	return s
}
651544
func (a *UnitAgent) Done(err error) {
	a.errReason = err
	close(a.dead)
}
439978
func (b *rescanBatch) done(err error) {
	for _, c := range b.errChans {
		c <- err
	}
}
792041
func ProcessRegisteredConfigs(ctx types.Context) {
	for r := range ConfigRegs(ctx) {
		gofig.Register(r)
	}
}
823523
func (t *servingTask) done() uint64 {
	t.servingTime += uint64(mclock.Now())
	close(t.token)
	return t.servingTime
}
740844
func filteredFinishedInvs(raw []byte, oldest time.Time) ([]*internal.FinishedInvocation, error) {
	invs, err := unmarshalFinishedInvs(raw)
	if err != nil {
		return nil, err
	}
	filtered := make([]*internal.FinishedInvocation, 0, len(invs))
	for _, inv := range invs {
		if google.TimeFromProto(inv.Finished).After(oldest) {
			filtered = append(filtered, inv)
		}
	}
	return filtered, nil
}
763299
func (r *reader) Done(err error) {
	q := readerReport{
		t:    time.Now(),
		pos:  r.pos,
		size: r.size,
		bps:  &r.bps,
		err:  err,
	}

	select {
	case r.ch <- q:
		close(r.ch)
	case <-r.ctx.Done():
	}
}
26059
func (s *TrustedAdvisorResourcesSummary) SetResourcesProcessed(v int64) *TrustedAdvisorResourcesSummary {
	s.ResourcesProcessed = &v
	return s
}
19343
func (scw *LegacySplitCloneWorker) processData(ctx context.Context, dbNames []string, td *tabletmanagerdatapb.TableDefinition, tableIndex int, rr ResultReader, rowSplitter *RowSplitter, insertChannels []chan string, destinationPackCount int) error {
	// Store the baseCmd per destination shard because each tablet may have a
	// different dbName.
	baseCmds := make([]string, len(dbNames))
	for i, dbName := range dbNames {
		baseCmds[i] = "INSERT INTO " + sqlescape.EscapeID(dbName) + "." + sqlescape.EscapeID(td.Name) + " (" + strings.Join(escapeAll(td.Columns), ", ") + ") VALUES "
	}
	sr := rowSplitter.StartSplit()
	packCount := 0

	fields := rr.Fields()
	for {
		r, err := rr.Next()
		if err != nil {
			// we are done, see if there was an error
			if err != io.EOF {
				return err
			}

			// send the remainder if any (ignoring
			// the return value, we don't care
			// here if we're aborted)
			if packCount > 0 {
				rowSplitter.Send(fields, sr, baseCmds, insertChannels, ctx.Done())
			}
			return nil
		}

		// Split the rows by keyspace ID, and insert each chunk into each destination
		if err := rowSplitter.Split(sr, r.Rows); err != nil {
			return vterrors.Wrapf(err, "RowSplitter failed for table %v", td.Name)
		}
		scw.tableStatusList.addCopiedRows(tableIndex, len(r.Rows))

		// see if we reach the destination pack count
		packCount++
		if packCount < destinationPackCount {
			continue
		}

		// send the rows to be inserted
		if aborted := rowSplitter.Send(fields, sr, baseCmds, insertChannels, ctx.Done()); aborted {
			return nil
		}

		// and reset our row buffer
		sr = rowSplitter.StartSplit()
		packCount = 0
	}
}
1092197
func (pb *primitiveBuilder) processDMLTable(tableExprs sqlparser.TableExprs) (*routeOption, error) {
	if err := pb.processTableExprs(tableExprs); err != nil {
		return nil, err
	}
	rb, ok := pb.bldr.(*route)
	if !ok {
		return nil, errors.New("unsupported: multi-shard or vindex write statement")
	}
	ro := rb.routeOptions[0]
	for _, sub := range ro.substitutions {
		*sub.oldExpr = *sub.newExpr
	}
	return ro, nil
}
1031093
func (cm *ClientManager) processed(node *ClientNode, maxCost, realCost uint64, now mclock.AbsTime) {
	cm.lock.Lock()
	defer cm.lock.Unlock()

	if realCost > maxCost {
		realCost = maxCost
	}
	cm.updateNodeRc(node, int64(maxCost-realCost), &node.params, now)
	if uint64(node.corrBufValue) > node.bufValue {
		if node.log != nil {
			node.log.add(now, fmt.Sprintf("corrected  bv=%d  oldBv=%d", node.corrBufValue, node.bufValue))
		}
		node.bufValue = uint64(node.corrBufValue)
	}
}
120339
func (s *StanServer) processRecoveredChannels(channels map[string]*stores.RecoveredChannel) ([]*subState, error) {
	allSubs := make([]*subState, 0, 16)

	for channelName, recoveredChannel := range channels {
		channel, err := s.channels.create(s, channelName, recoveredChannel.Channel)
		if err != nil {
			return nil, err
		}
		if !s.isClustered {
			// Get the recovered subscriptions for this channel.
			for _, recSub := range recoveredChannel.Subscriptions {
				sub := s.recoverOneSub(channel, recSub.Sub, recSub.Pending, nil)
				if sub != nil {
					// Subscribe to subscription ACKs
					if err := sub.startAckSub(s.nca, s.processAckMsg); err != nil {
						return nil, err
					}
					allSubs = append(allSubs, sub)
				}
			}
			// Now that we have recovered possible subscriptions for this channel,
			// check if we should start the delete timer.
			if channel.activity != nil {
				s.channels.maybeStartChannelDeleteTimer(channelName, channel)
			}
		}
	}
	return allSubs, nil
}
693249
func (g *Gormigrate) checkReservedID() error {
	for _, m := range g.migrations {
		if m.ID == initSchemaMigrationID {
			return &ReservedIDError{ID: m.ID}
		}
	}
	return nil
}
817527
func (p *ConnPool) afterConnectionCreated(c *Conn) (*Conn, error) {
	if p.afterConnect != nil {
		err := p.afterConnect(c)
		if err != nil {
			c.die(err)
			return nil, err
		}
	}

	for _, ps := range p.preparedStatements {
		if _, err := c.Prepare(ps.Name, ps.SQL); err != nil {
			c.die(err)
			return nil, err
		}
	}

	return c, nil
}