Rename TSVal

This commit is contained in:
kortschak 2014-07-02 12:13:15 +09:30
parent a1453da84e
commit d87e227ff3
29 changed files with 118 additions and 118 deletions

View file

@ -66,7 +66,7 @@ func (it *Int64) DebugString(indent int) string {
// Next() on an Int64 all iterator is a simple incrementing counter.
// Return the next integer, and mark it as the result.
func (it *Int64) Next() (graph.TSVal, bool) {
func (it *Int64) Next() (graph.Value, bool) {
graph.NextLogIn(it)
if it.at == -1 {
return graph.NextLogOut(it, nil, false)
@ -89,7 +89,7 @@ func (it *Int64) Size() (int64, bool) {
// Check() for an Int64 is merely seeing if the passed value is
// withing the range, assuming the value is an int64.
func (it *Int64) Check(tsv graph.TSVal) bool {
func (it *Int64) Check(tsv graph.Value) bool {
graph.CheckLogIn(it, tsv)
v := tsv.(int64)
if it.min <= v && v <= it.max {

View file

@ -73,7 +73,7 @@ func (it *And) SubIterators() []graph.Iterator {
// Overrides Base TagResults, as it needs to add it's own results and
// recurse down it's subiterators.
func (it *And) TagResults(dst map[string]graph.TSVal) {
func (it *And) TagResults(dst map[string]graph.Value) {
it.Base.TagResults(dst)
if it.primaryIt != nil {
it.primaryIt.TagResults(dst)
@ -139,9 +139,9 @@ func (it *And) AddSubIterator(sub graph.Iterator) {
// intersection of its subiterators, it must choose one subiterator to produce a
// candidate, and check this value against the subiterators. A productive choice
// of primary iterator is therefore very important.
func (it *And) Next() (graph.TSVal, bool) {
func (it *And) Next() (graph.Value, bool) {
graph.NextLogIn(it)
var curr graph.TSVal
var curr graph.Value
var exists bool
for {
curr, exists = it.primaryIt.Next()
@ -157,7 +157,7 @@ func (it *And) Next() (graph.TSVal, bool) {
}
// Checks a value against the non-primary iterators, in order.
func (it *And) checkSubIts(val graph.TSVal) bool {
func (it *And) checkSubIts(val graph.Value) bool {
var subIsGood = true
for _, sub := range it.internalIterators {
subIsGood = sub.Check(val)
@ -168,7 +168,7 @@ func (it *And) checkSubIts(val graph.TSVal) bool {
return subIsGood
}
func (it *And) checkCheckList(val graph.TSVal) bool {
func (it *And) checkCheckList(val graph.Value) bool {
ok := true
for _, c := range it.checkList {
ok = c.Check(val)
@ -183,7 +183,7 @@ func (it *And) checkCheckList(val graph.TSVal) bool {
}
// Check a value against the entire iterator, in order.
func (it *And) Check(val graph.TSVal) bool {
func (it *And) Check(val graph.Value) bool {
graph.CheckLogIn(it, val)
if it.checkList != nil {
return it.checkCheckList(val)

View file

@ -43,7 +43,7 @@ func TestTag(t *testing.T) {
if val != 234 {
t.Errorf("Unexpected value")
}
tags := make(map[string]graph.TSVal)
tags := make(map[string]graph.Value)
and.TagResults(tags)
if tags["bar"] != 234 {
t.Errorf("no bar tag")

View file

@ -17,7 +17,7 @@ package iterator
// Defines one of the base iterators, the Fixed iterator. A fixed iterator is quite simple; it
// contains an explicit fixed array of values.
//
// A fixed iterator requires an Equality function to be passed to it, by reason that graph.TSVal, the
// 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 ==.
import (
@ -31,16 +31,16 @@ import (
// an equality function.
type Fixed struct {
Base
values []graph.TSVal
values []graph.Value
lastIndex int
cmp Equality
}
// Define the signature of an equality function.
type Equality func(a, b graph.TSVal) bool
type Equality func(a, b graph.Value) bool
// Define an equality function of purely ==, which works for native types.
func BasicEquality(a, b graph.TSVal) bool {
func BasicEquality(a, b graph.Value) bool {
if a == b {
return true
}
@ -56,7 +56,7 @@ func newFixed() *Fixed {
func NewFixedIteratorWithCompare(compareFn Equality) *Fixed {
var it Fixed
BaseInit(&it.Base)
it.values = make([]graph.TSVal, 0, 20)
it.values = make([]graph.Value, 0, 20)
it.lastIndex = 0
it.cmp = compareFn
return &it
@ -79,7 +79,7 @@ func (it *Fixed) Clone() graph.Iterator {
// Add a value to the iterator. The array now contains this value.
// TODO(barakmich): This ought to be a set someday, disallowing repeated values.
func (it *Fixed) AddValue(v graph.TSVal) {
func (it *Fixed) AddValue(v graph.Value) {
it.values = append(it.values, v)
}
@ -104,7 +104,7 @@ func (it *Fixed) Type() string {
}
// Check if the passed value is equal to one of the values stored in the iterator.
func (it *Fixed) Check(v graph.TSVal) bool {
func (it *Fixed) Check(v graph.Value) bool {
// Could be optimized by keeping it sorted or using a better datastructure.
// However, for fixed iterators, which are by definition kind of tiny, this
// isn't a big issue.
@ -119,7 +119,7 @@ func (it *Fixed) Check(v graph.TSVal) bool {
}
// Return the next stored value from the iterator.
func (it *Fixed) Next() (graph.TSVal, bool) {
func (it *Fixed) Next() (graph.Value, bool) {
graph.NextLogIn(it)
if it.lastIndex == len(it.values) {
return graph.NextLogOut(it, nil, false)

View file

@ -99,7 +99,7 @@ func (it *HasA) Optimize() (graph.Iterator, bool) {
}
// Pass the TagResults down the chain.
func (it *HasA) TagResults(dst map[string]graph.TSVal) {
func (it *HasA) TagResults(dst map[string]graph.Value) {
it.Base.TagResults(dst)
it.primaryIt.TagResults(dst)
}
@ -123,7 +123,7 @@ 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,
// and then Next() values out of that iterator and Check() them against our subiterator.
func (it *HasA) Check(val graph.TSVal) bool {
func (it *HasA) Check(val graph.Value) bool {
graph.CheckLogIn(it, val)
if glog.V(4) {
glog.V(4).Infoln("Id is", it.ts.NameOf(val))
@ -173,7 +173,7 @@ func (it *HasA) NextResult() bool {
// Get the next result from this iterator. This is simpler than Check. We have a
// subiterator we can get a value from, and we can take that resultant triple,
// pull our direction out of it, and return that.
func (it *HasA) Next() (graph.TSVal, bool) {
func (it *HasA) Next() (graph.Value, bool) {
graph.NextLogIn(it)
if it.resultIt != nil {
it.resultIt.Close()

View file

@ -36,9 +36,9 @@ func nextID() uintptr {
// The Base iterator is the iterator other iterators inherit from to get some
// default functionality.
type Base struct {
Last graph.TSVal
Last graph.Value
tags []string
fixedTags map[string]graph.TSVal
fixedTags map[string]graph.Value
canNext bool
uid uintptr
}
@ -64,9 +64,9 @@ func (it *Base) AddTag(tag string) {
it.tags = append(it.tags, tag)
}
func (it *Base) AddFixedTag(tag string, value graph.TSVal) {
func (it *Base) AddFixedTag(tag string, value graph.Value) {
if it.fixedTags == nil {
it.fixedTags = make(map[string]graph.TSVal)
it.fixedTags = make(map[string]graph.Value)
}
it.fixedTags[tag] = value
}
@ -76,7 +76,7 @@ func (it *Base) Tags() []string {
return it.tags
}
func (it *Base) FixedTags() map[string]graph.TSVal {
func (it *Base) FixedTags() map[string]graph.Value {
return it.fixedTags
}
@ -97,7 +97,7 @@ func (it *Base) DebugString(indent int) string {
}
// Nothing in a base iterator.
func (it *Base) Check(v graph.TSVal) bool {
func (it *Base) Check(v graph.Value) bool {
return false
}
@ -114,7 +114,7 @@ func (it *Base) ResultTree() *graph.ResultTree {
}
// Nothing in a base iterator.
func (it *Base) Next() (graph.TSVal, bool) {
func (it *Base) Next() (graph.Value, bool) {
return nil, false
}
@ -123,7 +123,7 @@ func (it *Base) NextResult() bool {
}
// Returns the last result of an iterator.
func (it *Base) Result() graph.TSVal {
func (it *Base) Result() graph.Value {
return it.Last
}
@ -142,7 +142,7 @@ func (it *Base) CanNext() bool { return it.canNext }
// Fill the map based on the tags assigned to this iterator. Default
// functionality works well for most iterators.
func (it *Base) TagResults(dst map[string]graph.TSVal) {
func (it *Base) TagResults(dst map[string]graph.Value) {
for _, tag := range it.Tags() {
dst[tag] = it.Result()
}

View file

@ -77,7 +77,7 @@ func (it *LinksTo) Clone() graph.Iterator {
func (it *LinksTo) Direction() graph.Direction { return it.dir }
// Tag these results, and our subiterator's results.
func (it *LinksTo) TagResults(dst map[string]graph.TSVal) {
func (it *LinksTo) TagResults(dst map[string]graph.Value) {
it.Base.TagResults(dst)
it.primaryIt.TagResults(dst)
}
@ -98,7 +98,7 @@ func (it *LinksTo) DebugString(indent int) string {
// If it checks in the right direction for the subiterator, it is a valid link
// for the LinksTo.
func (it *LinksTo) Check(val graph.TSVal) bool {
func (it *LinksTo) Check(val graph.Value) bool {
graph.CheckLogIn(it, val)
node := it.ts.TripleDirection(val, it.dir)
if it.primaryIt.Check(node) {
@ -135,7 +135,7 @@ func (it *LinksTo) Optimize() (graph.Iterator, bool) {
}
// Next()ing a LinksTo operates as described above.
func (it *LinksTo) Next() (graph.TSVal, bool) {
func (it *LinksTo) Next() (graph.Value, bool) {
graph.NextLogIn(it)
val, ok := it.nextIt.Next()
if !ok {

View file

@ -27,14 +27,14 @@ type TestTripleStore struct {
mock.Mock
}
func (ts *TestTripleStore) ValueOf(s string) graph.TSVal {
func (ts *TestTripleStore) ValueOf(s string) graph.Value {
args := ts.Mock.Called(s)
return args.Get(0)
}
func (ts *TestTripleStore) AddTriple(*graph.Triple) {}
func (ts *TestTripleStore) AddTripleSet([]*graph.Triple) {}
func (ts *TestTripleStore) Triple(graph.TSVal) *graph.Triple { return &graph.Triple{} }
func (ts *TestTripleStore) TripleIterator(d graph.Direction, i graph.TSVal) graph.Iterator {
func (ts *TestTripleStore) Triple(graph.Value) *graph.Triple { return &graph.Triple{} }
func (ts *TestTripleStore) TripleIterator(d graph.Direction, i graph.Value) graph.Iterator {
args := ts.Mock.Called(d, i)
return args.Get(0).(graph.Iterator)
}
@ -43,7 +43,7 @@ func (ts *TestTripleStore) TriplesAllIterator() graph.Iterator { return &Null{}
func (ts *TestTripleStore) GetIteratorByString(string, string, string) graph.Iterator {
return &Null{}
}
func (ts *TestTripleStore) NameOf(v graph.TSVal) string {
func (ts *TestTripleStore) NameOf(v graph.Value) string {
args := ts.Mock.Called(v)
return args.Get(0).(string)
}
@ -56,5 +56,5 @@ func (ts *TestTripleStore) FixedIterator() graph.FixedIterator {
return NewFixedIteratorWithCompare(BasicEquality)
}
func (ts *TestTripleStore) Close() {}
func (ts *TestTripleStore) TripleDirection(graph.TSVal, graph.Direction) graph.TSVal { return 0 }
func (ts *TestTripleStore) TripleDirection(graph.Value, graph.Direction) graph.Value { return 0 }
func (ts *TestTripleStore) RemoveTriple(t *graph.Triple) {}

View file

@ -69,7 +69,7 @@ func (it *Optional) Clone() graph.Iterator {
// Nexting the iterator is unsupported -- error and return an empty set.
// (As above, a reasonable alternative would be to Next() an all iterator)
func (it *Optional) Next() (graph.TSVal, bool) {
func (it *Optional) Next() (graph.Value, bool) {
glog.Errorln("Nexting an un-nextable iterator")
return nil, false
}
@ -87,7 +87,7 @@ func (it *Optional) NextResult() bool {
// Check() is the real hack of this iterator. It always returns true, regardless
// of whether the subiterator matched. But we keep track of whether the subiterator
// matched for results purposes.
func (it *Optional) Check(val graph.TSVal) bool {
func (it *Optional) Check(val graph.Value) bool {
checked := it.subIt.Check(val)
it.lastCheck = checked
it.Last = val
@ -96,7 +96,7 @@ func (it *Optional) Check(val graph.TSVal) bool {
// If we failed the check, then the subiterator should not contribute to the result
// set. Otherwise, go ahead and tag it.
func (it *Optional) TagResults(dst map[string]graph.TSVal) {
func (it *Optional) TagResults(dst map[string]graph.Value) {
if it.lastCheck == false {
return
}

View file

@ -83,7 +83,7 @@ func (it *Or) SubIterators() []graph.Iterator {
// Overrides BaseIterator TagResults, as it needs to add it's own results and
// recurse down it's subiterators.
func (it *Or) TagResults(dst map[string]graph.TSVal) {
func (it *Or) TagResults(dst map[string]graph.Value) {
it.Base.TagResults(dst)
it.internalIterators[it.currentIterator].TagResults(dst)
}
@ -128,9 +128,9 @@ func (it *Or) AddSubIterator(sub graph.Iterator) {
// Returns the Next value from the Or graph.iterator. Because the Or is the
// union of its subiterators, it must produce from all subiterators -- unless
// it's shortcircuiting, in which case, it's the first one that returns anything.
func (it *Or) Next() (graph.TSVal, bool) {
func (it *Or) Next() (graph.Value, bool) {
graph.NextLogIn(it)
var curr graph.TSVal
var curr graph.Value
var exists bool
firstTime := false
for {
@ -157,7 +157,7 @@ func (it *Or) Next() (graph.TSVal, bool) {
}
// Checks a value against the iterators, in order.
func (it *Or) checkSubIts(val graph.TSVal) bool {
func (it *Or) checkSubIts(val graph.Value) bool {
var subIsGood = false
for i, sub := range it.internalIterators {
subIsGood = sub.Check(val)
@ -170,7 +170,7 @@ func (it *Or) checkSubIts(val graph.TSVal) bool {
}
// Check a value against the entire graph.iterator, in order.
func (it *Or) Check(val graph.TSVal) bool {
func (it *Or) Check(val graph.Value) bool {
graph.CheckLogIn(it, val)
anyGood := it.checkSubIts(val)
if !anyGood {

View file

@ -65,7 +65,7 @@ func NewComparison(sub graph.Iterator, op Operator, val interface{}, ts graph.Tr
// Here's the non-boilerplate part of the ValueComparison iterator. Given a value
// and our operator, determine whether or not we meet the requirement.
func (it *Comparison) doComparison(val graph.TSVal) bool {
func (it *Comparison) doComparison(val graph.Value) bool {
//TODO(barakmich): Implement string comparison.
nodeStr := it.ts.NameOf(val)
switch cVal := it.val.(type) {
@ -117,8 +117,8 @@ func (it *Comparison) Clone() graph.Iterator {
return out
}
func (it *Comparison) Next() (graph.TSVal, bool) {
var val graph.TSVal
func (it *Comparison) Next() (graph.Value, bool) {
var val graph.Value
var ok bool
for {
val, ok = it.subIt.Next()
@ -147,7 +147,7 @@ func (it *Comparison) NextResult() bool {
return true
}
func (it *Comparison) Check(val graph.TSVal) bool {
func (it *Comparison) Check(val graph.Value) bool {
if !it.doComparison(val) {
return false
}
@ -156,7 +156,7 @@ func (it *Comparison) Check(val graph.TSVal) bool {
// If we failed the check, then the subiterator should not contribute to the result
// set. Otherwise, go ahead and tag it.
func (it *Comparison) TagResults(dst map[string]graph.TSVal) {
func (it *Comparison) TagResults(dst map[string]graph.Value) {
it.Base.TagResults(dst)
it.subIt.TagResults(dst)
}