Skip to content

Commit

Permalink
Add DESC for INSERT and DELETE commands. This change also has minor c…
Browse files Browse the repository at this point in the history
…osmetic update to the CREATE and DROP plans
  • Loading branch information
xllora committed Jan 4, 2017
1 parent 5fbd6be commit 5251ce1
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions bql/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package planner

import (
"bytes"
"errors"
"fmt"
"reflect"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (p *createPlan) Execute(ctx context.Context) (*table.Table, error) {

// String returns a readable description of the execution plan.
func (p *createPlan) String() string {
return fmt.Sprintf("store(%q).NewGraph(_, %v)", p.store.Name(nil), p.stm.Graphs())
return fmt.Sprintf("CREATE plan:\n\nstore(%q).NewGraph(_, %v)", p.store.Name(nil), p.stm.Graphs())
}

// dropPlan encapsulates the sequence of instructions that need to be
Expand Down Expand Up @@ -99,7 +100,7 @@ func (p *dropPlan) Execute(ctx context.Context) (*table.Table, error) {

// String returns a readable description of the execution plan.
func (p *dropPlan) String() string {
return fmt.Sprintf("store(%q).DeleteGraph(_, %v)", p.store.Name(nil), p.stm.Graphs())
return fmt.Sprintf("DROP plan:\n\nstore(%q).DeleteGraph(_, %v)", p.store.Name(nil), p.stm.Graphs())
}

// insertPlan encapsulates the sequence of instructions that need to be
Expand Down Expand Up @@ -158,7 +159,17 @@ func (p *insertPlan) Execute(ctx context.Context) (*table.Table, error) {

// String returns a readable description of the execution plan.
func (p *insertPlan) String() string {
return "not implemented"
b := bytes.NewBufferString("INSERT plan:\n\n")
for _, g := range p.stm.Graphs() {
b.WriteString(fmt.Sprintf("store(%q).Graph(%q).AddTriples(_, data)\n", p.store.Name(nil), g))
}
b.WriteString("where data:\n")
for _, t := range p.stm.Data() {
b.WriteString("\t")
b.WriteString(t.String())
b.WriteString("\n")
}
return b.String()
}

// deletePlan encapsulates the sequence of instructions that need to be
Expand All @@ -181,7 +192,17 @@ func (p *deletePlan) Execute(ctx context.Context) (*table.Table, error) {

// String returns a readable description of the execution plan.
func (p *deletePlan) String() string {
return "not implemented"
b := bytes.NewBufferString("DELETE plan:\n\n")
for _, g := range p.stm.Graphs() {
b.WriteString(fmt.Sprintf("store(%q).Graph(%q).RemoveTriples(_, data)\n", p.store.Name(nil), g))
}
b.WriteString("where data:\n")
for _, t := range p.stm.Data() {
b.WriteString("\t")
b.WriteString(t.String())
b.WriteString("\n")
}
return b.String()
}

// queryPlan encapsulates the sequence of instructions that need to be
Expand Down

0 comments on commit 5251ce1

Please sign in to comment.