// NewPredicateMetadataFactory creates a PredicateMetadataFactory.
487730
func NewPredicateMetadataFactory(podLister algorithm.PodLister) PredicateMetadataProducer {
	factory := &PredicateMetadataFactory{
		podLister,
	}
	return factory.GetMetadata
}
587469
func NewContextFactory(config FactoryConfig) (ContextFactory, error) {
	unit, err := config.State.Unit(config.UnitTag)
	if err != nil {
		return nil, errors.Trace(err)
	}
	m, err := config.State.Model()
	if err != nil {
		return nil, errors.Trace(err)
	}
	var (
		machineTag names.MachineTag
		zone       string
	)
	if m.ModelType == model.IAAS {
		machineTag, err = unit.AssignedMachine()
		if err != nil {
			return nil, errors.Trace(err)
		}

		zone, err = unit.AvailabilityZone()
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	principal, ok, err := unit.PrincipalName()
	if err != nil {
		return nil, errors.Trace(err)
	} else if !ok {
		principal = ""
	}

	f := &contextFactory{
		unit:             unit,
		state:            config.State,
		tracker:          config.Tracker,
		paths:            config.Paths,
		modelUUID:        m.UUID,
		modelName:        m.Name,
		machineTag:       machineTag,
		getRelationInfos: config.GetRelationInfos,
		relationCaches:   map[int]*RelationCache{},
		storage:          config.Storage,
		rand:             rand.New(rand.NewSource(time.Now().Unix())),
		clock:            config.Clock,
		zone:             zone,
		principal:        principal,
		modelType:        m.ModelType,
	}
	return f, nil
}
502399
func NewMapRouter(defaultService string) MapRouter {
	return MapRouter{
		defaultService:            defaultService,
		serviceProcedures:         make(map[serviceProcedure]transport.Procedure),
		serviceProcedureEncodings: make(map[serviceProcedureEncoding]transport.Procedure),
		supportedEncodings:        make(map[serviceProcedure][]string),
		serviceNames:              map[string]struct{}{defaultService: {}},
	}
}
86343
func NewPreFilter() (*PreFilter, error) {
	// dyn{4,6} officially disabled for now due to missing
	// dump (get_next_key) from kernel side.
	c := preFilterConfig{
		dyn4Enabled: false,
		dyn6Enabled: false,
		fix4Enabled: true,
		fix6Enabled: true,
	}
	p := &PreFilter{
		revision: 1,
		config:   c,
	}
	// Only needed here given we access pinned maps.
	p.mutex.Lock()
	defer p.mutex.Unlock()
	return p.init()
}
704426
func NewDynamicSharedInformerFactory(client dynamic.Interface, defaultResync time.Duration) DynamicSharedInformerFactory {
	return NewFilteredDynamicSharedInformerFactory(client, defaultResync, metav1.NamespaceAll, nil)
}
933292
func NewAlphaGetMetadataArg(Path string) *AlphaGetMetadataArg {
	s := new(AlphaGetMetadataArg)
	s.Path = Path
	s.IncludeMediaInfo = false
	s.IncludeDeleted = false
	s.IncludeHasExplicitSharedMembers = false
	return s
}
751255
func (meta *predicateMetadata) ShallowCopy() PredicateMetadata {
	newPredMeta := &predicateMetadata{
		pod:                      meta.pod,
		podBestEffort:            meta.podBestEffort,
		podRequest:               meta.podRequest,
		serviceAffinityInUse:     meta.serviceAffinityInUse,
		ignoredExtendedResources: meta.ignoredExtendedResources,
	}
	newPredMeta.podPorts = append([]*v1.ContainerPort(nil), meta.podPorts...)
	newPredMeta.topologyPairsPotentialAffinityPods = newTopologyPairsMaps()
	newPredMeta.topologyPairsPotentialAffinityPods.appendMaps(meta.topologyPairsPotentialAffinityPods)
	newPredMeta.topologyPairsPotentialAntiAffinityPods = newTopologyPairsMaps()
	newPredMeta.topologyPairsPotentialAntiAffinityPods.appendMaps(meta.topologyPairsPotentialAntiAffinityPods)
	newPredMeta.topologyPairsAntiAffinityPodsMap = newTopologyPairsMaps()
	newPredMeta.topologyPairsAntiAffinityPodsMap.appendMaps(meta.topologyPairsAntiAffinityPodsMap)
	newPredMeta.serviceAffinityMatchingPodServices = append([]*v1.Service(nil),
		meta.serviceAffinityMatchingPodServices...)
	newPredMeta.serviceAffinityMatchingPodList = append([]*v1.Pod(nil),
		meta.serviceAffinityMatchingPodList...)
	return (PredicateMetadata)(newPredMeta)
}
63083
func NewFactory() *factory.KustFactory {
	return factory.NewKustFactory(
		kunstruct.NewKunstructuredFactoryImpl(),
		validator.NewKustValidator(),
		transformer.NewFactoryImpl(),
	)
}
1035482
func RegisterFitPredicate(name string, predicate predicates.FitPredicate) string {
	return RegisterFitPredicateFactory(name, func(PluginFactoryArgs) predicates.FitPredicate { return predicate })
}
428848
func NewPooledObjectFactory(
	create func(context.Context) (interface{}, error),
	destroy func(ctx context.Context, object *PooledObject) error,
	validate func(ctx context.Context, object *PooledObject) bool,
	activate func(ctx context.Context, object *PooledObject) error,
	passivate func(ctx context.Context, object *PooledObject) error) PooledObjectFactory {
	if create == nil {
		panic(errors.New("make function can not be nil"))
	}
	return &DefaultPooledObjectFactory{
		make: func(ctx context.Context) (*PooledObject, error) {
			o, err := create(ctx)
			if err != nil {
				return nil, err
			}
			return NewPooledObject(o), nil
		},
		destroy:   destroy,
		validate:  validate,
		activate:  activate,
		passivate: passivate}
}
1148654
func RegisterFitPredicateFactory(name string, predicateFactory FitPredicateFactory) string {
	schedulerFactoryMutex.Lock()
	defer schedulerFactoryMutex.Unlock()
	validateAlgorithmNameOrDie(name)
	fitPredicateMap[name] = predicateFactory
	return name
}
1117641
func NewFactory(generator Generator, store Store) *Factory {
	return &Factory{
		store:     store,
		generator: generator,
	}
}
279661
func newPredicateStringsWatcher(fn predicateFunc, values ...string) *PredicateStringsWatcher {
	return &PredicateStringsWatcher{
		stringsWatcherBase: newStringsWatcherBase(values...),
		fn:                 fn,
	}
}
912228
func NewPodAffinityPredicate(info NodeInfo, podLister algorithm.PodLister) FitPredicate {
	checker := &PodAffinityChecker{
		info:      info,
		podLister: podLister,
	}
	return checker.InterPodAffinityMatches
}
486472
func NewImmutable(id string) (*Predicate, error) {
	if id == "" {
		return nil, fmt.Errorf("predicate.NewImmutable(%q) cannot create a immutable predicate with empty ID", id)
	}
	return &Predicate{
		id: ID(id),
	}, nil
}
116812
func (q *QueryString) Predicate(name string) (p Predicate, err error) {
	defer func() {
		if rec := recover(); rec != nil {
			err = rec.(error)
		}
	}()

	raw, ok := q.fields[name]
	if !ok {
		return nil, fmt.Errorf("field not found: %q", name)
	}

	p, raw = parsePredicate(raw)
	if len(raw) != 0 {
		p = nil
		err = UnexpectedEndOfPredicate
	}

	return
}
172294
func newKeyspaceIDResolverFactory(ctx context.Context, ts *topo.Server, keyspace string, cell string) (keyspaceIDResolverFactory, error) {
	if *useV3ReshardingMode {
		return newKeyspaceIDResolverFactoryV3(ctx, ts, keyspace, cell)
	}

	return newKeyspaceIDResolverFactoryV2(ctx, ts, keyspace)
}