Reduce TripleStore interface names
This commit is contained in:
parent
8576f66d20
commit
b89d4f392c
29 changed files with 156 additions and 156 deletions
|
|
@ -217,11 +217,11 @@ func (ts *TripleStore) RemoveTriple(t *graph.Triple) {
|
|||
}
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetTriple(index graph.TSVal) *graph.Triple {
|
||||
func (ts *TripleStore) Triple(index graph.TSVal) *graph.Triple {
|
||||
return &ts.triples[index.(int64)]
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetTripleIterator(d graph.Direction, value graph.TSVal) graph.Iterator {
|
||||
func (ts *TripleStore) TripleIterator(d graph.Direction, value graph.TSVal) graph.Iterator {
|
||||
index, ok := ts.index.Get(d, value.(int64))
|
||||
data := fmt.Sprintf("dir:%s val:%d", d, value.(int64))
|
||||
if ok {
|
||||
|
|
@ -243,15 +243,15 @@ func (ts *TripleStore) DebugPrint() {
|
|||
}
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetIdFor(name string) graph.TSVal {
|
||||
func (ts *TripleStore) ValueOf(name string) graph.TSVal {
|
||||
return ts.idMap[name]
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetNameFor(id graph.TSVal) string {
|
||||
func (ts *TripleStore) NameOf(id graph.TSVal) string {
|
||||
return ts.revIdMap[id.(int64)]
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetTriplesAllIterator() graph.Iterator {
|
||||
func (ts *TripleStore) TriplesAllIterator() graph.Iterator {
|
||||
return iterator.NewInt64(0, ts.Size())
|
||||
}
|
||||
|
||||
|
|
@ -259,12 +259,12 @@ func (ts *TripleStore) FixedIterator() graph.FixedIterator {
|
|||
return iterator.NewFixedIteratorWithCompare(iterator.BasicEquality)
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetTripleDirection(val graph.TSVal, d graph.Direction) graph.TSVal {
|
||||
name := ts.GetTriple(val).Get(d)
|
||||
return ts.GetIdFor(name)
|
||||
func (ts *TripleStore) TripleDirection(val graph.TSVal, d graph.Direction) graph.TSVal {
|
||||
name := ts.Triple(val).Get(d)
|
||||
return ts.ValueOf(name)
|
||||
}
|
||||
|
||||
func (ts *TripleStore) GetNodesAllIterator() graph.Iterator {
|
||||
func (ts *TripleStore) NodesAllIterator() graph.Iterator {
|
||||
return NewMemstoreAllIterator(ts)
|
||||
}
|
||||
func (ts *TripleStore) Close() {}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func (ts *TripleStore) optimizeLinksTo(it *iterator.LinksTo) (graph.Iterator, bo
|
|||
if !ok {
|
||||
panic("Sizes lie")
|
||||
}
|
||||
newIt := ts.GetTripleIterator(it.Direction(), val)
|
||||
newIt := ts.TripleIterator(it.Direction(), val)
|
||||
newIt.CopyTagsFrom(it)
|
||||
for _, tag := range primary.Tags() {
|
||||
newIt.AddFixedTag(tag, val)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func TestMemstore(t *testing.T) {
|
|||
So(ts.Size(), ShouldEqual, 11)
|
||||
})
|
||||
Convey("It should have an Id Space that makes sense", func() {
|
||||
v := ts.GetIdFor("C")
|
||||
v := ts.ValueOf("C")
|
||||
So(v.(int64), ShouldEqual, 4)
|
||||
})
|
||||
})
|
||||
|
|
@ -40,13 +40,13 @@ func TestMemstore(t *testing.T) {
|
|||
func TestIteratorsAndNextResultOrderA(t *testing.T) {
|
||||
ts := MakeTestingMemstore()
|
||||
fixed := ts.FixedIterator()
|
||||
fixed.AddValue(ts.GetIdFor("C"))
|
||||
all := ts.GetNodesAllIterator()
|
||||
fixed.AddValue(ts.ValueOf("C"))
|
||||
all := ts.NodesAllIterator()
|
||||
lto := iterator.NewLinksTo(ts, all, graph.Object)
|
||||
innerAnd := iterator.NewAnd()
|
||||
|
||||
fixed2 := ts.FixedIterator()
|
||||
fixed2.AddValue(ts.GetIdFor("follows"))
|
||||
fixed2.AddValue(ts.ValueOf("follows"))
|
||||
lto2 := iterator.NewLinksTo(ts, fixed2, graph.Predicate)
|
||||
innerAnd.AddSubIterator(lto2)
|
||||
innerAnd.AddSubIterator(lto)
|
||||
|
|
@ -58,19 +58,19 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
|
|||
if !ok {
|
||||
t.Error("Expected one matching subtree")
|
||||
}
|
||||
if ts.GetNameFor(val) != "C" {
|
||||
t.Errorf("Matching subtree should be %s, got %s", "barak", ts.GetNameFor(val))
|
||||
if ts.NameOf(val) != "C" {
|
||||
t.Errorf("Matching subtree should be %s, got %s", "barak", ts.NameOf(val))
|
||||
}
|
||||
expected := make([]string, 2)
|
||||
expected[0] = "B"
|
||||
expected[1] = "D"
|
||||
actualOut := make([]string, 2)
|
||||
actualOut[0] = ts.GetNameFor(all.LastResult())
|
||||
actualOut[0] = ts.NameOf(all.LastResult())
|
||||
nresultOk := outerAnd.NextResult()
|
||||
if !nresultOk {
|
||||
t.Error("Expected two results got one")
|
||||
}
|
||||
actualOut[1] = ts.GetNameFor(all.LastResult())
|
||||
actualOut[1] = ts.NameOf(all.LastResult())
|
||||
nresultOk = outerAnd.NextResult()
|
||||
if nresultOk {
|
||||
t.Error("Expected two results got three")
|
||||
|
|
@ -98,7 +98,7 @@ func CompareStringSlices(t *testing.T, expected []string, actual []string) {
|
|||
func TestLinksToOptimization(t *testing.T) {
|
||||
ts := MakeTestingMemstore()
|
||||
fixed := ts.FixedIterator()
|
||||
fixed.AddValue(ts.GetIdFor("cool"))
|
||||
fixed.AddValue(ts.ValueOf("cool"))
|
||||
lto := iterator.NewLinksTo(ts, fixed, graph.Object)
|
||||
lto.AddTag("foo")
|
||||
newIt, changed := lto.Optimize()
|
||||
|
|
@ -122,10 +122,10 @@ func TestRemoveTriple(t *testing.T) {
|
|||
ts := MakeTestingMemstore()
|
||||
ts.RemoveTriple(&graph.Triple{"E", "follows", "F", ""})
|
||||
fixed := ts.FixedIterator()
|
||||
fixed.AddValue(ts.GetIdFor("E"))
|
||||
fixed.AddValue(ts.ValueOf("E"))
|
||||
lto := iterator.NewLinksTo(ts, fixed, graph.Subject)
|
||||
fixed2 := ts.FixedIterator()
|
||||
fixed2.AddValue(ts.GetIdFor("follows"))
|
||||
fixed2.AddValue(ts.ValueOf("follows"))
|
||||
lto2 := iterator.NewLinksTo(ts, fixed2, graph.Predicate)
|
||||
innerAnd := iterator.NewAnd()
|
||||
innerAnd.AddSubIterator(lto2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue