MCPcopy Create free account
hub / github.com/brimdata/super / Run

Method Run

cmd/super/root/command.go:66–115  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

64}
65
66func (c *Command) Run(args []string) error {
67 if c.canon && len(c.queryFlags.Query) == 0 {
68 return errors.New("query text must be specified (-c or -I) when using -C")
69 }
70 ctx, cleanup, err := c.Init(&c.inputFlags, &c.outputFlags, &c.runtimeFlags)
71 if err != nil {
72 return err
73 }
74 defer cleanup()
75 if len(args) == 0 && len(c.queryFlags.Query) == 0 {
76 return charm.NeedHelp
77 }
78 ast, err := parser.ParseFiles(c.queryFlags.Query)
79 if err != nil {
80 return err
81 }
82 if c.canon {
83 fmt.Println(sfmt.AST(ast.Parsed()))
84 return nil
85 }
86 if len(args) > 0 {
87 ast.PrependFileScan(args)
88 }
89 env := exec.NewEnvironment(storage.NewLocalEngine(), nil)
90 env.Dynamic = c.inputFlags.Dynamic
91 env.IgnoreOpenErrors = !c.stopErr
92 env.ReaderOpts = c.inputFlags.ReaderOpts
93 env.Runtime = c.runtimeFlags.Runtime
94 env.SampleSize = c.inputFlags.SampleSize
95 comp := compiler.NewCompilerWithEnv(env)
96 query, err := runtime.CompileQuery(ctx, super.NewContext(), comp, ast, nil)
97 if err != nil {
98 return err
99 }
100 defer query.Pull(true)
101 writer, err := c.outputFlags.Open(ctx, env.Engine())
102 if err != nil {
103 return err
104 }
105 out := map[string]vio.Pusher{
106 "main": writer,
107 "debug": supio.NewWriter(sio.NopCloser(os.Stderr), supio.WriterOpts{}),
108 }
109 err = vio.CopyMux(out, query)
110 if closeErr := writer.Close(); err == nil {
111 err = closeErr
112 }
113 c.queryFlags.PrintStats(query.Progress())
114 return err
115}

Callers

nothing calls this directly

Implementers 15

Displaypkg/display/display.go
Serverpkg/httpd/server.go
Commandcmd/gentoken/main.go
Commandcmd/super/dev/command.go
Commandcmd/super/dev/vector/command.go
Commandcmd/super/dev/vector/copy/command.go
Commandcmd/super/dev/vector/project/command.g
Commandcmd/super/dev/vector/search/command.go
Commandcmd/super/dev/dig/command.go
Commandcmd/super/dev/dig/frames/command.go
Commandcmd/super/dev/dig/slice/command.go
Commandcmd/super/dev/csup/command.go

Calls 15

EngineMethod · 0.95
ParseFilesFunction · 0.92
ASTFunction · 0.92
NewEnvironmentFunction · 0.92
NewLocalEngineFunction · 0.92
NewCompilerWithEnvFunction · 0.92
CompileQueryFunction · 0.92
NewContextFunction · 0.92
NewWriterFunction · 0.92
NopCloserFunction · 0.92
CopyMuxFunction · 0.92
NewMethod · 0.80

Tested by

no test coverage detected