Skip to content

Commit

Permalink
deprecate quad.Raw type
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Dec 23, 2017
1 parent 4107f2f commit 41bf496
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 149 deletions.
8 changes: 4 additions & 4 deletions graph/bolt/bolt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ func TestLoadDatabase(t *testing.T) {
}

w, _ := writer.NewSingleReplication(qs, nil)
w.AddQuad(quad.MakeRaw(
w.AddQuad(quad.Make(
"Something",
"points_to",
"Something Else",
"context",
))
for _, pq := range []string{"Something", "points_to", "Something Else", "context"} {
if got := qs.NameOf(qs.ValueOf(quad.Raw(pq))).String(); got != pq {
if got := quad.ToString(qs.NameOf(qs.ValueOf(quad.Raw(pq)))); got != pq {
t.Errorf("Failed to roundtrip %q, got:%q expect:%q", pq, got, pq)
}
}
Expand Down Expand Up @@ -139,11 +139,11 @@ func TestLoadDatabase(t *testing.T) {
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
}

w.RemoveQuad(quad.MakeRaw(
w.RemoveQuad(quad.Make(
"A",
"follows",
"B",
"",
nil,
))
if s := qs.Size(); s != 11 {
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:11", s)
Expand Down
8 changes: 6 additions & 2 deletions graph/gaedatastore/quadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,15 @@ func (qs *QuadStore) Quad(val graph.Value) quad.Quad {
clog.Errorf("Error: %v", err)
}
}
return quad.MakeRaw(
var label interface{}
if q.Label != "" {
label = q.Label
}
return quad.Make(
q.Subject,
q.Predicate,
q.Object,
q.Label,
label,
)
}

Expand Down
6 changes: 3 additions & 3 deletions graph/gaedatastore/quadstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func TestIterators(t *testing.T) {
require.Equal(t, int64(11), qs.Size(), "Incorrect number of quads")

var expected = []quad.Quad{
quad.MakeRaw("C", "follows", "B", ""),
quad.MakeRaw("C", "follows", "D", ""),
quad.Make("C", "follows", "B", ""),
quad.Make("C", "follows", "D", ""),
}

it := qs.QuadIterator(quad.Subject, qs.ValueOf(quad.Raw("C")))
Expand All @@ -117,7 +117,7 @@ func TestIterators(t *testing.T) {
// Test contains
it = qs.QuadIterator(quad.Label, qs.ValueOf(quad.Raw("status_graph")))
gqs := qs.(*QuadStore)
key := gqs.createKeyForQuad(quad.MakeRaw("G", "status", "cool", "status_graph"))
key := gqs.createKeyForQuad(quad.Make("G", "status", "cool", "status_graph"))
token := &Token{quadKind, key.StringID()}

require.True(t, it.Contains(token), "Contains failed")
Expand Down
4 changes: 2 additions & 2 deletions graph/graphmock/graphmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (qs *Oldstore) ValueOf(s quad.Value) graph.Value {
return nil
}
for i := range qs.Data {
if s.String() == qs.valueAt(i).String() {
if va := qs.valueAt(i); va != nil && s.String() == va.String() {
return iterator.Int64Node(i)
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func (qs *Oldstore) NameOf(v graph.Value) quad.Value {
if qs.Parse {
return quad.String(v.(StringNode))
}
return quad.Raw(v.(StringNode))
return quad.Raw(string(v.(StringNode)))
default:
return nil
}
Expand Down
Loading

0 comments on commit 41bf496

Please sign in to comment.