Skip to content

Commit

Permalink
Simplifying select command and removing alternate use, which is bet…
Browse files Browse the repository at this point in the history
…ter handled by `render`
  • Loading branch information
kellrott committed Feb 7, 2024
1 parent 37b04e3 commit 0f69c26
Show file tree
Hide file tree
Showing 12 changed files with 813 additions and 1,168 deletions.
4 changes: 2 additions & 2 deletions conformance/tests/ot_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_mark_select_label_filter(man):
for row in G.query().V("Film:1").as_("a").\
both("films").\
as_("b").\
select(["a", "b"]):
render({"a" : "$a", "b" : "$b"}):
count += 1
if len(row) != 2:
errors.append("Incorrect number of marks returned")
Expand All @@ -32,7 +32,7 @@ def test_mark_select(man):

count = 0
for row in G.query().V("Character:1").as_("a").out().as_(
"b").out().as_("c").select(["a", "b", "c"]):
"b").out().as_("c").render({"a": "$a", "b": "$b", "c": "$c"}):
count += 1
if len(row) != 3:
errors.append("Incorrect number of marks returned")
Expand Down
12 changes: 2 additions & 10 deletions engine/core/statement_compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,8 @@ func (sc *DefaultStmtCompiler) Jump(stmt *gripql.GraphStatement_Jump, ps *gdbi.S
}

func (sc *DefaultStmtCompiler) Select(stmt *gripql.GraphStatement_Select, ps *gdbi.State) (gdbi.Processor, error) {
switch len(stmt.Select.Marks) {
case 0:
return nil, fmt.Errorf(`"select" statement has an empty list of mark names`)
case 1:
ps.LastType = ps.MarkTypes[stmt.Select.Marks[0]]
return &MarkSelect{stmt.Select.Marks[0]}, nil
default:
ps.LastType = gdbi.SelectionData
return &Selector{stmt.Select.Marks}, nil
}
ps.LastType = ps.MarkTypes[stmt.Select]
return &MarkSelect{stmt.Select}, nil
}

func (sc *DefaultStmtCompiler) Render(stmt *gripql.GraphStatement_Render, ps *gdbi.State) (gdbi.Processor, error) {
Expand Down
39 changes: 0 additions & 39 deletions engine/pipeline/pipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,45 +163,6 @@ func Convert(graph gdbi.GraphInterface, dataType gdbi.DataType, markTypes map[st
},
}

case gdbi.SelectionData:
selections := map[string]*gripql.Selection{}
for k, v := range t.GetSelections() {
vd := v.Get()
switch markTypes[k] {
case gdbi.VertexData:
var ve *gripql.Vertex
if !vd.Loaded {
ve = graph.GetVertex(vd.ID, true).ToVertex()
} else {
ve = vd.ToVertex()
}
selections[k] = &gripql.Selection{
Result: &gripql.Selection_Vertex{
Vertex: ve,
},
}
case gdbi.EdgeData:
var ee *gripql.Edge
if !vd.Loaded {
ee = graph.GetEdge(ee.Gid, true).ToEdge()
} else {
ee = vd.ToEdge()
}
selections[k] = &gripql.Selection{
Result: &gripql.Selection_Edge{
Edge: ee,
},
}
}
}
return &gripql.QueryResult{
Result: &gripql.QueryResult_Selections{
Selections: &gripql.Selections{
Selections: selections,
},
},
}

case gdbi.RenderData:
sValue, _ := structpb.NewValue(t.GetRender())
return &gripql.QueryResult{
Expand Down
2 changes: 1 addition & 1 deletion gdbi/statement_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func StatementProcessor(
return nil, fmt.Errorf(`"select" statement is only valid for edge or vertex types not: %s`, ps.LastType.String())
}
out, err := sc.Select(stmt, ps)
ps.LastType = ps.MarkTypes[stmt.Select.Marks[0]]
ps.LastType = ps.MarkTypes[stmt.Select]
return out, err

case *gripql.GraphStatement_Render:
Expand Down
Loading

0 comments on commit 0f69c26

Please sign in to comment.