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

Method Run

cmd/super/compile/shared.go:55–127  ·  view source on GitHub ↗
(ctx context.Context, args []string, dbFlags *dbflags.Flags, desc bool)

Source from the content-addressed store, hash-verified

53}
54
55func (s *Shared) Run(ctx context.Context, args []string, dbFlags *dbflags.Flags, desc bool) error {
56 if err := s.runtimeFlags.Init(); err != nil {
57 return err
58 }
59 if len(s.queryFlags.Query) == 0 && len(args) == 0 {
60 return errors.New("no query specified")
61 }
62 var inputs []string
63 if len(args) > 0 {
64 s.queryFlags.Query = append(s.queryFlags.Query, &srcfiles.PlainInput{Text: args[0]})
65 inputs = args[1:]
66 }
67 var root *db.Root
68 if dbFlags != nil {
69 dbAPI, err := dbFlags.Open(ctx)
70 if err != nil {
71 return err
72 }
73 root = dbAPI.Root()
74 }
75 ast, err := parser.ParseFiles(s.queryFlags.Query)
76 if err != nil {
77 return err
78 }
79 if s.parallel > 0 {
80 s.optimize = true
81 }
82 if s.optimize || desc {
83 s.dag = true
84 }
85 if !s.dag {
86 if s.runtime {
87 defer printRuntime(s.runtimeFlags.Runtime)
88 }
89 if s.query {
90 fmt.Println(sfmt.AST(ast.Parsed()))
91 return nil
92 }
93 return s.writeValue(ctx, ast.Parsed())
94 }
95 if len(inputs) > 0 {
96 ast.PrependFileScan(inputs)
97 }
98 rctx := runtime.DefaultContext()
99 env := exec.NewEnvironment(storage.NewLocalEngine(), root)
100 env.Dynamic = s.dynamic
101 env.Runtime = s.runtimeFlags.Runtime
102 env.SampleSize = s.sampleSize
103 dag, err := compiler.Analyze(rctx, ast, env, false)
104 if err != nil {
105 return err
106 }
107 if s.runtime {
108 defer printRuntime(env.Runtime)
109 }
110 if desc {
111 description, err := describe.AnalyzeDAG(ctx, dag, env)
112 if err != nil {

Callers

nothing calls this directly

Calls 15

writeValueMethod · 0.95
ParseFilesFunction · 0.92
ASTFunction · 0.92
DefaultContextFunction · 0.92
NewEnvironmentFunction · 0.92
NewLocalEngineFunction · 0.92
AnalyzeFunction · 0.92
AnalyzeDAGFunction · 0.92
OptimizeFunction · 0.92
DAGFunction · 0.92
printRuntimeFunction · 0.85
NewMethod · 0.80

Tested by

no test coverage detected