// NewSourceScanner A scanner to read from sub-query data source (join, sub-query, static)
330032
func NewSourceScanner(ctx *plan.Context, p *plan.Source, scanner schema.ConnScanner) *Source {
	s := &Source{
		TaskBase: NewTaskBase(ctx),
		Scanner:  scanner,
		p:        p,
	}
	return s
}
277687
func (call *GetGroupMemberIDsCall) NewScanner() *IDsScanner {
	var ctx context.Context
	if call.ctx != nil {
		ctx = call.ctx
	} else {
		ctx = context.Background()
	}

	c2 := &GetGroupMemberIDsCall{}
	*c2 = *call
	c2.ctx = ctx

	return &IDsScanner{
		caller: c2,
		ctx:    ctx,
	}
}
457183
func (s *SearchService) SearchSource(searchSource *SearchSource) *SearchService {
	s.searchSource = searchSource
	if s.searchSource == nil {
		s.searchSource = NewSearchSource()
	}
	return s
}
1191215
func NewSourceFromDB(DBConfigFile string) (Source, error) {
	// Load DB from cofiguration file
	db, err := dbconf.DBFromConfig(DBConfigFile)

	if err != nil {
		return nil, err
	}
	// Create accesor
	accessor := sql.NewAccessor(db)
	src := NewDBSource(accessor)

	return src, nil
}
980559
func NewSearchService(client *Client) *SearchService {
	builder := &SearchService{
		client:       client,
		searchSource: NewSearchSource(),
	}
	return builder
}
504158
func NewSQLMapper(filename string, conn *sql.DB) (*SQLMapper, error) {
	conf, confErr := GetSQLConfFromFile(filename)
	if confErr != nil {
		return nil, confErr
	}

	return &SQLMapper{conf: conf, sqlConn: conn}, nil
}
704000
func FromReader(reader io.Reader) Source {
	m := make(map[string]string)

	s := bufio.NewScanner(bufio.NewReader(reader))
	for s.Scan() {
		l := s.Text()
		p := keyValueRE.FindStringSubmatch(l)
		if p == nil {
			continue
		}
		m[strings.ToLower(p[1])] = p[2]
	}
	if err := s.Err(); err != nil {
		return Err(err)
	}
	return FromMap(m)
}
1315312
func NewSource(opts ...source.Option) source.Source {
	options := source.NewOptions(opts...)

	// create the client
	client, _ := api.NewClient(api.DefaultConfig())

	// get and set options
	if address := getAddress(options); address != "" {
		_ = client.SetAddress(address)
	}

	if nameSpace := getNameSpace(options); nameSpace != "" {
		client.SetNamespace(nameSpace)
	}

	if token := getToken(options); token != "" {
		client.SetToken(token)
	}

	path := getResourcePath(options)
	name := getSecretName(options)
	if name == "" {
		name = path
	}

	return &vault{
		opts:       options,
		client:     client,
		secretPath: path,
		secretName: name,
	}
}
1264569
func (s *Service) NewSourceUser(w http.ResponseWriter, r *http.Request) {
	var req sourceUserRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		invalidJSON(w, s.Logger)
		return
	}

	if err := req.ValidCreate(); err != nil {
		invalidData(w, err, s.Logger)
		return
	}

	ctx := r.Context()
	srcID, ts, err := s.sourcesSeries(ctx, w, r)
	if err != nil {
		return
	}

	store := ts.Users(ctx)
	user := &chronograf.User{
		Name:        req.Username,
		Passwd:      req.Password,
		Permissions: req.Permissions,
		Roles:       req.Roles,
	}

	res, err := store.Add(ctx, user)
	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	if err != nil {
		Error(w, http.StatusBadRequest, err.Error(), s.Logger)
		return
	}

	su := newSourceUserResponse(srcID, res.Name).WithPermissions(res.Permissions)
	if _, hasRoles := s.hasRoles(ctx, ts); hasRoles {
		su.WithRoles(srcID, res.Roles)
	}
	location(w, su.Links.Self)
	encodeJSON(w, http.StatusCreated, su, s.Logger)
}
812137
func NewScanner(name string, d EncodingHint) (UTFScanCloser, error) {
	f, err := OpenFile(name, d)
	if err != nil {
		return nil, err
	}

	return scanCloser{
		scanner: bufio.NewScanner(f),
		file:    f,
	}, nil
}
757016
func NewSource(r io.Reader) *Source {
	return &Source{
		dec: json.NewDecoder(r),
	}
}
432669
func NewScanner(reader io.Reader) *Scanner {
	scanner := &Scanner{
		reader:  bufio.NewReader(reader),
		curLine: 0,
		curCol:  0,
		newline: false,
	}
	scanner.readRune()
	return scanner
}
1368391
func NewScanner(r io.Reader, path string) *Scanner {
	return &Scanner{
		r: r,
		pos: Pos{
			Path:   path,
			LineNo: 1,
		},
	}
}
1082285
func NewSearchSource() *SearchSource {
	return &SearchSource{
		from:         -1,
		size:         -1,
		aggregations: make(map[string]Aggregation),
		indexBoosts:  make(map[string]float64),
		innerHits:    make(map[string]*InnerHit),
	}
}
309609
func NewSubscriptionManager(ntfnSource NotificationSource) *SubscriptionManager {
	return &SubscriptionManager{
		subscribers:         make(map[uint64]*newSubscription),
		newSubscriptions:    make(chan *newSubscription),
		cancelSubscriptions: make(chan *cancelSubscription),
		ntfnSource:          ntfnSource,
		quit:                make(chan struct{}),
	}
}
312821
func NewSelectQuery(builder Builder, db *DB) *SelectQuery {
	return &SelectQuery{
		builder:     builder,
		selects:     []string{},
		from:        []string{},
		join:        []JoinInfo{},
		orderBy:     []string{},
		groupBy:     []string{},
		union:       []UnionInfo{},
		limit:       -1,
		params:      Params{},
		FieldMapper: db.FieldMapper,
	}
}
907459
func NewSource(name string, in io.Reader, idgen line.IDGenerator, capacity int, enableSep bool) *Source {
	s := &Source{
		name:       name,
		in:         in, // Note that this may be closed, so do not rely on it
		capacity:   capacity,
		enableSep:  enableSep,
		idgen:      idgen,
		ready:      make(chan struct{}),
		setupDone:  make(chan struct{}),
		ChanOutput: pipeline.ChanOutput(make(chan interface{})),
	}
	s.Reset()
	return s
}