Quieten deadcode
This commit is contained in:
parent
484bf145a8
commit
8118c8d3cc
11 changed files with 25 additions and 37 deletions
|
|
@ -503,5 +503,5 @@ func compareTokens(a, b graph.Value) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
||||||
return iterator.NewFixedIteratorWithCompare(compareTokens)
|
return iterator.NewFixed(compareTokens)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
|
|
||||||
func TestIteratorPromotion(t *testing.T) {
|
func TestIteratorPromotion(t *testing.T) {
|
||||||
all := NewInt64(1, 3)
|
all := NewInt64(1, 3)
|
||||||
fixed := newFixed()
|
fixed := NewFixed(Identity)
|
||||||
fixed.Add(3)
|
fixed.Add(3)
|
||||||
a := NewAnd()
|
a := NewAnd()
|
||||||
a.AddSubIterator(all)
|
a.AddSubIterator(all)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
// Make sure that tags work on the And.
|
// Make sure that tags work on the And.
|
||||||
func TestTag(t *testing.T) {
|
func TestTag(t *testing.T) {
|
||||||
fix1 := newFixed()
|
fix1 := NewFixed(Identity)
|
||||||
fix1.Add(234)
|
fix1.Add(234)
|
||||||
fix1.Tagger().Add("foo")
|
fix1.Tagger().Add("foo")
|
||||||
and := NewAnd()
|
and := NewAnd()
|
||||||
|
|
@ -55,12 +55,12 @@ func TestTag(t *testing.T) {
|
||||||
|
|
||||||
// Do a simple itersection of fixed values.
|
// Do a simple itersection of fixed values.
|
||||||
func TestAndAndFixedIterators(t *testing.T) {
|
func TestAndAndFixedIterators(t *testing.T) {
|
||||||
fix1 := newFixed()
|
fix1 := NewFixed(Identity)
|
||||||
fix1.Add(1)
|
fix1.Add(1)
|
||||||
fix1.Add(2)
|
fix1.Add(2)
|
||||||
fix1.Add(3)
|
fix1.Add(3)
|
||||||
fix1.Add(4)
|
fix1.Add(4)
|
||||||
fix2 := newFixed()
|
fix2 := NewFixed(Identity)
|
||||||
fix2.Add(3)
|
fix2.Add(3)
|
||||||
fix2.Add(4)
|
fix2.Add(4)
|
||||||
fix2.Add(5)
|
fix2.Add(5)
|
||||||
|
|
@ -93,12 +93,12 @@ func TestAndAndFixedIterators(t *testing.T) {
|
||||||
// If there's no intersection, the size should still report the same,
|
// If there's no intersection, the size should still report the same,
|
||||||
// but there should be nothing to Next()
|
// but there should be nothing to Next()
|
||||||
func TestNonOverlappingFixedIterators(t *testing.T) {
|
func TestNonOverlappingFixedIterators(t *testing.T) {
|
||||||
fix1 := newFixed()
|
fix1 := NewFixed(Identity)
|
||||||
fix1.Add(1)
|
fix1.Add(1)
|
||||||
fix1.Add(2)
|
fix1.Add(2)
|
||||||
fix1.Add(3)
|
fix1.Add(3)
|
||||||
fix1.Add(4)
|
fix1.Add(4)
|
||||||
fix2 := newFixed()
|
fix2 := NewFixed(Identity)
|
||||||
fix2.Add(5)
|
fix2.Add(5)
|
||||||
fix2.Add(6)
|
fix2.Add(6)
|
||||||
fix2.Add(7)
|
fix2.Add(7)
|
||||||
|
|
|
||||||
|
|
@ -42,24 +42,16 @@ type Fixed struct {
|
||||||
type Equality func(a, b graph.Value) bool
|
type Equality func(a, b graph.Value) bool
|
||||||
|
|
||||||
// Define an equality function of purely ==, which works for native types.
|
// Define an equality function of purely ==, which works for native types.
|
||||||
func BasicEquality(a, b graph.Value) bool {
|
func Identity(a, b graph.Value) bool {
|
||||||
if a == b {
|
return a == b
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new Fixed iterator based around == equality.
|
// Creates a new Fixed iterator with a custom comparator.
|
||||||
func newFixed() *Fixed {
|
func NewFixed(cmp Equality) *Fixed {
|
||||||
return NewFixedIteratorWithCompare(BasicEquality)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a new Fixed iterator with a custom comparitor.
|
|
||||||
func NewFixedIteratorWithCompare(compareFn Equality) *Fixed {
|
|
||||||
return &Fixed{
|
return &Fixed{
|
||||||
uid: NextUID(),
|
uid: NextUID(),
|
||||||
values: make([]graph.Value, 0, 20),
|
values: make([]graph.Value, 0, 20),
|
||||||
cmp: compareFn,
|
cmp: cmp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +80,7 @@ func (it *Fixed) TagResults(dst map[string]graph.Value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *Fixed) Clone() graph.Iterator {
|
func (it *Fixed) Clone() graph.Iterator {
|
||||||
out := NewFixedIteratorWithCompare(it.cmp)
|
out := NewFixed(it.cmp)
|
||||||
for _, val := range it.values {
|
for _, val := range it.values {
|
||||||
out.Add(val)
|
out.Add(val)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import (
|
||||||
func TestLinksTo(t *testing.T) {
|
func TestLinksTo(t *testing.T) {
|
||||||
qs := &store{
|
qs := &store{
|
||||||
data: []string{1: "cool"},
|
data: []string{1: "cool"},
|
||||||
iter: newFixed(),
|
iter: NewFixed(Identity),
|
||||||
}
|
}
|
||||||
qs.iter.(*Fixed).Add(2)
|
qs.iter.(*Fixed).Add(2)
|
||||||
fixed := newFixed()
|
fixed := NewFixed(Identity)
|
||||||
val := qs.ValueOf("cool")
|
val := qs.ValueOf("cool")
|
||||||
if val != 1 {
|
if val != 1 {
|
||||||
t.Fatalf("Failed to return correct value, got:%v expect:1", val)
|
t.Fatalf("Failed to return correct value, got:%v expect:1", val)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func (qs *store) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *store) FixedIterator() graph.FixedIterator {
|
func (qs *store) FixedIterator() graph.FixedIterator {
|
||||||
return NewFixedIteratorWithCompare(BasicEquality)
|
return NewFixed(Identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *store) Close() {}
|
func (qs *store) Close() {}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ func iterated(it graph.Iterator) []int {
|
||||||
|
|
||||||
func TestOrIteratorBasics(t *testing.T) {
|
func TestOrIteratorBasics(t *testing.T) {
|
||||||
or := NewOr()
|
or := NewOr()
|
||||||
f1 := newFixed()
|
f1 := NewFixed(Identity)
|
||||||
f1.Add(1)
|
f1.Add(1)
|
||||||
f1.Add(2)
|
f1.Add(2)
|
||||||
f1.Add(3)
|
f1.Add(3)
|
||||||
f2 := newFixed()
|
f2 := NewFixed(Identity)
|
||||||
f2.Add(3)
|
f2.Add(3)
|
||||||
f2.Add(9)
|
f2.Add(9)
|
||||||
f2.Add(20)
|
f2.Add(20)
|
||||||
|
|
@ -77,11 +77,11 @@ func TestOrIteratorBasics(t *testing.T) {
|
||||||
func TestShortCircuitingOrBasics(t *testing.T) {
|
func TestShortCircuitingOrBasics(t *testing.T) {
|
||||||
var or *Or
|
var or *Or
|
||||||
|
|
||||||
f1 := newFixed()
|
f1 := NewFixed(Identity)
|
||||||
f1.Add(1)
|
f1.Add(1)
|
||||||
f1.Add(2)
|
f1.Add(2)
|
||||||
f1.Add(3)
|
f1.Add(3)
|
||||||
f2 := newFixed()
|
f2 := NewFixed(Identity)
|
||||||
f2.Add(3)
|
f2.Add(3)
|
||||||
f2.Add(9)
|
f2.Add(9)
|
||||||
f2.Add(20)
|
f2.Add(20)
|
||||||
|
|
@ -133,7 +133,7 @@ func TestShortCircuitingOrBasics(t *testing.T) {
|
||||||
|
|
||||||
// Check that it pulls the second iterator's numbers if the first is empty.
|
// Check that it pulls the second iterator's numbers if the first is empty.
|
||||||
or = NewShortCircuitOr()
|
or = NewShortCircuitOr()
|
||||||
or.AddSubIterator(newFixed())
|
or.AddSubIterator(NewFixed(Identity))
|
||||||
or.AddSubIterator(f2)
|
or.AddSubIterator(f2)
|
||||||
expect = []int{3, 9, 20, 21}
|
expect = []int{3, 9, 20, 21}
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
var simpleStore = &store{data: []string{"0", "1", "2", "3", "4", "5"}}
|
var simpleStore = &store{data: []string{"0", "1", "2", "3", "4", "5"}}
|
||||||
|
|
||||||
func simpleFixedIterator() *Fixed {
|
func simpleFixedIterator() *Fixed {
|
||||||
f := newFixed()
|
f := NewFixed(Identity)
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
f.Add(i)
|
f.Add(i)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -480,5 +480,5 @@ func compareBytes(a, b graph.Value) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
||||||
return iterator.NewFixedIteratorWithCompare(compareBytes)
|
return iterator.NewFixed(compareBytes)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ func (qs *QuadStore) QuadsAllIterator() graph.Iterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
||||||
return iterator.NewFixedIteratorWithCompare(iterator.BasicEquality)
|
return iterator.NewFixed(iterator.Identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) QuadDirection(val graph.Value, d quad.Direction) graph.Value {
|
func (qs *QuadStore) QuadDirection(val graph.Value, d quad.Direction) graph.Value {
|
||||||
|
|
|
||||||
|
|
@ -327,12 +327,8 @@ func (qs *QuadStore) Horizon() int64 {
|
||||||
return log.LogID
|
return log.LogID
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareStrings(a, b graph.Value) bool {
|
|
||||||
return a.(string) == b.(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
func (qs *QuadStore) FixedIterator() graph.FixedIterator {
|
||||||
return iterator.NewFixedIteratorWithCompare(compareStrings)
|
return iterator.NewFixed(iterator.Identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qs *QuadStore) Close() {
|
func (qs *QuadStore) Close() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue