// NewIndexOption returns an option that can be used to choose a story by its index.
483868
func NewIndexOption() *DialogOption {
	return &DialogOption{
		Description: []string{
			"Choose a story by inserting the associated index.",
		},
		IsActive: func(stories []common.Story, depth int) bool {
			return len(stories) != 0
		},
		MatchesInput: func(input string, stories []common.Story) bool {
			index, err := strconv.Atoi(input)
			if err != nil {
				return false
			}
			return 1 <= index && index <= len(stories)
		},
		SelectStory: func(
			input string,
			stories []common.Story,
			currentDialog *Dialog,
		) (common.Story, error) {

			index, _ := strconv.Atoi(input)
			return stories[index-1], nil
		},
	}
}
39778
func NewIndex() *Index {
	return &Index{lines: map[string]string{}, charts: map[string]*repo.ChartVersion{}}
}
387543
func NewIndex() (*Index, error) {
	var ptr *C.git_index

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	if err := C.git_index_new(&ptr); err < 0 {
		return nil, MakeGitError(err)
	}

	return newIndexFromC(ptr, nil), nil
}
1128691
func (h *Holder) CreateIndexIfNotExists(name string, opt IndexOptions) (*Index, error) {
	h.mu.Lock()
	defer h.mu.Unlock()

	// Find index in cache first.
	if index := h.indexes[name]; index != nil {
		return index, nil
	}

	return h.createIndex(name, opt)
}
1039724
func NewIndex(path, name string) (*Index, error) {
	err := validateName(name)
	if err != nil {
		return nil, errors.Wrap(err, "validating name")
	}

	return &Index{
		path:   path,
		name:   name,
		fields: make(map[string]*Field),

		newAttrStore: newNopAttrStore,
		columnAttrs:  nopStore,

		broadcaster:    NopBroadcaster,
		Stats:          stats.NopStatsClient,
		logger:         logger.NopLogger,
		trackExistence: true,
	}, nil
}
1349496
func (s *DB) AddIndex(indexName string, columns ...string) *DB {
	scope := s.Unscoped().NewScope(s.Value)
	scope.addIndex(false, indexName, columns...)
	return scope.db
}
683423
func (c Configuration) NewOptions(scope tally.Scope) Options {
	opts := NewOptions().SetMetricsScope(scope)
	if c.InitialBackoff != 0 {
		opts = opts.SetInitialBackoff(c.InitialBackoff)
	}
	if c.BackoffFactor != 0.0 {
		opts = opts.SetBackoffFactor(c.BackoffFactor)
	}
	if c.MaxBackoff != 0 {
		opts = opts.SetMaxBackoff(c.MaxBackoff)
	}
	if c.MaxRetries != 0 {
		opts = opts.SetMaxRetries(c.MaxRetries)
	}
	if c.Forever != nil {
		opts = opts.SetForever(*c.Forever)
	}
	if c.Jitter != nil {
		opts = opts.SetJitter(*c.Jitter)
	}

	return opts
}
1120880
func (c *Client) OpenIndex(name string) *OpenIndexService {
	builder := NewOpenIndexService(c)
	builder.Index(name)
	return builder
}
1307398
func (ts *TableSpec) AddIndex(id *IndexDefinition) {
	ts.Indexes = append(ts.Indexes, id)
}
94009
func NewIndicesAnalyzeService(client *Client) *IndicesAnalyzeService {
	return &IndicesAnalyzeService{
		client:  client,
		request: new(IndicesAnalyzeRequest),
	}
}
1130635
func NewIndicesExistsTypeService(client *Client) *IndicesExistsTypeService {
	return &IndicesExistsTypeService{
		client: client,
		index:  make([]string, 0),
		typ:    make([]string, 0),
	}
}
478211
func NewIndex(kind IndexKind, table string) Index {
	return &index{
		kind:  kind,
		table: table,
	}
}
786092
func NewOptions(ext Extender) *Options {
	// Use defaults except for Extender
	return &Options{
		DefaultUserAgent,
		DefaultRobotUserAgent,
		0,
		DefaultEnqueueChanBuffer,
		DefaultHostBufferFactor,
		DefaultCrawlDelay,
		DefaultIdleTTL,
		true,
		false,
		DefaultNormalizationFlags,
		LogError,
		ext,
	}
}
1183527
func (s *DB) AddUniqueIndex(indexName string, columns ...string) *DB {
	scope := s.Unscoped().NewScope(s.Value)
	scope.addIndex(true, indexName, columns...)
	return scope.db
}
153381
func NewOptions(e *xorm.Engine, opts Options, keyPairs ...[]byte) (*Store, error) {
	st := &Store{
		e:      e,
		opts:   opts,
		Codecs: securecookie.CodecsFromPairs(keyPairs...),
		SessionOpts: &sessions.Options{
			Path:   defaultPath,
			MaxAge: defaultMaxAge,
		},
	}
	if st.opts.TableName == "" {
		st.opts.TableName = defaultTableName
	}

	if !st.opts.SkipCreateTable {
		if err := st.e.Sync2(&xormSession{tableName: st.opts.TableName}); err != nil {
			return nil, err
		}
	}

	return st, nil
}
457331
func NewIndex(sfile *tsdb.SeriesFile, c Config, options ...IndexOption) *Index {
	idx := &Index{
		tagValueCache:    NewTagValueSeriesIDCache(c.SeriesIDSetCacheSize),
		partitionMetrics: newPartitionMetrics(nil),
		metricsEnabled:   true,
		maxLogFileSize:   int64(c.MaxIndexLogFileSize),
		logger:           zap.NewNop(),
		version:          Version,
		config:           c,
		sfile:            sfile,
		PartitionN:       DefaultPartitionN,
	}

	for _, option := range options {
		option(idx)
	}

	return idx
}
73709
func (s *IndicesRolloverService) NewIndex(newIndex string) *IndicesRolloverService {
	s.newIndex = newIndex
	return s
}