Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Remove an unnecessary AST-to-JSON conversion for the eval input. #6665

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func (s *Server) instrumentHandler(handler func(http.ResponseWriter, *http.Reque
return httpHandler
}

func (s *Server) execQuery(ctx context.Context, br bundleRevisions, txn storage.Transaction, parsedQuery ast.Body, input ast.Value, m metrics.Metrics, explainMode types.ExplainModeV1, includeMetrics, includeInstrumentation, pretty bool) (*types.QueryResponseV1, error) {
func (s *Server) execQuery(ctx context.Context, br bundleRevisions, txn storage.Transaction, parsedQuery ast.Body, input ast.Value, rawInput *interface{}, m metrics.Metrics, explainMode types.ExplainModeV1, includeMetrics, includeInstrumentation, pretty bool) (*types.QueryResponseV1, error) {
results := types.QueryResponseV1{}
logger := s.getDecisionLogger(br)

Expand All @@ -893,15 +893,6 @@ func (s *Server) execQuery(ctx context.Context, br bundleRevisions, txn storage.
buf = topdown.NewBufferTracer()
}

var rawInput *interface{}
if input != nil {
x, err := ast.JSON(input)
if err != nil {
return nil, err
}
rawInput = &x
}

var ndbCache builtins.NDBCache
if s.ndbCacheEnabled {
ndbCache = builtins.NDBCache{}
Expand Down Expand Up @@ -2277,7 +2268,7 @@ func (s *Server) v1QueryGet(w http.ResponseWriter, r *http.Request) {
return
}
pretty := pretty(r)
results, err := s.execQuery(ctx, br, txn, parsedQuery, nil, m, explainMode, includeMetrics(r), includeInstrumentation, pretty)
results, err := s.execQuery(ctx, br, txn, parsedQuery, nil, nil, m, explainMode, includeMetrics(r), includeInstrumentation, pretty)
if err != nil {
switch err := err.(type) {
case ast.Errors:
Expand Down Expand Up @@ -2347,7 +2338,7 @@ func (s *Server) v1QueryPost(w http.ResponseWriter, r *http.Request) {
return
}

results, err := s.execQuery(ctx, br, txn, parsedQuery, input, m, explainMode, includeMetrics, includeInstrumentation, pretty)
results, err := s.execQuery(ctx, br, txn, parsedQuery, input, request.Input, m, explainMode, includeMetrics, includeInstrumentation, pretty)
if err != nil {
switch err := err.(type) {
case ast.Errors:
Expand Down