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

add support for older vtgate query plans #448

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion go/tools/macrobench/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func getVTGateQueryPlans(port string) (VTGateQueryPlanMap, error) {
var response map[string]VTGateQueryPlanValue
err = json.NewDecoder(resp.Body).Decode(&response)
if err != nil {
return nil, err
return getOldVTGateQueryPlans(resp)
}
for key, plan := range response {
// keeping only select statements
Expand All @@ -178,6 +178,27 @@ func getVTGateQueryPlans(port string) (VTGateQueryPlanMap, error) {
return response, nil
}

func getOldVTGateQueryPlans(resp *http.Response) (VTGateQueryPlanMap, error) {
var response []VTGateQueryPlan
err := json.NewDecoder(resp.Body).Decode(&response)
if err != nil {
return nil, err
}
planMap := VTGateQueryPlanMap{}
for _, plan := range response {
// keeping only select statements
if strings.HasPrefix(plan.Key, "select") {
jsonPlan, err := json.MarshalIndent(plan.Value.Instructions, "", "\t")
if err != nil {
return nil, err
}
plan.Value.Instructions = string(jsonPlan)
planMap[plan.Key] = plan.Value
}
}
return planMap, nil
}

func getVTGatesQueryPlans(ports []string) (VTGateQueryPlanMap, error) {
res := VTGateQueryPlanMap{}

Expand Down
Loading