Rename AddValue

This commit is contained in:
kortschak 2014-07-02 12:17:33 +09:30
parent d87e227ff3
commit 447a835b93
13 changed files with 61 additions and 61 deletions

View file

@ -26,7 +26,7 @@ import (
func TestIteratorPromotion(t *testing.T) {
all := NewInt64(1, 3)
fixed := newFixed()
fixed.AddValue(3)
fixed.Add(3)
a := NewAnd()
a.AddSubIterator(all)
a.AddSubIterator(fixed)

View file

@ -23,7 +23,7 @@ import (
// Make sure that tags work on the And.
func TestTag(t *testing.T) {
fix1 := newFixed()
fix1.AddValue(234)
fix1.Add(234)
fix1.AddTag("foo")
and := NewAnd()
and.AddSubIterator(fix1)
@ -56,14 +56,14 @@ func TestTag(t *testing.T) {
// Do a simple itersection of fixed values.
func TestAndAndFixedIterators(t *testing.T) {
fix1 := newFixed()
fix1.AddValue(1)
fix1.AddValue(2)
fix1.AddValue(3)
fix1.AddValue(4)
fix1.Add(1)
fix1.Add(2)
fix1.Add(3)
fix1.Add(4)
fix2 := newFixed()
fix2.AddValue(3)
fix2.AddValue(4)
fix2.AddValue(5)
fix2.Add(3)
fix2.Add(4)
fix2.Add(5)
and := NewAnd()
and.AddSubIterator(fix1)
and.AddSubIterator(fix2)
@ -97,14 +97,14 @@ func TestAndAndFixedIterators(t *testing.T) {
// but there should be nothing to Next()
func TestNonOverlappingFixedIterators(t *testing.T) {
fix1 := newFixed()
fix1.AddValue(1)
fix1.AddValue(2)
fix1.AddValue(3)
fix1.AddValue(4)
fix1.Add(1)
fix1.Add(2)
fix1.Add(3)
fix1.Add(4)
fix2 := newFixed()
fix2.AddValue(5)
fix2.AddValue(6)
fix2.AddValue(7)
fix2.Add(5)
fix2.Add(6)
fix2.Add(7)
and := NewAnd()
and.AddSubIterator(fix1)
and.AddSubIterator(fix2)

View file

@ -71,7 +71,7 @@ func (it *Fixed) Close() {}
func (it *Fixed) Clone() graph.Iterator {
out := NewFixedIteratorWithCompare(it.cmp)
for _, val := range it.values {
out.AddValue(val)
out.Add(val)
}
out.CopyTagsFrom(it)
return out
@ -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.Value) {
func (it *Fixed) Add(v graph.Value) {
it.values = append(it.values, v)
}

View file

@ -23,11 +23,11 @@ import (
func TestLinksTo(t *testing.T) {
ts := new(TestTripleStore)
tsFixed := newFixed()
tsFixed.AddValue(2)
tsFixed.Add(2)
ts.On("ValueOf", "cool").Return(1)
ts.On("TripleIterator", graph.Object, 1).Return(tsFixed)
fixed := newFixed()
fixed.AddValue(ts.ValueOf("cool"))
fixed.Add(ts.ValueOf("cool"))
lto := NewLinksTo(ts, fixed, graph.Object)
val, ok := lto.Next()
if !ok {

View file

@ -40,14 +40,14 @@ func TestOrIteratorBasics(t *testing.T) {
Convey("Given an Or Iterator of two fixed iterators", t, func() {
orIt = NewOr()
fixed1 := newFixed()
fixed1.AddValue(1)
fixed1.AddValue(2)
fixed1.AddValue(3)
fixed1.Add(1)
fixed1.Add(2)
fixed1.Add(3)
fixed2 := newFixed()
fixed2.AddValue(3)
fixed2.AddValue(9)
fixed2.AddValue(20)
fixed2.AddValue(21)
fixed2.Add(3)
fixed2.Add(9)
fixed2.Add(20)
fixed2.Add(21)
orIt.AddSubIterator(fixed1)
orIt.AddSubIterator(fixed2)
@ -88,14 +88,14 @@ func TestShortCircuitingOrBasics(t *testing.T) {
Convey("Given a short-circuiting Or of two fixed iterators", t, func() {
orIt = NewShortCircuitOr()
fixed1 := newFixed()
fixed1.AddValue(1)
fixed1.AddValue(2)
fixed1.AddValue(3)
fixed1.Add(1)
fixed1.Add(2)
fixed1.Add(3)
fixed2 := newFixed()
fixed2.AddValue(3)
fixed2.AddValue(9)
fixed2.AddValue(20)
fixed2.AddValue(21)
fixed2.Add(3)
fixed2.Add(9)
fixed2.Add(20)
fixed2.Add(21)
Convey("It should guess its size.", func() {
orIt.AddSubIterator(fixed1)

View file

@ -25,8 +25,8 @@ import (
func buildHasaWithTag(ts graph.TripleStore, tag string, target string) *HasA {
fixed_obj := ts.FixedIterator()
fixed_pred := ts.FixedIterator()
fixed_obj.AddValue(ts.ValueOf(target))
fixed_pred.AddValue(ts.ValueOf("status"))
fixed_obj.Add(ts.ValueOf(target))
fixed_pred.Add(ts.ValueOf("status"))
fixed_obj.AddTag(tag)
lto1 := NewLinksTo(ts, fixed_obj, graph.Object)
lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate)
@ -92,7 +92,7 @@ func TestQueryShape(t *testing.T) {
andInternal.AddSubIterator(hasa1)
andInternal.AddSubIterator(hasa2)
fixed_pred := ts.FixedIterator()
fixed_pred.AddValue(ts.ValueOf("name"))
fixed_pred.Add(ts.ValueOf("name"))
lto1 := NewLinksTo(ts, andInternal, graph.Subject)
lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate)
and := NewAnd()

View file

@ -43,11 +43,11 @@ func SimpleValueTripleStore() *TestTripleStore {
func BuildFixedIterator() *Fixed {
fixed := newFixed()
fixed.AddValue(0)
fixed.AddValue(1)
fixed.AddValue(2)
fixed.AddValue(3)
fixed.AddValue(4)
fixed.Add(0)
fixed.Add(1)
fixed.Add(2)
fixed.Add(3)
fixed.Add(4)
return fixed
}