// Execute writes the code for the context types to the writer.
774861
func (w *ContextsWriter) Execute(data *ContextTemplateData) error {
	if err := w.ExecuteTemplate("context", ctxT, nil, data); err != nil {
		return err
	}
	fn := template.FuncMap{
		"newCoerceData":      newCoerceData,
		"arrayAttribute":     arrayAttribute,
		"printVal":           codegen.PrintVal,
		"canonicalHeaderKey": http.CanonicalHeaderKey,
		"isPathParam":        data.IsPathParam,
		"valueTypeOf":        valueTypeOf,
		"fromString":         fromString,
	}
	if err := w.ExecuteTemplate("new", ctxNewT, fn, data); err != nil {
		return err
	}
	if data.Payload != nil {
		found := false
		for _, t := range design.Design.Types {
			if t.TypeName == data.Payload.TypeName {
				found = true
				break
			}
		}
		if !found {
			fn := template.FuncMap{
				"finalizeCode":   w.Finalizer.Code,
				"validationCode": w.Validator.Code,
			}
			if err := w.ExecuteTemplate("payload", payloadT, fn, data); err != nil {
				return err
			}
		}
	}
	return data.IterateResponses(func(resp *design.ResponseDefinition) error {
		respData := map[string]interface{}{
			"Context":  data,
			"Response": resp,
		}
		var mt *design.MediaTypeDefinition
		if resp.Type != nil {
			var ok bool
			if mt, ok = resp.Type.(*design.MediaTypeDefinition); !ok {
				respData["Type"] = resp.Type
				respData["ContentType"] = resp.MediaType
				return w.ExecuteTemplate("response", ctxTRespT, nil, respData)
			}
		} else {
			mt = design.Design.MediaTypeWithIdentifier(resp.MediaType)
		}
		if mt != nil {
			var views []string
			if resp.ViewName != "" {
				views = []string{resp.ViewName}
			} else {
				views = make([]string, len(mt.Views))
				i := 0
				for name := range mt.Views {
					views[i] = name
					i++
				}
				sort.Strings(views)
			}
			for _, view := range views {
				projected, _, err := mt.Project(view)
				if err != nil {
					return err
				}
				respData["Projected"] = projected
				respData["ViewName"] = view
				respData["MediaType"] = mt
				respData["ContentType"] = mt.ContentType
				if view == "default" {
					respData["RespName"] = codegen.Goify(resp.Name, true)
				} else {
					base := fmt.Sprintf("%s%s", resp.Name, strings.Title(view))
					respData["RespName"] = codegen.Goify(base, true)
				}
				if err := w.ExecuteTemplate("response", ctxMTRespT, fn, respData); err != nil {
					return err
				}
			}
			return nil
		}
		return w.ExecuteTemplate("response", ctxNoMTRespT, nil, respData)
	})
}
988560
func (e *HashAggExec) execute(ctx context.Context) (err error) {
	inputIter := chunk.NewIterator4Chunk(e.childResult)
	for {
		err := e.children[0].Next(ctx, chunk.NewRecordBatch(e.childResult))
		if err != nil {
			return err
		}

		failpoint.Inject("unparallelHashAggError", func(val failpoint.Value) {
			if val.(bool) {
				failpoint.Return(errors.New("HashAggExec.unparallelExec error"))
			}
		})

		// no more data.
		if e.childResult.NumRows() == 0 {
			return nil
		}
		for row := inputIter.Begin(); row != inputIter.End(); row = inputIter.Next() {
			groupKey, err := e.getGroupKey(row)
			if err != nil {
				return err
			}
			if !e.groupSet.Exist(groupKey) {
				e.groupSet.Insert(groupKey)
				e.groupKeys = append(e.groupKeys, groupKey)
			}
			partialResults := e.getPartialResults(groupKey)
			for i, af := range e.PartialAggFuncs {
				err = af.UpdatePartialResult(e.ctx, []chunk.Row{row}, partialResults[i])
				if err != nil {
					return err
				}
			}
		}
	}
}
602136
func (c *SchemaStatus) Execute(args []string) error {
	if c.Verbose {
		fmt.Printf("executing schema status with %v\n", args)
		fmt.Printf("options are %+v\n", *c)
		fmt.Printf("global options are %+v\n", options)
	}

	// TODO(eculver): use options/configurator pattern to apply defaults
	if options.ServiceName == "" {
		options.ServiceName = _defServiceName
	}

	client, err := c.provideClient(options)
	if err != nil {
		return err
	}
	defer shutdownAdminClient(client)

	if c.Scope.String() != "" {
		client.Scope(c.Scope.String())
	}

	ctx, cancel := context.WithTimeout(context.Background(), options.Timeout.Duration())
	defer cancel()

	var prefix string
	if prefix, err = getNamePrefix(c.NamePrefix, c.Prefix); err != nil {
		return err
	}
	status, err := client.CheckSchemaStatus(ctx, prefix, c.Version)
	if err != nil {
		if c.Verbose {
			fmt.Printf("detail:%+v\n", err)
		}
		fmt.Println("Status: NOT OK")
		return err
	}
	fmt.Printf("Version: %d\n", status.Version)
	fmt.Printf("Status: %s\n", status.Status)
	return nil
}
70669
func (w *ResourcesWriter) Execute(data *ResourceData) error {
	return w.ExecuteTemplate("resource", resourceT, nil, data)
}
76095
func (t *Template) Execute(mapping func(string) string) (str string, err error) {
	b := new(bytes.Buffer)
	s := new(state)
	s.node = t.tree.Root
	s.mapper = mapping
	s.writer = b
	err = t.eval(s)
	if err != nil {
		return
	}
	return b.String(), nil
}
225113
func (tc *TiDBContext) Execute(ctx context.Context, sql string) (rs []ResultSet, err error) {
	rsList, err := tc.session.Execute(ctx, sql)
	if err != nil {
		return
	}
	if len(rsList) == 0 { // result ok
		return
	}
	rs = make([]ResultSet, len(rsList))
	for i := 0; i < len(rsList); i++ {
		rs[i] = &tidbResultSet{
			recordSet: rsList[i],
		}
	}
	return
}
1198353
func (c *SchemaUpsert) Execute(args []string) error {
	return c.doSchemaOp(schemaUpsert, dosa.AdminClient.UpsertSchema, c.Args.Paths)
}
996613
func (t *Template) Execute(w io.Writer, data interface{}) error {
	return t.tmpl.Execute(w, data)
}
371015
func (c *ServicedStorageVersion) Execute(args []string) error {
	fmt.Println(App.version)
	return nil
}
501726
func (c *SchemaCheck) Execute(args []string) error {
	return c.doSchemaOp(schemaCheck, dosa.AdminClient.CanUpsertSchema, c.Args.Paths)
}
265795
func (p *ListCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
	c.Conf.Debug = p.debug
	c.Conf.DebugSQL = p.debugSQL
	c.Conf.DBPath = p.dbpath
	c.Conf.DBType = p.dbtype
	c.Conf.HTTPProxy = p.httpProxy
	log.SetLogger(p.logDir, c.Conf.Quiet, c.Conf.Debug, p.logJSON)
	if !c.Conf.Validate() {
		return subcommands.ExitUsageError
	}

	driver, locked, err := db.NewDB(c.Conf.DBType, c.Conf.DBPath, c.Conf.DebugSQL)
	if err != nil {
		if locked {
			log.Errorf("Failed to Open DB. Close DB connection: %s", err)
			return subcommands.ExitFailure
		}
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	defer driver.CloseDB()

	jsonMetas, xmlMetas, err := nvd.ListFetchedFeeds(driver)
	if err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	sort.Slice(jsonMetas, func(i, j int) bool {
		return jsonMetas[i].URL < jsonMetas[j].URL
	})
	sort.Slice(xmlMetas, func(i, j int) bool {
		return xmlMetas[i].URL < xmlMetas[j].URL
	})

	jvnMetas, err := jvn.ListFetchedFeeds(driver)
	if err != nil {
		log.Errorf("%s", err)
		return subcommands.ExitFailure
	}
	sort.Slice(jvnMetas, func(i, j int) bool {
		return jvnMetas[i].URL < jvnMetas[j].URL
	})

	metas := []models.FeedMeta{}
	for _, mm := range [][]models.FeedMeta{jsonMetas, xmlMetas, jvnMetas} {
		metas = append(metas, mm...)
	}
	data := [][]string{}
	for _, meta := range metas {
		data = append(data, meta.ToTableWriterRow())
	}
	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Source", "Year", "Status", "Fetched", "Latest"})
	table.SetBorder(true)
	table.SetHeaderColor(
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold},
		tablewriter.Colors{tablewriter.Bold})
	table.AppendBulk(data)
	table.Render()

	cmds := []string{}
	for _, mm := range [][]models.FeedMeta{jsonMetas, xmlMetas, jvnMetas} {
		cmd := getUpdateCommand(mm)
		if cmd != "" {
			cmds = append(cmds, cmd)
		}
	}

	if 0 < len(cmds) {
		fmt.Printf("\nTo update feeds, execute the following commands.\n")
		for _, cmd := range cmds {
			fmt.Println(cmd)
		}
	}

	return subcommands.ExitSuccess
}
271666
func (t *explainTablet) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]*querypb.BindVariable, transactionID int64, options *querypb.ExecuteOptions) (*sqltypes.Result, error) {
	t.mu.Lock()
	t.currentTime = batchTime.Wait()

	// Since the query is simulated being "sent" over the wire we need to
	// copy the bindVars into the executor to avoid a data race.
	bindVariables = sqltypes.CopyBindVariables(bindVariables)
	t.tabletQueries = append(t.tabletQueries, &TabletQuery{
		Time:     t.currentTime,
		SQL:      sql,
		BindVars: bindVariables,
	})
	t.mu.Unlock()

	return t.tsv.Execute(ctx, target, sql, bindVariables, transactionID, options)
}
680732
func (p *showPlan) Execute(ctx context.Context) (*table.Table, error) {
	t, err := table.New([]string{"?graph_id"})
	if err != nil {
		return nil, err
	}
	errs := make(chan error)
	names := make(chan string)
	go func() {
		errs <- p.store.GraphNames(ctx, names)
		close(errs)
	}()

	for name := range names {
		id := name
		t.AddRow(table.Row{
			"?graph_id": &table.Cell{
				S: &id,
			},
		})
	}
	if <-errs != nil {
		return nil, err
	}
	return t, nil
}
457021
func (c *DriverList) Execute(args []string) error {
	App.initializeLogging()
	directory := GetDefaultDriver(string(c.Args.Path))
	logger := log.WithFields(log.Fields{
		"directory": directory,
	})
	driver, err := InitDriverIfExists(directory)
	if err != nil {
		logger.Fatal(err)
	}
	for _, volname := range driver.List() {
		fmt.Println(volname)
	}
	return nil
}
686280
func (c *Connection) Execute(ex *ExecuteRequest) (*ExecuteResponse, error) {
	c.dbMu.RLock()
	defer c.dbMu.RUnlock()
	if c.db == nil {
		return nil, ErrConnectionDoesNotExist
	}
	return c.store.execute(c, ex)
}
129540
func (c *Client) Execute(command string) (response *Packet, err error) {
	return c.Send(Exec, command)
}
518332
func (entityApi *EntityApi) Execute(id string, operation string, body []byte, options map[string]string) ([]byte, error) {
	optionsCopy := map[string]string{}
	for k, v := range options {
		optionsCopy[k] = v
	}
	optionsCopy["operation"] = operation
	endpoint := entityApi.buildEndpoint()
	if id != "" {
		endpoint = endpoint + "/" + id
	}
	request := api.CcaRequest{
		Method:   api.POST,
		Body:     body,
		Endpoint: endpoint,
		Options:  optionsCopy,
	}
	response, err := entityApi.apiClient.Do(request)
	if err != nil {
		return nil, err
	} else if response.IsError() {
		return nil, api.CcaErrorResponse(*response)
	}

	return entityApi.taskService.PollResponse(response, DEFAULT_POLLING_INTERVAL)
}