From b89d4f392cbc3a217bbbc82d7c3ffe88d1ed234e Mon Sep 17 00:00:00 2001 From: kortschak Date: Wed, 2 Jul 2014 11:40:33 +0930 Subject: [PATCH] Reduce TripleStore interface names --- graph/iterator/hasa_iterator.go | 12 +++---- graph/iterator/linksto_iterator.go | 4 +-- graph/iterator/linksto_iterator_test.go | 8 ++--- graph/iterator/mock_ts_test.go | 22 ++++++------- graph/iterator/query_shape.go | 2 +- graph/iterator/query_shape_test.go | 22 ++++++------- graph/iterator/value_comparison_iterator.go | 2 +- graph/iterator/value_comparison_iterator_test.go | 6 ++-- graph/leveldb/iterator.go | 6 ++-- graph/leveldb/leveldb_test.go | 40 ++++++++++++------------ graph/leveldb/triplestore.go | 22 ++++++------- graph/leveldb/triplestore_iterator_optimize.go | 2 +- graph/memstore/triplestore.go | 18 +++++------ graph/memstore/triplestore_iterator_optimize.go | 2 +- graph/memstore/triplestore_test.go | 22 ++++++------- graph/mongo/iterator.go | 2 +- graph/mongo/triplestore.go | 24 +++++++------- graph/mongo/triplestore_iterator_optimize.go | 2 +- graph/sexp/parser.go | 4 +-- graph/sexp/parser_test.go | 16 +++++----- graph/sexp/session.go | 2 +- graph/triplestore.go | 22 ++++++------- query/gremlin/build_iterator.go | 28 ++++++++--------- query/gremlin/finals.go | 4 +-- query/gremlin/functional_test.go | 2 +- query/gremlin/session.go | 4 +-- query/mql/build_iterator.go | 8 ++--- query/mql/fill.go | 2 +- query/mql/session.go | 2 +- 29 files changed, 156 insertions(+), 156 deletions(-) diff --git a/graph/iterator/hasa_iterator.go b/graph/iterator/hasa_iterator.go index 0a16c71..6725ad5 100644 --- a/graph/iterator/hasa_iterator.go +++ b/graph/iterator/hasa_iterator.go @@ -126,13 +126,13 @@ func (it *HasA) DebugString(indent int) string { func (it *HasA) Check(val graph.TSVal) bool { graph.CheckLogIn(it, val) if glog.V(4) { - glog.V(4).Infoln("Id is", it.ts.GetNameFor(val)) + glog.V(4).Infoln("Id is", it.ts.NameOf(val)) } // TODO(barakmich): Optimize this if it.resultIt != nil { it.resultIt.Close() } - it.resultIt = it.ts.GetTripleIterator(it.dir, val) + it.resultIt = it.ts.TripleIterator(it.dir, val) return graph.CheckLogOut(it, val, it.GetCheckResult()) } @@ -146,10 +146,10 @@ func (it *HasA) GetCheckResult() bool { break } if glog.V(4) { - glog.V(4).Infoln("Triple is", it.ts.GetTriple(linkVal)) + glog.V(4).Infoln("Triple is", it.ts.Triple(linkVal)) } if it.primaryIt.Check(linkVal) { - it.Last = it.ts.GetTripleDirection(linkVal, it.dir) + it.Last = it.ts.TripleDirection(linkVal, it.dir) return true } } @@ -184,8 +184,8 @@ func (it *HasA) Next() (graph.TSVal, bool) { if !ok { return graph.NextLogOut(it, 0, false) } - name := it.ts.GetTriple(tID).Get(it.dir) - val := it.ts.GetIdFor(name) + name := it.ts.Triple(tID).Get(it.dir) + val := it.ts.ValueOf(name) it.Last = val return graph.NextLogOut(it, val, true) } diff --git a/graph/iterator/linksto_iterator.go b/graph/iterator/linksto_iterator.go index 8305124..d7654cc 100644 --- a/graph/iterator/linksto_iterator.go +++ b/graph/iterator/linksto_iterator.go @@ -100,7 +100,7 @@ func (it *LinksTo) DebugString(indent int) string { // for the LinksTo. func (it *LinksTo) Check(val graph.TSVal) bool { graph.CheckLogIn(it, val) - node := it.ts.GetTripleDirection(val, it.dir) + node := it.ts.TripleDirection(val, it.dir) if it.primaryIt.Check(node) { it.Last = val return graph.CheckLogOut(it, val, true) @@ -146,7 +146,7 @@ func (it *LinksTo) Next() (graph.TSVal, bool) { return graph.NextLogOut(it, 0, false) } it.nextIt.Close() - it.nextIt = it.ts.GetTripleIterator(it.dir, candidate) + it.nextIt = it.ts.TripleIterator(it.dir, candidate) // Recurse -- return the first in the next set. return it.Next() } diff --git a/graph/iterator/linksto_iterator_test.go b/graph/iterator/linksto_iterator_test.go index a799473..d350e52 100644 --- a/graph/iterator/linksto_iterator_test.go +++ b/graph/iterator/linksto_iterator_test.go @@ -24,16 +24,16 @@ func TestLinksTo(t *testing.T) { ts := new(TestTripleStore) tsFixed := newFixed() tsFixed.AddValue(2) - ts.On("GetIdFor", "cool").Return(1) - ts.On("GetTripleIterator", graph.Object, 1).Return(tsFixed) + ts.On("ValueOf", "cool").Return(1) + ts.On("TripleIterator", graph.Object, 1).Return(tsFixed) fixed := newFixed() - fixed.AddValue(ts.GetIdFor("cool")) + fixed.AddValue(ts.ValueOf("cool")) lto := NewLinksTo(ts, fixed, graph.Object) val, ok := lto.Next() if !ok { t.Error("At least one triple matches the fixed object") } if val != 2 { - t.Errorf("Triple index 2, such as %s, should match %s", ts.GetTriple(2), ts.GetTriple(val)) + t.Errorf("Triple index 2, such as %s, should match %s", ts.Triple(2), ts.Triple(val)) } } diff --git a/graph/iterator/mock_ts_test.go b/graph/iterator/mock_ts_test.go index 1aee954..bb2c031 100644 --- a/graph/iterator/mock_ts_test.go +++ b/graph/iterator/mock_ts_test.go @@ -27,23 +27,23 @@ type TestTripleStore struct { mock.Mock } -func (ts *TestTripleStore) GetIdFor(s string) graph.TSVal { +func (ts *TestTripleStore) ValueOf(s string) graph.TSVal { args := ts.Mock.Called(s) return args.Get(0) } -func (ts *TestTripleStore) AddTriple(*graph.Triple) {} -func (ts *TestTripleStore) AddTripleSet([]*graph.Triple) {} -func (ts *TestTripleStore) GetTriple(graph.TSVal) *graph.Triple { return &graph.Triple{} } -func (ts *TestTripleStore) GetTripleIterator(d graph.Direction, i graph.TSVal) graph.Iterator { +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 { args := ts.Mock.Called(d, i) return args.Get(0).(graph.Iterator) } -func (ts *TestTripleStore) GetNodesAllIterator() graph.Iterator { return &Null{} } -func (ts *TestTripleStore) GetTriplesAllIterator() graph.Iterator { return &Null{} } +func (ts *TestTripleStore) NodesAllIterator() graph.Iterator { return &Null{} } +func (ts *TestTripleStore) TriplesAllIterator() graph.Iterator { return &Null{} } func (ts *TestTripleStore) GetIteratorByString(string, string, string) graph.Iterator { return &Null{} } -func (ts *TestTripleStore) GetNameFor(v graph.TSVal) string { +func (ts *TestTripleStore) NameOf(v graph.TSVal) string { args := ts.Mock.Called(v) return args.Get(0).(string) } @@ -55,6 +55,6 @@ func (ts *TestTripleStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, func (ts *TestTripleStore) FixedIterator() graph.FixedIterator { return NewFixedIteratorWithCompare(BasicEquality) } -func (ts *TestTripleStore) Close() {} -func (ts *TestTripleStore) GetTripleDirection(graph.TSVal, graph.Direction) graph.TSVal { return 0 } -func (ts *TestTripleStore) RemoveTriple(t *graph.Triple) {} +func (ts *TestTripleStore) Close() {} +func (ts *TestTripleStore) TripleDirection(graph.TSVal, graph.Direction) graph.TSVal { return 0 } +func (ts *TestTripleStore) RemoveTriple(t *graph.Triple) {} diff --git a/graph/iterator/query_shape.go b/graph/iterator/query_shape.go index 2a54cda..7e34d77 100644 --- a/graph/iterator/query_shape.go +++ b/graph/iterator/query_shape.go @@ -133,7 +133,7 @@ func (qs *queryShape) MakeNode(it graph.Iterator) *Node { if !more { break } - n.Values = append(n.Values, qs.ts.GetNameFor(val)) + n.Values = append(n.Values, qs.ts.NameOf(val)) } case "hasa": hasa := it.(*HasA) diff --git a/graph/iterator/query_shape_test.go b/graph/iterator/query_shape_test.go index ef007e8..f8f1770 100644 --- a/graph/iterator/query_shape_test.go +++ b/graph/iterator/query_shape_test.go @@ -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.GetIdFor(target)) - fixed_pred.AddValue(ts.GetIdFor("status")) + fixed_obj.AddValue(ts.ValueOf(target)) + fixed_pred.AddValue(ts.ValueOf("status")) fixed_obj.AddTag(tag) lto1 := NewLinksTo(ts, fixed_obj, graph.Object) lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate) @@ -40,14 +40,14 @@ func buildHasaWithTag(ts graph.TripleStore, tag string, target string) *HasA { func TestQueryShape(t *testing.T) { var queryShape map[string]interface{} ts := new(TestTripleStore) - ts.On("GetIdFor", "cool").Return(1) - ts.On("GetNameFor", 1).Return("cool") - ts.On("GetIdFor", "status").Return(2) - ts.On("GetNameFor", 2).Return("status") - ts.On("GetIdFor", "fun").Return(3) - ts.On("GetNameFor", 3).Return("fun") - ts.On("GetIdFor", "name").Return(4) - ts.On("GetNameFor", 4).Return("name") + ts.On("ValueOf", "cool").Return(1) + ts.On("NameOf", 1).Return("cool") + ts.On("ValueOf", "status").Return(2) + ts.On("NameOf", 2).Return("status") + ts.On("ValueOf", "fun").Return(3) + ts.On("NameOf", 3).Return("fun") + ts.On("ValueOf", "name").Return(4) + ts.On("NameOf", 4).Return("name") Convey("Given a single linkage iterator's shape", t, func() { queryShape = make(map[string]interface{}) @@ -92,7 +92,7 @@ func TestQueryShape(t *testing.T) { andInternal.AddSubIterator(hasa1) andInternal.AddSubIterator(hasa2) fixed_pred := ts.FixedIterator() - fixed_pred.AddValue(ts.GetIdFor("name")) + fixed_pred.AddValue(ts.ValueOf("name")) lto1 := NewLinksTo(ts, andInternal, graph.Subject) lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate) and := NewAnd() diff --git a/graph/iterator/value_comparison_iterator.go b/graph/iterator/value_comparison_iterator.go index f6c9009..b1d9aa3 100644 --- a/graph/iterator/value_comparison_iterator.go +++ b/graph/iterator/value_comparison_iterator.go @@ -67,7 +67,7 @@ func NewComparison(sub graph.Iterator, op Operator, val interface{}, ts graph.Tr // and our operator, determine whether or not we meet the requirement. func (it *Comparison) doComparison(val graph.TSVal) bool { //TODO(barakmich): Implement string comparison. - nodeStr := it.ts.GetNameFor(val) + nodeStr := it.ts.NameOf(val) switch cVal := it.val.(type) { case int: cInt := int64(cVal) diff --git a/graph/iterator/value_comparison_iterator_test.go b/graph/iterator/value_comparison_iterator_test.go index 5e80f71..90a7ac1 100644 --- a/graph/iterator/value_comparison_iterator_test.go +++ b/graph/iterator/value_comparison_iterator_test.go @@ -23,8 +23,8 @@ import ( func SetupMockTripleStore(nameMap map[string]int) *TestTripleStore { ts := new(TestTripleStore) for k, v := range nameMap { - ts.On("GetIdFor", k).Return(v) - ts.On("GetNameFor", v).Return(k) + ts.On("ValueOf", k).Return(v) + ts.On("NameOf", v).Return(k) } return ts } @@ -59,7 +59,7 @@ func checkIteratorContains(ts graph.TripleStore, it graph.Iterator, expected []s if !ok { break } - actual = append(actual, ts.GetNameFor(val)) + actual = append(actual, ts.NameOf(val)) } actualSet := actual[:] for _, a := range expected { diff --git a/graph/leveldb/iterator.go b/graph/leveldb/iterator.go index 07171f9..26219be 100644 --- a/graph/leveldb/iterator.go +++ b/graph/leveldb/iterator.go @@ -177,8 +177,8 @@ func (it *Iterator) Check(v graph.TSVal) bool { return true } } else { - nameForDir := it.ts.GetTriple(v).Get(it.dir) - hashForDir := it.ts.GetIdFor(nameForDir).([]byte) + nameForDir := it.ts.Triple(v).Get(it.dir) + hashForDir := it.ts.ValueOf(nameForDir).([]byte) if bytes.Equal(hashForDir, it.checkId) { return true } @@ -192,7 +192,7 @@ func (it *Iterator) Size() (int64, bool) { func (it *Iterator) DebugString(indent int) string { size, _ := it.Size() - return fmt.Sprintf("%s(%s %d tags: %v dir: %s size:%d %s)", strings.Repeat(" ", indent), it.Type(), it.UID(), it.Tags(), it.dir, size, it.ts.GetNameFor(it.checkId)) + return fmt.Sprintf("%s(%s %d tags: %v dir: %s size:%d %s)", strings.Repeat(" ", indent), it.Type(), it.UID(), it.Tags(), it.dir, size, it.ts.NameOf(it.checkId)) } func (it *Iterator) Type() string { return "leveldb" } diff --git a/graph/leveldb/leveldb_test.go b/graph/leveldb/leveldb_test.go index 9982eea..f6100e0 100644 --- a/graph/leveldb/leveldb_test.go +++ b/graph/leveldb/leveldb_test.go @@ -50,7 +50,7 @@ func extractTripleFromIterator(ts graph.TripleStore, it graph.Iterator) []string if !ok { break } - output = append(output, ts.GetTriple(val).String()) + output = append(output, ts.Triple(val).String()) } return output } @@ -62,7 +62,7 @@ func extractValuesFromIterator(ts graph.TripleStore, it graph.Iterator) []string if !ok { break } - output = append(output, ts.GetNameFor(val)) + output = append(output, ts.NameOf(val)) } return output } @@ -113,7 +113,7 @@ func TestLoadDatabase(t *testing.T) { Convey("Can load a single triple", func() { ts.AddTriple(&graph.Triple{"Something", "points_to", "Something Else", "context"}) - So(ts.GetNameFor(ts.GetIdFor("Something")), ShouldEqual, "Something") + So(ts.NameOf(ts.ValueOf("Something")), ShouldEqual, "Something") So(ts.Size(), ShouldEqual, 1) }) @@ -121,12 +121,12 @@ func TestLoadDatabase(t *testing.T) { ts.AddTripleSet(makeTripleSet()) So(ts.Size(), ShouldEqual, 11) - So(ts.GetSizeFor(ts.GetIdFor("B")), ShouldEqual, 5) + So(ts.GetSizeFor(ts.ValueOf("B")), ShouldEqual, 5) Convey("Can delete triples", func() { ts.RemoveTriple(&graph.Triple{"A", "follows", "B", ""}) So(ts.Size(), ShouldEqual, 10) - So(ts.GetSizeFor(ts.GetIdFor("B")), ShouldEqual, 4) + So(ts.GetSizeFor(ts.ValueOf("B")), ShouldEqual, 4) }) }) @@ -153,7 +153,7 @@ func TestIterator(t *testing.T) { var it graph.Iterator Convey("Can create an all iterator for nodes", func() { - it = ts.GetNodesAllIterator() + it = ts.NodesAllIterator() So(it, ShouldNotBeNil) Convey("Has basics", func() { @@ -192,9 +192,9 @@ func TestIterator(t *testing.T) { }) Convey("Contains a couple nodes", func() { - So(it.Check(ts.GetIdFor("A")), ShouldBeTrue) - So(it.Check(ts.GetIdFor("cool")), ShouldBeTrue) - //So(it.Check(ts.GetIdFor("baller")), ShouldBeFalse) + So(it.Check(ts.ValueOf("A")), ShouldBeTrue) + So(it.Check(ts.ValueOf("cool")), ShouldBeTrue) + //So(it.Check(ts.ValueOf("baller")), ShouldBeFalse) }) Reset(func() { @@ -203,7 +203,7 @@ func TestIterator(t *testing.T) { }) Convey("Can create an all iterator for edges", func() { - it := ts.GetTriplesAllIterator() + it := ts.TriplesAllIterator() So(it, ShouldNotBeNil) Convey("Has basics", func() { size, accurate := it.Size() @@ -217,7 +217,7 @@ func TestIterator(t *testing.T) { Convey("Iterates an edge", func() { edge_val, _ := it.Next() - triple := ts.GetTriple(edge_val) + triple := ts.Triple(edge_val) set := makeTripleSet() var string_set []string for _, t := range set { @@ -249,7 +249,7 @@ func TestSetIterator(t *testing.T) { var it graph.Iterator Convey("Can create a subject iterator", func() { - it = ts.GetTripleIterator(graph.Subject, ts.GetIdFor("C")) + it = ts.TripleIterator(graph.Subject, ts.ValueOf("C")) Convey("Containing the right things", func() { expected := []string{ @@ -264,7 +264,7 @@ func TestSetIterator(t *testing.T) { Convey("And checkable", func() { and := iterator.NewAnd() - and.AddSubIterator(ts.GetTriplesAllIterator()) + and.AddSubIterator(ts.TriplesAllIterator()) and.AddSubIterator(it) expected := []string{ @@ -283,7 +283,7 @@ func TestSetIterator(t *testing.T) { }) Convey("Can create an object iterator", func() { - it = ts.GetTripleIterator(graph.Object, ts.GetIdFor("F")) + it = ts.TripleIterator(graph.Object, ts.ValueOf("F")) Convey("Containing the right things", func() { expected := []string{ @@ -298,7 +298,7 @@ func TestSetIterator(t *testing.T) { Convey("Mutually and-checkable", func() { and := iterator.NewAnd() - and.AddSubIterator(ts.GetTripleIterator(graph.Subject, ts.GetIdFor("B"))) + and.AddSubIterator(ts.TripleIterator(graph.Subject, ts.ValueOf("B"))) and.AddSubIterator(it) expected := []string{ @@ -313,7 +313,7 @@ func TestSetIterator(t *testing.T) { }) Convey("Can create a predicate iterator", func() { - it = ts.GetTripleIterator(graph.Predicate, ts.GetIdFor("status")) + it = ts.TripleIterator(graph.Predicate, ts.ValueOf("status")) Convey("Containing the right things", func() { expected := []string{ @@ -330,7 +330,7 @@ func TestSetIterator(t *testing.T) { }) Convey("Can create a provenance iterator", func() { - it = ts.GetTripleIterator(graph.Provenance, ts.GetIdFor("status_graph")) + it = ts.TripleIterator(graph.Provenance, ts.ValueOf("status_graph")) Convey("Containing the right things", func() { expected := []string{ @@ -347,7 +347,7 @@ func TestSetIterator(t *testing.T) { Convey("Can be cross-checked", func() { and := iterator.NewAnd() // Order is important - and.AddSubIterator(ts.GetTripleIterator(graph.Subject, ts.GetIdFor("B"))) + and.AddSubIterator(ts.TripleIterator(graph.Subject, ts.ValueOf("B"))) and.AddSubIterator(it) expected := []string{ @@ -361,7 +361,7 @@ func TestSetIterator(t *testing.T) { and := iterator.NewAnd() // Order is important and.AddSubIterator(it) - and.AddSubIterator(ts.GetTripleIterator(graph.Subject, ts.GetIdFor("B"))) + and.AddSubIterator(ts.TripleIterator(graph.Subject, ts.ValueOf("B"))) expected := []string{ (&graph.Triple{"B", "status", "cool", "status_graph"}).String(), @@ -399,7 +399,7 @@ func TestOptimize(t *testing.T) { Convey("With an linksto-fixed pair", func() { fixed := ts.FixedIterator() - fixed.AddValue(ts.GetIdFor("F")) + fixed.AddValue(ts.ValueOf("F")) fixed.AddTag("internal") lto = iterator.NewLinksTo(ts, fixed, graph.Object) diff --git a/graph/leveldb/triplestore.go b/graph/leveldb/triplestore.go index 0771f9c..0b88993 100644 --- a/graph/leveldb/triplestore.go +++ b/graph/leveldb/triplestore.go @@ -65,11 +65,11 @@ func CreateNewLevelDB(path string) bool { return true } -func NewTripleStore(path string, options graph.OptionsDict) *TripleStore { +func NewTripleStore(path string, options graph.Options) *TripleStore { var ts TripleStore ts.path = path cache_size := DefaultCacheSize - if val, ok := options.GetIntKey("cache_size_mb"); ok { + if val, ok := options.IntKey("cache_size_mb"); ok { cache_size = val } ts.dbOpts = &opt.Options{ @@ -78,7 +78,7 @@ func NewTripleStore(path string, options graph.OptionsDict) *TripleStore { ts.dbOpts.ErrorIfMissing = true write_buffer_mb := DefaultWriteBufferSize - if val, ok := options.GetIntKey("write_buffer_mb"); ok { + if val, ok := options.IntKey("write_buffer_mb"); ok { write_buffer_mb = val } ts.dbOpts.WriteBuffer = write_buffer_mb * opt.MiB @@ -301,7 +301,7 @@ func (ts *TripleStore) Close() { ts.open = false } -func (ts *TripleStore) GetTriple(k graph.TSVal) *graph.Triple { +func (ts *TripleStore) Triple(k graph.TSVal) *graph.Triple { var triple graph.Triple b, err := ts.db.Get(k.([]byte), ts.readopts) if err != nil && err != leveldb.ErrNotFound { @@ -328,7 +328,7 @@ func (ts *TripleStore) convertStringToByteHash(s string) []byte { return key } -func (ts *TripleStore) GetIdFor(s string) graph.TSVal { +func (ts *TripleStore) ValueOf(s string) graph.TSVal { return ts.createValueKeyFor(s) } @@ -352,7 +352,7 @@ func (ts *TripleStore) getValueData(value_key []byte) ValueData { return out } -func (ts *TripleStore) GetNameFor(k graph.TSVal) string { +func (ts *TripleStore) NameOf(k graph.TSVal) string { if k == nil { glog.V(2).Infoln("k was nil") return "" @@ -401,7 +401,7 @@ func (ts *TripleStore) GetApproximateSizeForPrefix(pre []byte) (int64, error) { return 0, nil } -func (ts *TripleStore) GetTripleIterator(d graph.Direction, val graph.TSVal) graph.Iterator { +func (ts *TripleStore) TripleIterator(d graph.Direction, val graph.TSVal) graph.Iterator { var prefix string switch d { case graph.Subject: @@ -418,21 +418,21 @@ func (ts *TripleStore) GetTripleIterator(d graph.Direction, val graph.TSVal) gra return NewIterator(prefix, d, val, ts) } -func (ts *TripleStore) GetNodesAllIterator() graph.Iterator { +func (ts *TripleStore) NodesAllIterator() graph.Iterator { return NewAllIterator("z", graph.Any, ts) } -func (ts *TripleStore) GetTriplesAllIterator() graph.Iterator { +func (ts *TripleStore) TriplesAllIterator() graph.Iterator { return NewAllIterator("po", graph.Predicate, ts) } -func (ts *TripleStore) GetTripleDirection(val graph.TSVal, d graph.Direction) graph.TSVal { +func (ts *TripleStore) TripleDirection(val graph.TSVal, d graph.Direction) graph.TSVal { v := val.([]uint8) offset := GetPositionFromPrefix(v[0:2], d, ts) if offset != -1 { return append([]byte("z"), v[offset:offset+ts.hasher.Size()]...) } else { - return ts.GetTriple(val).Get(d) + return ts.Triple(val).Get(d) } } diff --git a/graph/leveldb/triplestore_iterator_optimize.go b/graph/leveldb/triplestore_iterator_optimize.go index 8b5e37e..42a4082 100644 --- a/graph/leveldb/triplestore_iterator_optimize.go +++ b/graph/leveldb/triplestore_iterator_optimize.go @@ -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) diff --git a/graph/memstore/triplestore.go b/graph/memstore/triplestore.go index 5bc5d0c..5cb1be7 100644 --- a/graph/memstore/triplestore.go +++ b/graph/memstore/triplestore.go @@ -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() {} diff --git a/graph/memstore/triplestore_iterator_optimize.go b/graph/memstore/triplestore_iterator_optimize.go index c62416f..b48414c 100644 --- a/graph/memstore/triplestore_iterator_optimize.go +++ b/graph/memstore/triplestore_iterator_optimize.go @@ -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) diff --git a/graph/memstore/triplestore_test.go b/graph/memstore/triplestore_test.go index 15c5482..f5158c0 100644 --- a/graph/memstore/triplestore_test.go +++ b/graph/memstore/triplestore_test.go @@ -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) diff --git a/graph/mongo/iterator.go b/graph/mongo/iterator.go index 3515ccd..4b1c1c8 100644 --- a/graph/mongo/iterator.go +++ b/graph/mongo/iterator.go @@ -43,7 +43,7 @@ func NewIterator(ts *TripleStore, collection string, d graph.Direction, val grap var m Iterator iterator.BaseInit(&m.Base) - m.name = ts.GetNameFor(val) + m.name = ts.NameOf(val) m.collection = collection switch d { case graph.Subject: diff --git a/graph/mongo/triplestore.go b/graph/mongo/triplestore.go index 2555882..8fc0fab 100644 --- a/graph/mongo/triplestore.go +++ b/graph/mongo/triplestore.go @@ -37,7 +37,7 @@ type TripleStore struct { idCache *IDLru } -func CreateNewMongoGraph(addr string, options graph.OptionsDict) bool { +func CreateNewMongoGraph(addr string, options graph.Options) bool { conn, err := mgo.Dial(addr) if err != nil { glog.Fatal("Error connecting: ", err) @@ -45,7 +45,7 @@ func CreateNewMongoGraph(addr string, options graph.OptionsDict) bool { } conn.SetSafe(&mgo.Safe{}) dbName := DefaultDBName - if val, ok := options.GetStringKey("database_name"); ok { + if val, ok := options.StringKey("database_name"); ok { dbName = val } db := conn.DB(dbName) @@ -66,7 +66,7 @@ func CreateNewMongoGraph(addr string, options graph.OptionsDict) bool { return true } -func NewTripleStore(addr string, options graph.OptionsDict) *TripleStore { +func NewTripleStore(addr string, options graph.Options) *TripleStore { var ts TripleStore conn, err := mgo.Dial(addr) if err != nil { @@ -74,7 +74,7 @@ func NewTripleStore(addr string, options graph.OptionsDict) *TripleStore { } conn.SetSafe(&mgo.Safe{}) dbName := DefaultDBName - if val, ok := options.GetStringKey("database_name"); ok { + if val, ok := options.StringKey("database_name"); ok { dbName = val } ts.db = conn.DB(dbName) @@ -108,7 +108,7 @@ type MongoNode struct { func (ts *TripleStore) updateNodeBy(node_name string, inc int) { var size MongoNode - node := ts.GetIdFor(node_name) + node := ts.ValueOf(node_name) err := ts.db.C("nodes").FindId(node).One(&size) if err != nil { if err.Error() == "not found" { @@ -209,7 +209,7 @@ func (ts *TripleStore) RemoveTriple(t *graph.Triple) { } } -func (ts *TripleStore) GetTriple(val graph.TSVal) *graph.Triple { +func (ts *TripleStore) Triple(val graph.TSVal) *graph.Triple { var bsonDoc bson.M err := ts.db.C("triples").FindId(val.(string)).One(&bsonDoc) if err != nil { @@ -223,23 +223,23 @@ func (ts *TripleStore) GetTriple(val graph.TSVal) *graph.Triple { } } -func (ts *TripleStore) GetTripleIterator(d graph.Direction, val graph.TSVal) graph.Iterator { +func (ts *TripleStore) TripleIterator(d graph.Direction, val graph.TSVal) graph.Iterator { return NewIterator(ts, "triples", d, val) } -func (ts *TripleStore) GetNodesAllIterator() graph.Iterator { +func (ts *TripleStore) NodesAllIterator() graph.Iterator { return NewAllIterator(ts, "nodes") } -func (ts *TripleStore) GetTriplesAllIterator() graph.Iterator { +func (ts *TripleStore) TriplesAllIterator() graph.Iterator { return NewAllIterator(ts, "triples") } -func (ts *TripleStore) GetIdFor(s string) graph.TSVal { +func (ts *TripleStore) ValueOf(s string) graph.TSVal { return ts.ConvertStringToByteHash(s) } -func (ts *TripleStore) GetNameFor(v graph.TSVal) string { +func (ts *TripleStore) NameOf(v graph.TSVal) string { val, ok := ts.idCache.Get(v.(string)) if ok { return val @@ -274,7 +274,7 @@ func (ts *TripleStore) Close() { ts.db.Session.Close() } -func (ts *TripleStore) GetTripleDirection(in graph.TSVal, d graph.Direction) graph.TSVal { +func (ts *TripleStore) TripleDirection(in graph.TSVal, d graph.Direction) graph.TSVal { // Maybe do the trick here var offset int switch d { diff --git a/graph/mongo/triplestore_iterator_optimize.go b/graph/mongo/triplestore_iterator_optimize.go index 3a6250c..7b8e7cc 100644 --- a/graph/mongo/triplestore_iterator_optimize.go +++ b/graph/mongo/triplestore_iterator_optimize.go @@ -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) diff --git a/graph/sexp/parser.go b/graph/sexp/parser.go index 9c3fca7..9f3f0ef 100644 --- a/graph/sexp/parser.go +++ b/graph/sexp/parser.go @@ -188,7 +188,7 @@ func buildIteratorTree(tree *peg.ExpressionTree, ts graph.TripleStore) graph.Ite var out graph.Iterator nodeID := getIdentString(tree) if tree.Children[0].Name == "Variable" { - allIt := ts.GetNodesAllIterator() + allIt := ts.NodesAllIterator() allIt.AddTag(nodeID) out = allIt } else { @@ -197,7 +197,7 @@ func buildIteratorTree(tree *peg.ExpressionTree, ts graph.TripleStore) graph.Ite n = nodeID[1:] } fixed := ts.FixedIterator() - fixed.AddValue(ts.GetIdFor(n)) + fixed.AddValue(ts.ValueOf(n)) out = fixed } return out diff --git a/graph/sexp/parser_test.go b/graph/sexp/parser_test.go index 63a5a2d..11b9c68 100644 --- a/graph/sexp/parser_test.go +++ b/graph/sexp/parser_test.go @@ -47,7 +47,7 @@ func TestParseSexpWithMemstore(t *testing.T) { So(it.Type(), ShouldEqual, "and") out, ok := it.Next() So(ok, ShouldBeTrue) - So(out, ShouldEqual, ts.GetIdFor("i")) + So(out, ShouldEqual, ts.ValueOf("i")) }) Convey("It can get an internal linkage", func() { @@ -57,7 +57,7 @@ func TestParseSexpWithMemstore(t *testing.T) { So(it.Type(), ShouldEqual, "and") out, ok := it.Next() So(ok, ShouldBeTrue) - So(out, ShouldEqual, ts.GetIdFor("i")) + So(out, ShouldEqual, ts.ValueOf("i")) }) }) @@ -78,8 +78,8 @@ func TestTreeConstraintParse(t *testing.T) { if !ok { t.Error("Got no results") } - if out != ts.GetIdFor("i") { - t.Errorf("Got %d, expected %d", out, ts.GetIdFor("i")) + if out != ts.ValueOf("i") { + t.Errorf("Got %d, expected %d", out, ts.ValueOf("i")) } } @@ -97,8 +97,8 @@ func TestTreeConstraintTagParse(t *testing.T) { } tags := make(map[string]graph.TSVal) it.TagResults(&tags) - if ts.GetNameFor(tags["$a"]) != "food" { - t.Errorf("Got %s, expected food", ts.GetNameFor(tags["$a"])) + if ts.NameOf(tags["$a"]) != "food" { + t.Errorf("Got %s, expected food", ts.NameOf(tags["$a"])) } } @@ -119,8 +119,8 @@ func TestMultipleConstraintParse(t *testing.T) { if !ok { t.Error("Got no results") } - if out != ts.GetIdFor("i") { - t.Errorf("Got %d, expected %d", out, ts.GetIdFor("i")) + if out != ts.ValueOf("i") { + t.Errorf("Got %d, expected %d", out, ts.ValueOf("i")) } _, ok = it.Next() if ok { diff --git a/graph/sexp/session.go b/graph/sexp/session.go index e6b71de..1ef2ee0 100644 --- a/graph/sexp/session.go +++ b/graph/sexp/session.go @@ -115,7 +115,7 @@ func (s *Session) ToText(result interface{}) string { if k == "$_" { continue } - out += fmt.Sprintf("%s : %s\n", k, s.ts.GetNameFor((*tags)[k])) + out += fmt.Sprintf("%s : %s\n", k, s.ts.NameOf((*tags)[k])) } return out } diff --git a/graph/triplestore.go b/graph/triplestore.go index 8250988..7309779 100644 --- a/graph/triplestore.go +++ b/graph/triplestore.go @@ -47,24 +47,24 @@ type TripleStore interface { RemoveTriple(*Triple) // Given an opaque token, returns the triple for that token from the store. - GetTriple(TSVal) *Triple + Triple(TSVal) *Triple // Given a direction and a token, creates an iterator of links which have // that node token in that directional field. - GetTripleIterator(Direction, TSVal) Iterator + TripleIterator(Direction, TSVal) Iterator // Returns an iterator enumerating all nodes in the graph. - GetNodesAllIterator() Iterator + NodesAllIterator() Iterator // Returns an iterator enumerating all links in the graph. - GetTriplesAllIterator() Iterator + TriplesAllIterator() Iterator // Given a node ID, return the opaque token used by the TripleStore // to represent that id. - GetIdFor(string) TSVal + ValueOf(string) TSVal // Given an opaque token, return the node that it represents. - GetNameFor(TSVal) string + NameOf(TSVal) string // Returns the number of triples currently stored. Size() int64 @@ -88,13 +88,13 @@ type TripleStore interface { // gives the TripleStore the opportunity to make this optimization. // // Iterators will call this. At worst, a valid implementation is - // self.GetIdFor(self.GetTriple(triple_id).Get(dir)) - GetTripleDirection(triple_id TSVal, d Direction) TSVal + // ts.IdFor(ts.Triple(triple_id).Get(dir)) + TripleDirection(triple_id TSVal, d Direction) TSVal } -type OptionsDict map[string]interface{} +type Options map[string]interface{} -func (d OptionsDict) GetIntKey(key string) (int, bool) { +func (d Options) IntKey(key string) (int, bool) { if val, ok := d[key]; ok { switch vv := val.(type) { case float64: @@ -106,7 +106,7 @@ func (d OptionsDict) GetIntKey(key string) (int, bool) { return 0, false } -func (d OptionsDict) GetStringKey(key string) (string, bool) { +func (d Options) StringKey(key string) (string, bool) { if val, ok := d[key]; ok { switch vv := val.(type) { case string: diff --git a/query/gremlin/build_iterator.go b/query/gremlin/build_iterator.go index 9c81666..0fa98f0 100644 --- a/query/gremlin/build_iterator.go +++ b/query/gremlin/build_iterator.go @@ -68,14 +68,14 @@ func makeListOfStringsFromArrayValue(obj *otto.Object) []string { func buildIteratorFromValue(val otto.Value, ts graph.TripleStore) graph.Iterator { if val.IsNull() || val.IsUndefined() { - return ts.GetNodesAllIterator() + return ts.NodesAllIterator() } if val.IsPrimitive() { thing, _ := val.Export() switch v := thing.(type) { case string: it := ts.FixedIterator() - it.AddValue(ts.GetIdFor(v)) + it.AddValue(ts.ValueOf(v)) return it default: glog.Errorln("Trying to build unknown primitive value.") @@ -89,7 +89,7 @@ func buildIteratorFromValue(val otto.Value, ts graph.TripleStore) graph.Iterator strings := makeListOfStringsFromArrayValue(val.Object()) it := ts.FixedIterator() for _, x := range strings { - it.AddValue(ts.GetIdFor(x)) + it.AddValue(ts.ValueOf(x)) } return it case "Number": @@ -101,7 +101,7 @@ func buildIteratorFromValue(val otto.Value, ts graph.TripleStore) graph.Iterator case "String": it := ts.FixedIterator() str, _ := val.ToString() - it.AddValue(ts.GetIdFor(str)) + it.AddValue(ts.ValueOf(str)) return it default: glog.Errorln("Trying to handle unsupported Javascript value.") @@ -120,7 +120,7 @@ func buildInOutIterator(obj *otto.Object, ts graph.TripleStore, base graph.Itera length, _ := lengthVal.ToInteger() var predicateNodeIterator graph.Iterator if length == 0 { - predicateNodeIterator = ts.GetNodesAllIterator() + predicateNodeIterator = ts.NodesAllIterator() } else { zero, _ := argArray.Get("0") predicateNodeIterator = buildIteratorFromValue(zero, ts) @@ -168,11 +168,11 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. switch kind { case "vertex": if len(stringArgs) == 0 { - it = ts.GetNodesAllIterator() + it = ts.NodesAllIterator() } else { fixed := ts.FixedIterator() for _, name := range stringArgs { - fixed.AddValue(ts.GetIdFor(name)) + fixed.AddValue(ts.ValueOf(name)) } it = fixed } @@ -182,7 +182,7 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. it.AddTag(tag) } case "save": - all := ts.GetNodesAllIterator() + all := ts.NodesAllIterator() if len(stringArgs) > 2 || len(stringArgs) == 0 { return iterator.NewNull() } @@ -192,7 +192,7 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. all.AddTag(stringArgs[0]) } predFixed := ts.FixedIterator() - predFixed.AddValue(ts.GetIdFor(stringArgs[0])) + predFixed.AddValue(ts.ValueOf(stringArgs[0])) subAnd := iterator.NewAnd() subAnd.AddSubIterator(iterator.NewLinksTo(ts, predFixed, graph.Predicate)) subAnd.AddSubIterator(iterator.NewLinksTo(ts, all, graph.Object)) @@ -202,7 +202,7 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. and.AddSubIterator(subIt) it = and case "saver": - all := ts.GetNodesAllIterator() + all := ts.NodesAllIterator() if len(stringArgs) > 2 || len(stringArgs) == 0 { return iterator.NewNull() } @@ -212,7 +212,7 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. all.AddTag(stringArgs[0]) } predFixed := ts.FixedIterator() - predFixed.AddValue(ts.GetIdFor(stringArgs[0])) + predFixed.AddValue(ts.ValueOf(stringArgs[0])) subAnd := iterator.NewAnd() subAnd.AddSubIterator(iterator.NewLinksTo(ts, predFixed, graph.Predicate)) subAnd.AddSubIterator(iterator.NewLinksTo(ts, all, graph.Subject)) @@ -227,10 +227,10 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. return iterator.NewNull() } for _, name := range stringArgs[1:] { - fixed.AddValue(ts.GetIdFor(name)) + fixed.AddValue(ts.ValueOf(name)) } predFixed := ts.FixedIterator() - predFixed.AddValue(ts.GetIdFor(stringArgs[0])) + predFixed.AddValue(ts.ValueOf(stringArgs[0])) subAnd := iterator.NewAnd() subAnd.AddSubIterator(iterator.NewLinksTo(ts, predFixed, graph.Predicate)) subAnd.AddSubIterator(iterator.NewLinksTo(ts, fixed, graph.Object)) @@ -263,7 +263,7 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph. case "is": fixed := ts.FixedIterator() for _, name := range stringArgs { - fixed.AddValue(ts.GetIdFor(name)) + fixed.AddValue(ts.ValueOf(name)) } and := iterator.NewAnd() and.AddSubIterator(fixed) diff --git a/query/gremlin/finals.go b/query/gremlin/finals.go index 4babcd0..a2f8702 100644 --- a/query/gremlin/finals.go +++ b/query/gremlin/finals.go @@ -138,7 +138,7 @@ func mapFunc(env *otto.Otto, ses *Session, obj *otto.Object) func(otto.FunctionC func tagsToValueMap(m map[string]graph.TSVal, ses *Session) map[string]string { outputMap := make(map[string]string) for k, v := range m { - outputMap[k] = ses.ts.GetNameFor(v) + outputMap[k] = ses.ts.NameOf(v) } return outputMap } @@ -191,7 +191,7 @@ func runIteratorToArrayNoTags(it graph.Iterator, ses *Session, limit int) []stri if !ok { break } - output = append(output, ses.ts.GetNameFor(val)) + output = append(output, ses.ts.NameOf(val)) count++ if limit >= 0 && count >= limit { break diff --git a/query/gremlin/functional_test.go b/query/gremlin/functional_test.go index e1bf733..0bc32bf 100644 --- a/query/gremlin/functional_test.go +++ b/query/gremlin/functional_test.go @@ -63,7 +63,7 @@ func runQueryGetTag(query string, tag string) ([]string, int) { if data.val == nil { val := (*data.actualResults)[tag] if val != nil { - output = append(output, js.ts.GetNameFor(val)) + output = append(output, js.ts.NameOf(val)) } } } diff --git a/query/gremlin/session.go b/query/gremlin/session.go index d7c8665..7f07443 100644 --- a/query/gremlin/session.go +++ b/query/gremlin/session.go @@ -202,7 +202,7 @@ func (s *Session) ToText(result interface{}) string { if k == "$_" { continue } - out += fmt.Sprintf("%s : %s\n", k, s.ts.GetNameFor((*tags)[k])) + out += fmt.Sprintf("%s : %s\n", k, s.ts.NameOf((*tags)[k])) } } else { if data.val.IsObject() { @@ -234,7 +234,7 @@ func (ses *Session) BuildJson(result interface{}) { } sort.Strings(tagKeys) for _, k := range tagKeys { - obj[k] = ses.ts.GetNameFor((*tags)[k]) + obj[k] = ses.ts.NameOf((*tags)[k]) } ses.dataOutput = append(ses.dataOutput, obj) } else { diff --git a/query/mql/build_iterator.go b/query/mql/build_iterator.go index 6f4e9d3..cc18988 100644 --- a/query/mql/build_iterator.go +++ b/query/mql/build_iterator.go @@ -27,12 +27,12 @@ import ( func (q *Query) buildFixed(s string) graph.Iterator { f := q.ses.ts.FixedIterator() - f.AddValue(q.ses.ts.GetIdFor(s)) + f.AddValue(q.ses.ts.ValueOf(s)) return f } func (q *Query) buildResultIterator(path Path) graph.Iterator { - all := q.ses.ts.GetNodesAllIterator() + all := q.ses.ts.NodesAllIterator() all.AddTag(string(path)) return all } @@ -103,7 +103,7 @@ func (q *Query) buildIteratorTreeInternal(query interface{}, path Path) (it grap func (q *Query) buildIteratorTreeMapInternal(query map[string]interface{}, path Path) (graph.Iterator, error) { it := iterator.NewAnd() - it.AddSubIterator(q.ses.ts.GetNodesAllIterator()) + it.AddSubIterator(q.ses.ts.NodesAllIterator()) var err error err = nil outputStructure := make(map[string]interface{}) @@ -138,7 +138,7 @@ func (q *Query) buildIteratorTreeMapInternal(query map[string]interface{}, path } subAnd := iterator.NewAnd() predFixed := q.ses.ts.FixedIterator() - predFixed.AddValue(q.ses.ts.GetIdFor(pred)) + predFixed.AddValue(q.ses.ts.ValueOf(pred)) subAnd.AddSubIterator(iterator.NewLinksTo(q.ses.ts, predFixed, graph.Predicate)) if reverse { lto := iterator.NewLinksTo(q.ses.ts, builtIt, graph.Subject) diff --git a/query/mql/fill.go b/query/mql/fill.go index dabae91..d93da62 100644 --- a/query/mql/fill.go +++ b/query/mql/fill.go @@ -27,7 +27,7 @@ func (q *Query) treeifyResult(tags map[string]graph.TSVal) map[ResultPath]string if v == nil { continue } - results[Path(k)] = q.ses.ts.GetNameFor(v) + results[Path(k)] = q.ses.ts.NameOf(v) } resultPaths := make(map[ResultPath]string) for k, v := range results { diff --git a/query/mql/session.go b/query/mql/session.go index 059358e..af31b57 100644 --- a/query/mql/session.go +++ b/query/mql/session.go @@ -121,7 +121,7 @@ func (s *Session) ToText(result interface{}) string { if k == "$_" { continue } - out += fmt.Sprintf("%s : %s\n", k, s.ts.GetNameFor(tags[k])) + out += fmt.Sprintf("%s : %s\n", k, s.ts.NameOf(tags[k])) } return out }