// Limit only evaluator
168047
func (m *Projection) limitEvaluator() MessageHandler {

	out := m.MessageOut()
	limit := m.p.Stmt.Limit
	if limit == 0 {
		limit = math.MaxInt32
	}

	rowCt := 0
	return func(ctx *plan.Context, msg schema.Message) bool {

		select {
		case <-m.SigChan():
			u.Debugf("%p closed, returning", m)
			return false
		default:
		}

		if rowCt >= limit {
			if rowCt == limit {
				//u.Debugf("%p Projection reaching Limit!!! rowct:%v  limit:%v", m, rowCt, limit)
				out <- nil // Sending nil message is a message to downstream to shutdown
				//m.Close()
				m.Quit()
			}
			rowCt++
			//return false
			return true // swallow it
		}
		rowCt++

		select {
		case out <- msg:
			return true
		case <-m.SigChan():
			return false
		}
	}
}
724516
func (lrs LinearRegressionSeries) GetLimit() int {
	if lrs.Limit == 0 {
		return lrs.InnerSeries.Len()
	}
	return lrs.Limit
}
691722
func (m *MockCoreV1Interface) LimitRanges(arg0 string) v11.LimitRangeInterface {
	ret := m.ctrl.Call(m, "LimitRanges", arg0)
	ret0, _ := ret[0].(v11.LimitRangeInterface)
	return ret0
}
1126813
func (bldr *aeBackupKindQueryBuilder) Limit(limit int) *aeBackupKindQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
110136
func (bldr *aeBackupInformationKindTypeInfoQueryBuilder) Limit(limit int) *aeBackupInformationKindTypeInfoQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
718859
func (s *SelectQuery) Limit(limit int64) *SelectQuery {
	s.limit = limit
	return s
}
335897
func NewErroringLimiter(limit Allower) endpoint.Middleware {
	return func(next endpoint.Endpoint) endpoint.Endpoint {
		return func(ctx context.Context, request interface{}) (interface{}, error) {
			if !limit.Allow() {
				return nil, ErrLimited
			}
			return next(ctx, request)
		}
	}
}
1095115
func (bldr *UserQueryBuilder) Limit(limit int) *UserQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
221250
func newLimitIterator(itr iterator, maxRowID, maxColumnID uint64) *limitIterator { // nolint: unparam
	return &limitIterator{
		itr:         itr,
		maxRowID:    maxRowID,
		maxColumnID: maxColumnID,
	}
}
898314
func (l *Limiter) LimitReached(key string) bool {
	if l.isUsingTokenBucketsWithTTL() {
		return l.limitReachedWithDefaultTokenBucketTTL(key)
	}
	return l.limitReachedNoTokenBucketTTL(key)
}
862652
func (rl *RateLimiter) Limit() bool {
	// Calculate the number of ns that have passed since our last call
	now := unixNano()
	passed := now - atomic.SwapUint64(&rl.lastCheck, now)

	// Add them to our allowance
	rate := atomic.LoadUint64(&rl.rate)
	current := atomic.AddUint64(&rl.allowance, passed*rate)

	// Ensure our allowance is not over maximum
	if max := atomic.LoadUint64(&rl.max); current > max {
		atomic.AddUint64(&rl.allowance, max-current)
		current = max
	}

	// If our allowance is less than one unit, rate-limit!
	if current < rl.unit {
		return true
	}

	// Not limited, subtract a unit
	atomic.AddUint64(&rl.allowance, -rl.unit)
	return false
}
533807
func (b *SelectBuilder) Limit(limit uint) *SelectBuilder {
	b.limit = limit
	return b
}
292107
func NewLimiter(config LimiterConfig) (*Limiter, error) {
	var err error
	limiter := Limiter{}

	limiter.ConnectionsLimiter, err = NewConnectionsLimiter(config)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	limiter.rateLimiter, err = NewRateLimiter(config)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return &limiter, nil
}
596409
func (prs PolynomialRegressionSeries) GetLimit() int {
	if prs.Limit == 0 {
		return prs.InnerSeries.Len()
	}
	return prs.Limit
}
771866
func (b *DeleteBuilder) Limit(count interface{}) *DeleteBuilder {
	if b.Delete.Limit == nil {
		b.Delete.Limit = &Limit{}
	}
	b.Delete.Limit.Rowcount = makeValExpr(count)
	return b
}
357711
func EvalFilter(node EvalNode, fn EvalNodeFilterFunc) EvalNode {
	if f, ok := node.(EvalNodeFilterable); ok {
		f.Filter(fn)
		return node
	}

	return fn(node)
}
689844
func (bldr *aeDataQueryBuilder) Limit(limit int) *aeDataQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}