// incUnitCountOp returns the operation to increment the application's unit count.
341619
func (a *Application) incUnitCountOp(asserts bson.D) txn.Op {
	op := txn.Op{
		C:      applicationsC,
		Id:     a.doc.DocID,
		Update: bson.D{{"$inc", bson.D{{"unitcount", 1}}}},
	}
	if len(asserts) > 0 {
		op.Assert = asserts
	}
	return op
}
1097184
func (s *RelationalDatabaseBundle) SetCpuCount(v int64) *RelationalDatabaseBundle {
	s.CpuCount = &v
	return s
}
297070
func (s *Scratch) countSimple(in []byte) (max int) {
	for _, v := range in {
		s.count[v]++
	}
	m := uint32(0)
	for i, v := range s.count[:] {
		if v > m {
			m = v
		}
		if v > 0 {
			s.symbolLen = uint16(i) + 1
		}
	}
	return int(m)
}
689510
func IncrementEventCountAndGetSession(ctx context.Context, unhandled bool) *Session {
	if s := ctx.Value(contextSessionKey); s != nil {
		if session, ok := s.(*Session); ok && !session.StartedAt.IsZero() {
			// It is not just getting back a default value
			ec := session.EventCounts
			if unhandled {
				ec.Unhandled++
			} else {
				ec.Handled++
			}
			return session
		}
	}
	return nil
}
894792
func MapGetByRankRangeCountOp(binName string, rank int, count int, returnType mapReturnType) *Operation {
	return newCDTCreateOperationIndexCount(_CDT_MAP_GET_BY_RANK_RANGE, _MAP_READ, binName, rank, count, returnType)
}
785120
func (f *fragment) incrementOpN() error {
	f.opN++
	if f.opN <= f.MaxOpN {
		return nil
	}

	if err := f.snapshot(); err != nil {
		return fmt.Errorf("snapshot: %s", err)
	}
	return nil
}
457421
func (l *upgradeSeriesResolver) NextOp(
	localState resolver.LocalState, remoteState remotestate.Snapshot, opFactory operation.Factory,
) (operation.Operation, error) {
	// If the unit has completed a pre-series-upgrade hook
	// (as noted by its state) then the uniter should idle in the face of all
	// remote state changes.
	if remoteState.UpgradeSeriesStatus == model.UpgradeSeriesPrepareCompleted {
		return nil, resolver.ErrDoNotProceed
	}

	if localState.Kind == operation.Continue {
		if localState.UpgradeSeriesStatus == model.UpgradeSeriesNotStarted &&
			remoteState.UpgradeSeriesStatus == model.UpgradeSeriesPrepareStarted {
			return opFactory.NewRunHook(hook.Info{Kind: hooks.PreSeriesUpgrade})
		}

		// The uniter's local state will be in the "not started" state if the
		// uniter was stopped for any reason, while performing a series upgrade.
		// If the uniter was not stopped then it will be in the "prepare completed"
		// state and likewise run the post upgrade hook.
		if (localState.UpgradeSeriesStatus == model.UpgradeSeriesNotStarted ||
			localState.UpgradeSeriesStatus == model.UpgradeSeriesPrepareCompleted) &&
			remoteState.UpgradeSeriesStatus == model.UpgradeSeriesCompleteStarted {
			return opFactory.NewRunHook(hook.Info{Kind: hooks.PostSeriesUpgrade})
		}

		// If the local state is completed but the remote state is not started,
		// then this means that the lock has been removed and the local uniter
		// state should be reset.
		if localState.UpgradeSeriesStatus == model.UpgradeSeriesCompleted &&
			remoteState.UpgradeSeriesStatus == model.UpgradeSeriesNotStarted {
			return opFactory.NewNoOpFinishUpgradeSeries()
		}
	}

	return nil, resolver.ErrNoOperation
}
1150615
func AddOp(bin *Bin) *Operation {
	return &Operation{opType: _ADD, binName: bin.Name, binValue: bin.Value}
}
1240960
func (s *precheckAppShim) AllUnits() ([]PrecheckUnit, error) {
	units, err := s.Application.AllUnits()
	if err != nil {
		return nil, errors.Trace(err)
	}
	out := make([]PrecheckUnit, 0, len(units))
	for _, unit := range units {
		out = append(out, unit)
	}
	return out, nil
}
1041723
func ListIncrementByOneWithPolicyOp(policy *ListPolicy, binName string, index int) *Operation {
	return &Operation{opType: _CDT_MODIFY, binName: binName, binValue: ListValue{_CDT_LIST_INCREMENT, IntegerValue(index), IntegerValue(1), IntegerValue(policy.attributes), IntegerValue(policy.flags)}, encoder: listGenericOpEncoder}
}
555499
func (a Amount) ToUnit(u AmountUnit) float64 {
	return float64(a) / math.Pow10(int(u+8))
}
11343
func (s *CirconusSink) IncrCounter(key []string, val float32) {
	flatKey := s.flattenKey(key)
	s.metrics.IncrementByValue(flatKey, uint64(val))
}
519792
func (o *oplogDoc) validOp(ns string) bool {
	return ns == o.Ns && (o.Op == "i" || o.Op == "d" || o.Op == "u")
}
560727
func WithWindowsCPUCount(count uint64) SpecOpts {
	return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
		if s.Windows.Resources == nil {
			s.Windows.Resources = &specs.WindowsResources{}
		}
		if s.Windows.Resources.CPU == nil {
			s.Windows.Resources.CPU = &specs.WindowsCPUResources{}
		}
		s.Windows.Resources.CPU.Count = &count
		return nil
	}
}
411934
func AppendOp(bin *Bin) *Operation {
	return &Operation{opType: _APPEND, binName: bin.Name, binValue: bin.Value}
}
611498
func (r *PCPRegistry) InstanceCount() int {
	r.indomlock.RLock()
	defer r.indomlock.RUnlock()

	return r.instanceCount
}
141868
func GetPseudoRowCountByColumnRanges(sc *stmtctx.StatementContext, tableRowCount float64, columnRanges []*ranger.Range, colIdx int) (float64, error) {
	var rowCount float64
	var err error
	for _, ran := range columnRanges {
		if ran.LowVal[colIdx].Kind() == types.KindNull && ran.HighVal[colIdx].Kind() == types.KindMaxValue {
			rowCount += tableRowCount
		} else if ran.LowVal[colIdx].Kind() == types.KindMinNotNull {
			nullCount := tableRowCount / pseudoEqualRate
			if ran.HighVal[colIdx].Kind() == types.KindMaxValue {
				rowCount += tableRowCount - nullCount
			} else if err == nil {
				lessCount := tableRowCount / pseudoLessRate
				rowCount += lessCount - nullCount
			}
		} else if ran.HighVal[colIdx].Kind() == types.KindMaxValue {
			rowCount += tableRowCount / pseudoLessRate
		} else {
			compare, err1 := ran.LowVal[colIdx].CompareDatum(sc, &ran.HighVal[colIdx])
			if err1 != nil {
				return 0, errors.Trace(err1)
			}
			if compare == 0 {
				rowCount += tableRowCount / pseudoEqualRate
			} else {
				rowCount += tableRowCount / pseudoBetweenRate
			}
		}
		if err != nil {
			return 0, errors.Trace(err)
		}
	}
	if rowCount > tableRowCount {
		rowCount = tableRowCount
	}
	return rowCount, nil
}