Rename triple entities were relevant

This commit is contained in:
kortschak 2014-08-27 21:27:01 +09:30
parent ddf8849e60
commit 443a091b72
62 changed files with 664 additions and 664 deletions

View file

@ -17,9 +17,9 @@ package iterator
// Defines one of the base iterators, the All iterator. Which, logically
// enough, represents all nodes or all links in the graph.
//
// This particular file is actually vestigial. It's up to the TripleStore to give
// This particular file is actually vestigial. It's up to the QuadStore to give
// us an All iterator that represents all things in the graph. So this is
// really the All iterator for the MemTripleStore. That said, it *is* one of
// really the All iterator for the memstore.QuadStore. That said, it *is* one of
// the base iterators, and it helps just to see it here.
import (

View file

@ -1,5 +1,5 @@
// Defines the And iterator, one of the base iterators. And requires no
// knowledge of the constituent TripleStore; its sole purpose is to act as an
// knowledge of the constituent QuadStore; its sole purpose is to act as an
// intersection operator across the subiterators it is given. If one iterator
// contains [1,3,5] and another [2,3,4] -- then And is an iterator that
// 'contains' [3]

View file

@ -18,7 +18,7 @@ package iterator
// contains an explicit fixed array of values.
//
// A fixed iterator requires an Equality function to be passed to it, by reason that graph.Value, the
// opaque Triple store value, may not answer to ==.
// opaque Quad store value, may not answer to ==.
import (
"fmt"

View file

@ -21,7 +21,7 @@ package iterator
//
// HasA is weird in that it may return the same value twice if on the Next()
// path. That's okay -- in reality, it can be viewed as returning the value for
// a new triple, but to make logic much simpler, here we have the HasA.
// a new quad, but to make logic much simpler, here we have the HasA.
//
// Likewise, it's important to think about Contains()ing a HasA. When given a
// value to check, it means "Check all predicates that have this value for your
@ -43,13 +43,13 @@ import (
"github.com/google/cayley/quad"
)
// A HasA consists of a reference back to the graph.TripleStore that it references,
// a primary subiterator, a direction in which the triples for that subiterator point,
// A HasA consists of a reference back to the graph.QuadStore that it references,
// a primary subiterator, a direction in which the quads for that subiterator point,
// and a temporary holder for the iterator generated on Contains().
type HasA struct {
uid uint64
tags graph.Tagger
ts graph.TripleStore
qs graph.QuadStore
primaryIt graph.Iterator
dir quad.Direction
resultIt graph.Iterator
@ -57,12 +57,12 @@ type HasA struct {
runstats graph.IteratorStats
}
// Construct a new HasA iterator, given the triple subiterator, and the triple
// Construct a new HasA iterator, given the quad subiterator, and the quad
// direction for which it stands.
func NewHasA(ts graph.TripleStore, subIt graph.Iterator, d quad.Direction) *HasA {
func NewHasA(qs graph.QuadStore, subIt graph.Iterator, d quad.Direction) *HasA {
return &HasA{
uid: NextUID(),
ts: ts,
qs: qs,
primaryIt: subIt,
dir: d,
}
@ -89,7 +89,7 @@ func (it *HasA) Tagger() *graph.Tagger {
}
func (it *HasA) Clone() graph.Iterator {
out := NewHasA(it.ts, it.primaryIt.Clone(), it.dir)
out := NewHasA(it.qs, it.primaryIt.Clone(), it.dir)
out.tags.CopyFrom(it)
return out
}
@ -98,7 +98,7 @@ func (it *HasA) Clone() graph.Iterator {
func (it *HasA) Direction() quad.Direction { return it.dir }
// Pass the Optimize() call along to the subiterator. If it becomes Null,
// then the HasA becomes Null (there are no triples that have any directions).
// then the HasA becomes Null (there are no quads that have any directions).
func (it *HasA) Optimize() (graph.Iterator, bool) {
newPrimary, changed := it.primaryIt.Optimize()
if changed {
@ -140,34 +140,34 @@ func (it *HasA) DebugString(indent int) string {
}
// Check a value against our internal iterator. In order to do this, we must first open a new
// iterator of "triples that have `val` in our direction", given to us by the triple store,
// iterator of "quads that have `val` in our direction", given to us by the quad store,
// and then Next() values out of that iterator and Contains() them against our subiterator.
func (it *HasA) Contains(val graph.Value) bool {
graph.ContainsLogIn(it, val)
it.runstats.Contains += 1
if glog.V(4) {
glog.V(4).Infoln("Id is", it.ts.NameOf(val))
glog.V(4).Infoln("Id is", it.qs.NameOf(val))
}
// TODO(barakmich): Optimize this
if it.resultIt != nil {
it.resultIt.Close()
}
it.resultIt = it.ts.TripleIterator(it.dir, val)
it.resultIt = it.qs.QuadIterator(it.dir, val)
return graph.ContainsLogOut(it, val, it.NextContains())
}
// NextContains() is shared code between Contains() and GetNextResult() -- calls next on the
// result iterator (a triple iterator based on the last checked value) and returns true if
// result iterator (a quad iterator based on the last checked value) and returns true if
// another match is made.
func (it *HasA) NextContains() bool {
for graph.Next(it.resultIt) {
it.runstats.ContainsNext += 1
link := it.resultIt.Result()
if glog.V(4) {
glog.V(4).Infoln("Quad is", it.ts.Quad(link))
glog.V(4).Infoln("Quad is", it.qs.Quad(link))
}
if it.primaryIt.Contains(link) {
it.result = it.ts.TripleDirection(link, it.dir)
it.result = it.qs.QuadDirection(link, it.dir)
return true
}
}
@ -192,7 +192,7 @@ func (it *HasA) NextPath() bool {
}
// Next advances the iterator. This is simpler than Contains. We have a
// subiterator we can get a value from, and we can take that resultant triple,
// subiterator we can get a value from, and we can take that resultant quad,
// pull our direction out of it, and return that.
func (it *HasA) Next() bool {
graph.NextLogIn(it)
@ -206,7 +206,7 @@ func (it *HasA) Next() bool {
return graph.NextLogOut(it, 0, false)
}
tID := it.primaryIt.Result()
val := it.ts.TripleDirection(tID, it.dir)
val := it.qs.QuadDirection(tID, it.dir)
it.result = val
return graph.NextLogOut(it, val, true)
}
@ -217,20 +217,20 @@ func (it *HasA) Result() graph.Value {
// GetStats() returns the statistics on the HasA iterator. This is curious. Next
// cost is easy, it's an extra call or so on top of the subiterator Next cost.
// ContainsCost involves going to the graph.TripleStore, iterating out values, and hoping
// ContainsCost involves going to the graph.QuadStore, iterating out values, and hoping
// one sticks -- potentially expensive, depending on fanout. Size, however, is
// potentially smaller. we know at worst it's the size of the subiterator, but
// if there are many repeated values, it could be much smaller in totality.
func (it *HasA) Stats() graph.IteratorStats {
subitStats := it.primaryIt.Stats()
// TODO(barakmich): These should really come from the triplestore itself
// TODO(barakmich): These should really come from the quadstore itself
// and be optimized.
faninFactor := int64(1)
fanoutFactor := int64(30)
nextConstant := int64(2)
tripleConstant := int64(1)
quadConstant := int64(1)
return graph.IteratorStats{
NextCost: tripleConstant + subitStats.NextCost,
NextCost: quadConstant + subitStats.NextCost,
ContainsCost: (fanoutFactor * nextConstant) * subitStats.ContainsCost,
Size: faninFactor * subitStats.Size,
Next: it.runstats.Next,

View file

@ -37,13 +37,13 @@ import (
"github.com/google/cayley/quad"
)
// A LinksTo has a reference back to the graph.TripleStore (to create the iterators
// A LinksTo has a reference back to the graph.QuadStore (to create the iterators
// for each node) the subiterator, and the direction the iterator comes from.
// `next_it` is the tempoarary iterator held per result in `primary_it`.
type LinksTo struct {
uid uint64
tags graph.Tagger
ts graph.TripleStore
qs graph.QuadStore
primaryIt graph.Iterator
dir quad.Direction
nextIt graph.Iterator
@ -53,10 +53,10 @@ type LinksTo struct {
// Construct a new LinksTo iterator around a direction and a subiterator of
// nodes.
func NewLinksTo(ts graph.TripleStore, it graph.Iterator, d quad.Direction) *LinksTo {
func NewLinksTo(qs graph.QuadStore, it graph.Iterator, d quad.Direction) *LinksTo {
return &LinksTo{
uid: NextUID(),
ts: ts,
qs: qs,
primaryIt: it,
dir: d,
nextIt: &Null{},
@ -80,7 +80,7 @@ func (it *LinksTo) Tagger() *graph.Tagger {
}
func (it *LinksTo) Clone() graph.Iterator {
out := NewLinksTo(it.ts, it.primaryIt.Clone(), it.dir)
out := NewLinksTo(it.qs, it.primaryIt.Clone(), it.dir)
out.tags.CopyFrom(it)
return out
}
@ -120,7 +120,7 @@ func (it *LinksTo) DebugString(indent int) string {
func (it *LinksTo) Contains(val graph.Value) bool {
graph.ContainsLogIn(it, val)
it.runstats.Contains += 1
node := it.ts.TripleDirection(val, it.dir)
node := it.qs.QuadDirection(val, it.dir)
if it.primaryIt.Contains(node) {
it.result = val
return graph.ContainsLogOut(it, val, true)
@ -143,10 +143,10 @@ func (it *LinksTo) Optimize() (graph.Iterator, bool) {
return it.primaryIt, true
}
}
// Ask the graph.TripleStore if we can be replaced. Often times, this is a great
// Ask the graph.QuadStore if we can be replaced. Often times, this is a great
// optimization opportunity (there's a fixed iterator underneath us, for
// example).
newReplacement, hasOne := it.ts.OptimizeIterator(it)
newReplacement, hasOne := it.qs.OptimizeIterator(it)
if hasOne {
it.Close()
return newReplacement, true
@ -170,7 +170,7 @@ func (it *LinksTo) Next() bool {
return graph.NextLogOut(it, 0, false)
}
it.nextIt.Close()
it.nextIt = it.ts.TripleIterator(it.dir, it.primaryIt.Result())
it.nextIt = it.qs.QuadIterator(it.dir, it.primaryIt.Result())
// Recurse -- return the first in the next set.
return it.Next()
@ -197,7 +197,7 @@ func (it *LinksTo) Type() graph.Type { return graph.LinksTo }
// Return a guess as to how big or costly it is to next the iterator.
func (it *LinksTo) Stats() graph.IteratorStats {
subitStats := it.primaryIt.Stats()
// TODO(barakmich): These should really come from the triplestore itself
// TODO(barakmich): These should really come from the quadstore itself
fanoutFactor := int64(20)
checkConstant := int64(1)
nextConstant := int64(2)

View file

@ -21,23 +21,23 @@ import (
)
func TestLinksTo(t *testing.T) {
ts := &store{
qs := &store{
data: []string{1: "cool"},
iter: newFixed(),
}
ts.iter.(*Fixed).Add(2)
qs.iter.(*Fixed).Add(2)
fixed := newFixed()
val := ts.ValueOf("cool")
val := qs.ValueOf("cool")
if val != 1 {
t.Fatalf("Failed to return correct value, got:%v expect:1", val)
}
fixed.Add(val)
lto := NewLinksTo(ts, fixed, quad.Object)
lto := NewLinksTo(qs, fixed, quad.Object)
if !lto.Next() {
t.Error("At least one triple matches the fixed object")
t.Error("At least one quad matches the fixed object")
}
val = lto.Result()
if val != 2 {
t.Errorf("Quad index 2, such as %s, should match %s", ts.Quad(2), ts.Quad(val))
t.Errorf("Quad index 2, such as %s, should match %s", qs.Quad(2), qs.Quad(val))
}
}

View file

@ -14,14 +14,12 @@
package iterator
// A quickly mocked version of the TripleStore interface, for use in tests.
// Can better used Mock.Called but will fill in as needed.
import (
"github.com/google/cayley/graph"
"github.com/google/cayley/quad"
)
// store is a mocked version of the QuadStore interface, for use in tests.
type store struct {
data []string
iter graph.Iterator
@ -40,13 +38,13 @@ func (qs *store) ApplyDeltas([]graph.Delta) error { return nil }
func (qs *store) Quad(graph.Value) quad.Quad { return quad.Quad{} }
func (qs *store) TripleIterator(d quad.Direction, i graph.Value) graph.Iterator {
func (qs *store) QuadIterator(d quad.Direction, i graph.Value) graph.Iterator {
return qs.iter
}
func (qs *store) NodesAllIterator() graph.Iterator { return &Null{} }
func (qs *store) TriplesAllIterator() graph.Iterator { return &Null{} }
func (qs *store) QuadsAllIterator() graph.Iterator { return &Null{} }
func (qs *store) NameOf(v graph.Value) string {
i := v.(int)
@ -72,6 +70,6 @@ func (qs *store) FixedIterator() graph.FixedIterator {
func (qs *store) Close() {}
func (qs *store) TripleDirection(graph.Value, quad.Direction) graph.Value { return 0 }
func (qs *store) QuadDirection(graph.Value, quad.Direction) graph.Value { return 0 }
func (qs *store) RemoveTriple(t quad.Quad) {}
func (qs *store) RemoveQuad(t quad.Quad) {}

View file

@ -37,47 +37,47 @@ type Link struct {
type queryShape struct {
nodes []Node
links []Link
ts graph.TripleStore
qs graph.QuadStore
nodeId int
hasaIds []int
hasaDirs []quad.Direction
}
func OutputQueryShapeForIterator(it graph.Iterator, ts graph.TripleStore, outputMap map[string]interface{}) {
qs := &queryShape{
ts: ts,
func OutputQueryShapeForIterator(it graph.Iterator, qs graph.QuadStore, outputMap map[string]interface{}) {
s := &queryShape{
qs: qs,
nodeId: 1,
}
node := qs.MakeNode(it.Clone())
qs.AddNode(node)
outputMap["nodes"] = qs.nodes
outputMap["links"] = qs.links
node := s.MakeNode(it.Clone())
s.AddNode(node)
outputMap["nodes"] = s.nodes
outputMap["links"] = s.links
}
func (qs *queryShape) AddNode(n *Node) {
qs.nodes = append(qs.nodes, *n)
func (s *queryShape) AddNode(n *Node) {
s.nodes = append(s.nodes, *n)
}
func (qs *queryShape) AddLink(l *Link) {
qs.links = append(qs.links, *l)
func (s *queryShape) AddLink(l *Link) {
s.links = append(s.links, *l)
}
func (qs *queryShape) LastHasa() (int, quad.Direction) {
return qs.hasaIds[len(qs.hasaIds)-1], qs.hasaDirs[len(qs.hasaDirs)-1]
func (s *queryShape) LastHasa() (int, quad.Direction) {
return s.hasaIds[len(s.hasaIds)-1], s.hasaDirs[len(s.hasaDirs)-1]
}
func (qs *queryShape) PushHasa(i int, d quad.Direction) {
qs.hasaIds = append(qs.hasaIds, i)
qs.hasaDirs = append(qs.hasaDirs, d)
func (s *queryShape) PushHasa(i int, d quad.Direction) {
s.hasaIds = append(s.hasaIds, i)
s.hasaDirs = append(s.hasaDirs, d)
}
func (qs *queryShape) RemoveHasa() {
qs.hasaIds = qs.hasaIds[:len(qs.hasaIds)-1]
qs.hasaDirs = qs.hasaDirs[:len(qs.hasaDirs)-1]
func (s *queryShape) RemoveHasa() {
s.hasaIds = s.hasaIds[:len(s.hasaIds)-1]
s.hasaDirs = s.hasaDirs[:len(s.hasaDirs)-1]
}
func (qs *queryShape) StealNode(left *Node, right *Node) {
func (s *queryShape) StealNode(left *Node, right *Node) {
for _, v := range right.Values {
left.Values = append(left.Values, v)
}
@ -86,7 +86,7 @@ func (qs *queryShape) StealNode(left *Node, right *Node) {
}
left.IsLinkNode = left.IsLinkNode || right.IsLinkNode
left.IsFixed = left.IsFixed || right.IsFixed
for i, link := range qs.links {
for i, link := range s.links {
rewrite := false
if link.LinkNode == right.Id {
link.LinkNode = left.Id
@ -101,13 +101,13 @@ func (qs *queryShape) StealNode(left *Node, right *Node) {
rewrite = true
}
if rewrite {
qs.links = append(append(qs.links[:i], qs.links[i+1:]...), link)
s.links = append(append(s.links[:i], s.links[i+1:]...), link)
}
}
}
func (qs *queryShape) MakeNode(it graph.Iterator) *Node {
n := Node{Id: qs.nodeId}
func (s *queryShape) MakeNode(it graph.Iterator) *Node {
n := Node{Id: s.nodeId}
for _, tag := range it.Tagger().Tags() {
n.Tags = append(n.Tags, tag)
}
@ -118,56 +118,56 @@ func (qs *queryShape) MakeNode(it graph.Iterator) *Node {
switch it.Type() {
case graph.And:
for _, sub := range it.SubIterators() {
qs.nodeId++
newNode := qs.MakeNode(sub)
s.nodeId++
newNode := s.MakeNode(sub)
if sub.Type() != graph.Or {
qs.StealNode(&n, newNode)
s.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
qs.AddLink(&Link{n.Id, newNode.Id, 0, 0})
s.AddNode(newNode)
s.AddLink(&Link{n.Id, newNode.Id, 0, 0})
}
}
case graph.Fixed:
n.IsFixed = true
for graph.Next(it) {
n.Values = append(n.Values, qs.ts.NameOf(it.Result()))
n.Values = append(n.Values, s.qs.NameOf(it.Result()))
}
case graph.HasA:
hasa := it.(*HasA)
qs.PushHasa(n.Id, hasa.dir)
qs.nodeId++
newNode := qs.MakeNode(hasa.primaryIt)
qs.AddNode(newNode)
qs.RemoveHasa()
s.PushHasa(n.Id, hasa.dir)
s.nodeId++
newNode := s.MakeNode(hasa.primaryIt)
s.AddNode(newNode)
s.RemoveHasa()
case graph.Or:
for _, sub := range it.SubIterators() {
qs.nodeId++
newNode := qs.MakeNode(sub)
s.nodeId++
newNode := s.MakeNode(sub)
if sub.Type() == graph.Or {
qs.StealNode(&n, newNode)
s.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
qs.AddLink(&Link{n.Id, newNode.Id, 0, 0})
s.AddNode(newNode)
s.AddLink(&Link{n.Id, newNode.Id, 0, 0})
}
}
case graph.LinksTo:
n.IsLinkNode = true
lto := it.(*LinksTo)
qs.nodeId++
newNode := qs.MakeNode(lto.primaryIt)
hasaID, hasaDir := qs.LastHasa()
s.nodeId++
newNode := s.MakeNode(lto.primaryIt)
hasaID, hasaDir := s.LastHasa()
if (hasaDir == quad.Subject && lto.dir == quad.Object) ||
(hasaDir == quad.Object && lto.dir == quad.Subject) {
qs.AddNode(newNode)
s.AddNode(newNode)
if hasaDir == quad.Subject {
qs.AddLink(&Link{hasaID, newNode.Id, 0, n.Id})
s.AddLink(&Link{hasaID, newNode.Id, 0, n.Id})
} else {
qs.AddLink(&Link{newNode.Id, hasaID, 0, n.Id})
s.AddLink(&Link{newNode.Id, hasaID, 0, n.Id})
}
} else if lto.primaryIt.Type() == graph.Fixed {
qs.StealNode(&n, newNode)
s.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
s.AddNode(newNode)
}
case graph.Optional:
// Unsupported, for the moment

View file

@ -22,23 +22,23 @@ import (
"github.com/google/cayley/quad"
)
func hasaWithTag(ts graph.TripleStore, tag string, target string) *HasA {
func hasaWithTag(qs graph.QuadStore, tag string, target string) *HasA {
and := NewAnd()
obj := ts.FixedIterator()
obj.Add(ts.ValueOf(target))
obj := qs.FixedIterator()
obj.Add(qs.ValueOf(target))
obj.Tagger().Add(tag)
and.AddSubIterator(NewLinksTo(ts, obj, quad.Object))
and.AddSubIterator(NewLinksTo(qs, obj, quad.Object))
pred := ts.FixedIterator()
pred.Add(ts.ValueOf("status"))
and.AddSubIterator(NewLinksTo(ts, pred, quad.Predicate))
pred := qs.FixedIterator()
pred.Add(qs.ValueOf("status"))
and.AddSubIterator(NewLinksTo(qs, pred, quad.Predicate))
return NewHasA(ts, and, quad.Subject)
return NewHasA(qs, and, quad.Subject)
}
func TestQueryShape(t *testing.T) {
ts := &store{
qs := &store{
data: []string{
1: "cool",
2: "status",
@ -48,11 +48,11 @@ func TestQueryShape(t *testing.T) {
}
// Given a single linkage iterator's shape.
hasa := hasaWithTag(ts, "tag", "cool")
hasa := hasaWithTag(qs, "tag", "cool")
hasa.Tagger().Add("top")
shape := make(map[string]interface{})
OutputQueryShapeForIterator(hasa, ts, shape)
OutputQueryShapeForIterator(hasa, qs, shape)
nodes := shape["nodes"].([]Node)
if len(nodes) != 3 {
@ -93,23 +93,23 @@ func TestQueryShape(t *testing.T) {
// Given a name-of-an-and-iterator's shape.
andInternal := NewAnd()
hasa1 := hasaWithTag(ts, "tag1", "cool")
hasa1 := hasaWithTag(qs, "tag1", "cool")
hasa1.Tagger().Add("hasa1")
andInternal.AddSubIterator(hasa1)
hasa2 := hasaWithTag(ts, "tag2", "fun")
hasa2 := hasaWithTag(qs, "tag2", "fun")
hasa2.Tagger().Add("hasa2")
andInternal.AddSubIterator(hasa2)
pred := ts.FixedIterator()
pred.Add(ts.ValueOf("name"))
pred := qs.FixedIterator()
pred.Add(qs.ValueOf("name"))
and := NewAnd()
and.AddSubIterator(NewLinksTo(ts, andInternal, quad.Subject))
and.AddSubIterator(NewLinksTo(ts, pred, quad.Predicate))
and.AddSubIterator(NewLinksTo(qs, andInternal, quad.Subject))
and.AddSubIterator(NewLinksTo(qs, pred, quad.Predicate))
shape = make(map[string]interface{})
OutputQueryShapeForIterator(NewHasA(ts, and, quad.Object), ts, shape)
OutputQueryShapeForIterator(NewHasA(qs, and, quad.Object), qs, shape)
links = shape["links"].([]Link)
if len(links) != 3 {

View file

@ -51,17 +51,17 @@ type Comparison struct {
subIt graph.Iterator
op Operator
val interface{}
ts graph.TripleStore
qs graph.QuadStore
result graph.Value
}
func NewComparison(sub graph.Iterator, op Operator, val interface{}, ts graph.TripleStore) *Comparison {
func NewComparison(sub graph.Iterator, op Operator, val interface{}, qs graph.QuadStore) *Comparison {
return &Comparison{
uid: NextUID(),
subIt: sub,
op: op,
val: val,
ts: ts,
qs: qs,
}
}
@ -73,7 +73,7 @@ func (it *Comparison) UID() uint64 {
// and our operator, determine whether or not we meet the requirement.
func (it *Comparison) doComparison(val graph.Value) bool {
//TODO(barakmich): Implement string comparison.
nodeStr := it.ts.NameOf(val)
nodeStr := it.qs.NameOf(val)
switch cVal := it.val.(type) {
case int:
cInt := int64(cVal)
@ -122,7 +122,7 @@ func (it *Comparison) Tagger() *graph.Tagger {
}
func (it *Comparison) Clone() graph.Iterator {
out := NewComparison(it.subIt.Clone(), it.op, it.val, it.ts)
out := NewComparison(it.subIt.Clone(), it.op, it.val, it.qs)
out.tags.CopyFrom(it)
return out
}

View file

@ -65,12 +65,12 @@ var comparisonTests = []struct {
func TestValueComparison(t *testing.T) {
for _, test := range comparisonTests {
ts := simpleStore
vc := NewComparison(simpleFixedIterator(), test.operator, test.operand, ts)
qs := simpleStore
vc := NewComparison(simpleFixedIterator(), test.operator, test.operand, qs)
var got []string
for vc.Next() {
got = append(got, ts.NameOf(vc.Result()))
got = append(got, qs.NameOf(vc.Result()))
}
if !reflect.DeepEqual(got, test.expect) {
t.Errorf("Failed to show %s, got:%q expect:%q", test.message, got, test.expect)