// New create a new executable plan given a semantic BQL statement.
183414
func New(ctx context.Context, store storage.Store, stm *semantic.Statement, chanSize, bulkSize int, w io.Writer) (Executor, error) {
	switch stm.Type() {
	case semantic.Query:
		return newQueryPlan(ctx, store, stm, chanSize, w)
	case semantic.Insert:
		return &insertPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Delete:
		return &deletePlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Create:
		return &createPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Drop:
		return &dropPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	case semantic.Construct:
		qp, _ := newQueryPlan(ctx, store, stm, chanSize, w)
		return &constructPlan{
			stm:       stm,
			store:     store,
			tracer:    w,
			bulkSize:  bulkSize,
			queryPlan: qp,
			construct: true,
		}, nil
	case semantic.Deconstruct:
		qp, _ := newQueryPlan(ctx, store, stm, chanSize, w)
		return &constructPlan{
			stm:       stm,
			store:     store,
			tracer:    w,
			bulkSize:  bulkSize,
			queryPlan: qp,
			construct: false,
		}, nil
	case semantic.Show:
		return &showPlan{
			stm:    stm,
			store:  store,
			tracer: w,
		}, nil
	default:
		return nil, fmt.Errorf("planner.New: unknown statement type in statement %v", stm)
	}
}
712575
func New(c *Configuration) (b *Bundler, err error) {
	// Init
	b = &Bundler{
		appName:           c.AppName,
		bindPackage:       c.Bind.Package,
		Client:            &http.Client{},
		environments:      c.Environments,
		darwinAgentApp:    c.DarwinAgentApp,
		resourcesAdapters: c.ResourcesAdapters,
		ldflags:           c.LDFlags,
		infoPlist:         c.InfoPlist,
	}

	// Ldflags
	if b.ldflags == nil {
		b.ldflags = make(LDFlags)
	}

	// Add context
	b.ctx, b.cancel = context.WithCancel(context.Background())

	// Loop through environments
	for _, env := range b.environments {
		// Validate OS
		if !astilectron.IsValidOS(env.OS) {
			err = fmt.Errorf("OS %s is invalid", env.OS)
			return
		}
	}

	// Astilectron path
	if b.pathAstilectron, err = absPath(c.AstilectronPath, nil); err != nil {
		return
	}

	// Working directory path
	if b.pathWorkingDirectory, err = absPath(c.WorkingDirectoryPath, func() (string, error) { return filepath.Join(os.TempDir(), "astibundler"), nil }); err != nil {
		return
	}

	// Paths that depend on the working directory path
	b.pathBindInput = filepath.Join(b.pathWorkingDirectory, "bind")
	b.pathCache = filepath.Join(b.pathWorkingDirectory, "cache")

	// Darwin icon path
	if b.pathIconDarwin, err = absPath(c.IconPathDarwin, nil); err != nil {
		return
	}

	// Linux icon path
	if b.pathIconLinux, err = absPath(c.IconPathLinux, nil); err != nil {
		return
	}

	// Windows icon path
	if b.pathIconWindows, err = absPath(c.IconPathWindows, nil); err != nil {
		return
	}

	// Windows application manifest path
	if b.pathManifest, err = absPath(c.ManifestPath, nil); err != nil {
		return
	}

	// Input path
	if b.pathInput, err = absPath(c.InputPath, os.Getwd); err != nil {
		return
	}

	// Paths that depends on the input path
	for _, i := range filepath.SplitList(os.Getenv("GOPATH")) {
		var p = filepath.Join(i, "src")
		if strings.HasPrefix(b.pathInput, p) {
			b.pathBuild = strings.TrimPrefix(strings.TrimPrefix(b.pathInput, p), string(os.PathSeparator))
			break
		}
	}

	// Bind output path
	if b.pathBindOutput, err = absPath(c.Bind.OutputPath, func() (string, error) { return b.pathInput, nil }); err != nil {
		return
	}

	// If build path is empty, ldflags are not set properly
	if len(b.pathBuild) == 0 {
		b.pathBuild = "."
	}

	// Resources path
	if b.pathResources = c.ResourcesPath; len(b.pathResources) == 0 {
		b.pathResources = "resources"
	}

	// Vendor path
	if b.pathVendor = c.VendorDirPath; len(b.pathVendor) == 0 {
		b.pathVendor = vendorDirectoryName
	}
	b.pathVendor = filepath.Join(b.pathBindInput, b.pathVendor)

	// Go binary path
	b.pathGoBinary = "go"
	if len(c.GoBinaryPath) > 0 {
		b.pathGoBinary = c.GoBinaryPath
	}

	// Output path
	if b.pathOutput, err = absPath(c.OutputPath, func() (string, error) {
		p, err := os.Getwd()
		if err != nil {
			return "", err
		}
		p = filepath.Join(p, "output")
		return p, err
	}); err != nil {
		return
	}

	// Bind package
	if len(b.bindPackage) == 0 {
		b.bindPackage = "main"
	}
	return
}
40461
func New(exec utilexec.Interface, dbus utildbus.Interface, protocol Protocol) Interface {
	vstring, err := getIptablesVersionString(exec)
	if err != nil {
		glog.Warningf("Error checking iptables version, assuming version at least %s: %v", MinCheckVersion, err)
		vstring = MinCheckVersion
	}
	runner := &runner{
		exec:     exec,
		dbus:     dbus,
		protocol: protocol,
		hasCheck: getIptablesHasCheckCommand(vstring),
		waitFlag: getIptablesWaitFlag(vstring),
	}
	runner.connectToFirewallD()
	return runner
}
502085
func New(caller base.APICaller) API {
	fc := base.NewFacadeCaller(caller, uaFacade)
	return API{facade: fc}
}
223485
func New(ctx context.Context, params backend.Params) (*LiteBackend, error) {
	var cfg *Config
	err := utils.ObjectToStruct(params, &cfg)
	if err != nil {
		return nil, trace.BadParameter("SQLite configuration is invalid: %v", err)
	}
	return NewWithConfig(ctx, *cfg)
}
8945
func New(source ConfigSource, initial auditlog.Config, logFactory AuditLogFactory) (worker.Worker, error) {
	u := &updater{
		source:     source,
		current:    initial,
		logFactory: logFactory,
	}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &u.catacomb,
		Work: u.loop,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return u, nil
}
1201032
func New(dbName string, idAlloc autoid.Allocator) (KvEncoder, error) {
	kvEnc := &kvEncoder{}
	mu.Lock()
	defer mu.Unlock()
	if refCount == 0 {
		if err := initGlobal(); err != nil {
			return nil, err
		}
	}
	err := kvEnc.initial(dbName, idAlloc)
	if err != nil {
		return nil, err
	}
	refCount++
	return kvEnc, nil
}
945535
func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error) {
	obj, err := s.raw.NewObject(kind)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}
553718
func New(org, project string, envs, services, identities, instances []string) (*PathExp, error) {
	return newPathexp(org, project, envs, services, identities, instances, true)
}
273571
func (factory *DevrantBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := DevrantBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
94592
func (a Algorithm) New() Digester {
	return &digester{
		alg:  a,
		hash: a.Hash(),
	}
}
1230143
func New(code int32, message string, args ...interface{}) Error {
	if len(args) > 0 {
		return &apiError{code, fmt.Sprintf(message, args...)}
	}
	return &apiError{code, message}
}
903141
func (factory *JabberBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := JabberBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
887541
func (factory *CronBeeFactory) New(name, description string, options bees.BeeOptions) bees.BeeInterface {
	bee := CronBee{
		Bee: bees.NewBee(name, factory.ID(), description, options),
	}
	bee.ReloadOptions(options)

	return &bee
}
263850
func New(txn *lmdb.Txn, dbi lmdb.DBI) *Scanner {
	s := &Scanner{
		dbi: dbi,
		op:  lmdb.Next,
	}

	s.cur, s.err = txn.OpenCursor(dbi)
	return s
}
24518
func new(err error, skip int) *Error {
	return &Error{
		Err:        err,
		stackTrace: stacktrace(err, skip+1),
		info:       map[string]interface{}{},
	}
}
208687
func (s *Scheme) New(versionName, typeName string) (Object, error) {
	obj, err := s.raw.NewObject(versionName, typeName)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}