From 189961cb8dce476878ae42bec44e357abce0e136 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Tue, 28 Apr 2015 15:57:35 -0700 Subject: [PATCH] Remove deprecated ResultTree API --- graph/bolt/all_iterator.go | 4 -- graph/bolt/iterator.go | 4 -- graph/gaedatastore/iterator.go | 4 -- graph/iterator.go | 3 -- graph/iterator/all_iterator.go | 5 --- graph/iterator/and_iterator.go | 10 ----- graph/iterator/fixed_iterator.go | 5 --- graph/iterator/hasa_iterator.go | 7 ---- graph/iterator/iterator.go | 4 -- graph/iterator/linksto_iterator.go | 7 ---- graph/iterator/materialize_iterator.go | 7 ---- graph/iterator/not_iterator.go | 8 ---- graph/iterator/optional_iterator.go | 5 --- graph/iterator/or_iterator.go | 9 ----- graph/iterator/unique_iterator.go | 7 ---- graph/iterator/value_comparison_iterator.go | 5 --- graph/leveldb/all_iterator.go | 4 -- graph/leveldb/iterator.go | 4 -- graph/memstore/iterator.go | 4 -- graph/mongo/indexed_linksto.go | 7 ---- graph/mongo/iterator.go | 4 -- graph/result_tree_evaluator.go | 59 ----------------------------- graph/result_tree_evaluator_test.go | 45 ---------------------- 23 files changed, 221 deletions(-) delete mode 100644 graph/result_tree_evaluator.go delete mode 100644 graph/result_tree_evaluator_test.go diff --git a/graph/bolt/all_iterator.go b/graph/bolt/all_iterator.go index d8fae27..0677b14 100644 --- a/graph/bolt/all_iterator.go +++ b/graph/bolt/all_iterator.go @@ -140,10 +140,6 @@ func (it *AllIterator) Err() error { return it.err } -func (it *AllIterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *AllIterator) Result() graph.Value { if it.done { return nil diff --git a/graph/bolt/iterator.go b/graph/bolt/iterator.go index d080391..4604531 100644 --- a/graph/bolt/iterator.go +++ b/graph/bolt/iterator.go @@ -191,10 +191,6 @@ func (it *Iterator) Err() error { return it.err } -func (it *Iterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Iterator) Result() graph.Value { if it.done { return nil diff --git a/graph/gaedatastore/iterator.go b/graph/gaedatastore/iterator.go index 8f3ef18..2992f19 100644 --- a/graph/gaedatastore/iterator.go +++ b/graph/gaedatastore/iterator.go @@ -209,10 +209,6 @@ func (it *Iterator) SubIterators() []graph.Iterator { return nil } -func (it *Iterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Iterator) Result() graph.Value { return it.result } diff --git a/graph/iterator.go b/graph/iterator.go index 67a79ba..6585ff5 100644 --- a/graph/iterator.go +++ b/graph/iterator.go @@ -86,9 +86,6 @@ type Iterator interface { // Returns the current result. Result() Value - // DEPRECATED -- Fills a ResultTree struct with Result(). - ResultTree() *ResultTree - // These methods are the heart and soul of the iterator, as they constitute // the iteration interface. // diff --git a/graph/iterator/all_iterator.go b/graph/iterator/all_iterator.go index 26e6302..048a7b3 100644 --- a/graph/iterator/all_iterator.go +++ b/graph/iterator/all_iterator.go @@ -109,11 +109,6 @@ func (it *Int64) Err() error { return nil } -// DEPRECATED -func (it *Int64) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Int64) Result() graph.Value { return it.result } diff --git a/graph/iterator/and_iterator.go b/graph/iterator/and_iterator.go index f315878..26f4749 100644 --- a/graph/iterator/and_iterator.go +++ b/graph/iterator/and_iterator.go @@ -102,16 +102,6 @@ func (it *And) SubIterators() []graph.Iterator { return iters } -// DEPRECATED Returns the ResultTree for this iterator, recurses to it's subiterators. -func (it *And) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.primaryIt.ResultTree()) - for _, sub := range it.internalIterators { - tree.AddSubtree(sub.ResultTree()) - } - return tree -} - func (it *And) Describe() graph.Description { subIts := make([]graph.Description, len(it.internalIterators)) for i, sub := range it.internalIterators { diff --git a/graph/iterator/fixed_iterator.go b/graph/iterator/fixed_iterator.go index fe112bc..c41def3 100644 --- a/graph/iterator/fixed_iterator.go +++ b/graph/iterator/fixed_iterator.go @@ -149,11 +149,6 @@ func (it *Fixed) Err() error { return nil } -// DEPRECATED -func (it *Fixed) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Fixed) Result() graph.Value { return it.result } diff --git a/graph/iterator/hasa_iterator.go b/graph/iterator/hasa_iterator.go index a799bdd..9547c54 100644 --- a/graph/iterator/hasa_iterator.go +++ b/graph/iterator/hasa_iterator.go @@ -121,13 +121,6 @@ func (it *HasA) TagResults(dst map[string]graph.Value) { it.primaryIt.TagResults(dst) } -// DEPRECATED Return results in a ResultTree. -func (it *HasA) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.primaryIt.ResultTree()) - return tree -} - func (it *HasA) Describe() graph.Description { primary := it.primaryIt.Describe() return graph.Description{ diff --git a/graph/iterator/iterator.go b/graph/iterator/iterator.go index 371025c..b326996 100644 --- a/graph/iterator/iterator.go +++ b/graph/iterator/iterator.go @@ -96,10 +96,6 @@ func (it *Null) Result() graph.Value { return nil } -func (it *Null) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Null) SubIterators() []graph.Iterator { return nil } diff --git a/graph/iterator/linksto_iterator.go b/graph/iterator/linksto_iterator.go index 930e929..ab4c3f3 100644 --- a/graph/iterator/linksto_iterator.go +++ b/graph/iterator/linksto_iterator.go @@ -99,13 +99,6 @@ func (it *LinksTo) TagResults(dst map[string]graph.Value) { it.primaryIt.TagResults(dst) } -// DEPRECATED -func (it *LinksTo) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.primaryIt.ResultTree()) - return tree -} - func (it *LinksTo) Describe() graph.Description { primary := it.primaryIt.Describe() return graph.Description{ diff --git a/graph/iterator/materialize_iterator.go b/graph/iterator/materialize_iterator.go index f6421d8..f7cbe4a 100644 --- a/graph/iterator/materialize_iterator.go +++ b/graph/iterator/materialize_iterator.go @@ -131,13 +131,6 @@ func (it *Materialize) Describe() graph.Description { // Register this iterator as a Materialize iterator. func (it *Materialize) Type() graph.Type { return graph.Materialize } -// DEPRECATED -func (it *Materialize) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.subIt.ResultTree()) - return tree -} - func (it *Materialize) Result() graph.Value { if it.aborted { return it.subIt.Result() diff --git a/graph/iterator/not_iterator.go b/graph/iterator/not_iterator.go index 98232d6..4d393e8 100644 --- a/graph/iterator/not_iterator.go +++ b/graph/iterator/not_iterator.go @@ -66,14 +66,6 @@ func (it *Not) SubIterators() []graph.Iterator { return []graph.Iterator{it.primaryIt, it.allIt} } -// DEPRECATED -func (it *Not) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.primaryIt.ResultTree()) - tree.AddSubtree(it.allIt.ResultTree()) - return tree -} - // Next advances the Not iterator. It returns whether there is another valid // new value. It fetches the next value of the all iterator which is not // contained by the primary iterator. diff --git a/graph/iterator/optional_iterator.go b/graph/iterator/optional_iterator.go index dbf654c..3cc32e2 100644 --- a/graph/iterator/optional_iterator.go +++ b/graph/iterator/optional_iterator.go @@ -72,11 +72,6 @@ func (it *Optional) Clone() graph.Iterator { return out } -// DEPRECATED -func (it *Optional) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Optional) Err() error { return it.err } diff --git a/graph/iterator/or_iterator.go b/graph/iterator/or_iterator.go index 25524e6..8311755 100644 --- a/graph/iterator/or_iterator.go +++ b/graph/iterator/or_iterator.go @@ -102,15 +102,6 @@ func (it *Or) TagResults(dst map[string]graph.Value) { it.internalIterators[it.currentIterator].TagResults(dst) } -// DEPRECATED Returns the ResultTree for this graph.iterator, recurses to it's subiterators. -func (it *Or) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - for _, sub := range it.internalIterators { - tree.AddSubtree(sub.ResultTree()) - } - return tree -} - func (it *Or) Describe() graph.Description { var subIts []graph.Description for i, sub := range it.internalIterators { diff --git a/graph/iterator/unique_iterator.go b/graph/iterator/unique_iterator.go index 930b136..8d031aa 100644 --- a/graph/iterator/unique_iterator.go +++ b/graph/iterator/unique_iterator.go @@ -64,13 +64,6 @@ func (it *Unique) SubIterators() []graph.Iterator { return []graph.Iterator{it.subIt} } -// DEPRECATED -func (it *Unique) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.subIt.ResultTree()) - return tree -} - // Next advances the subiterator, continuing until it returns a value which it // has not previously seen. func (it *Unique) Next() bool { diff --git a/graph/iterator/value_comparison_iterator.go b/graph/iterator/value_comparison_iterator.go index 0351d60..4aa6373 100644 --- a/graph/iterator/value_comparison_iterator.go +++ b/graph/iterator/value_comparison_iterator.go @@ -140,11 +140,6 @@ func (it *Comparison) Err() error { return it.err } -// DEPRECATED -func (it *Comparison) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Comparison) Result() graph.Value { return it.result } diff --git a/graph/leveldb/all_iterator.go b/graph/leveldb/all_iterator.go index e0d1bdc..8de7a09 100644 --- a/graph/leveldb/all_iterator.go +++ b/graph/leveldb/all_iterator.go @@ -123,10 +123,6 @@ func (it *AllIterator) Err() error { return it.iter.Error() } -func (it *AllIterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *AllIterator) Result() graph.Value { return it.result } diff --git a/graph/leveldb/iterator.go b/graph/leveldb/iterator.go index 83321ad..8501538 100644 --- a/graph/leveldb/iterator.go +++ b/graph/leveldb/iterator.go @@ -159,10 +159,6 @@ func (it *Iterator) Err() error { return it.iter.Error() } -func (it *Iterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Iterator) Result() graph.Value { return it.result } diff --git a/graph/memstore/iterator.go b/graph/memstore/iterator.go index b39b4bf..fb82a9f 100644 --- a/graph/memstore/iterator.go +++ b/graph/memstore/iterator.go @@ -138,10 +138,6 @@ func (it *Iterator) Err() error { return it.err } -func (it *Iterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Iterator) Result() graph.Value { return it.result } diff --git a/graph/mongo/indexed_linksto.go b/graph/mongo/indexed_linksto.go index 3830390..4f24d72 100644 --- a/graph/mongo/indexed_linksto.go +++ b/graph/mongo/indexed_linksto.go @@ -110,13 +110,6 @@ func (it *LinksTo) TagResults(dst map[string]graph.Value) { it.primaryIt.TagResults(dst) } -// DEPRECATED -func (it *LinksTo) ResultTree() *graph.ResultTree { - tree := graph.NewResultTree(it.Result()) - tree.AddSubtree(it.primaryIt.ResultTree()) - return tree -} - // Optimize the LinksTo, by replacing it if it can be. func (it *LinksTo) Optimize() (graph.Iterator, bool) { return it, false diff --git a/graph/mongo/iterator.go b/graph/mongo/iterator.go index 5362971..a476993 100644 --- a/graph/mongo/iterator.go +++ b/graph/mongo/iterator.go @@ -153,10 +153,6 @@ func (it *Iterator) Err() error { return it.err } -func (it *Iterator) ResultTree() *graph.ResultTree { - return graph.NewResultTree(it.Result()) -} - func (it *Iterator) Result() graph.Value { return it.result } diff --git a/graph/result_tree_evaluator.go b/graph/result_tree_evaluator.go deleted file mode 100644 index 56947d4..0000000 --- a/graph/result_tree_evaluator.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Cayley Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package graph - -import ( - "bytes" - "fmt" -) - -type ResultTree struct { - result Value - subtrees []*ResultTree -} - -func NewResultTree(result Value) *ResultTree { - return &ResultTree{result: result} -} - -func (t *ResultTree) String() string { - var buf bytes.Buffer - fmt.Fprintf(&buf, "(%d", t.result) - for _, sub := range t.subtrees { - fmt.Fprintf(&buf, " %s", sub) - } - buf.WriteByte(')') - return buf.String() -} - -func (t *ResultTree) AddSubtree(sub *ResultTree) { - t.subtrees = append(t.subtrees, sub) -} - -func StringResultTreeEvaluator(it Nexter) string { - var buf bytes.Buffer - for it.Next() { - fmt.Fprintln(&buf, it.ResultTree()) - for it.NextPath() { - buf.WriteByte(' ') - fmt.Fprintln(&buf, it.ResultTree()) - } - } - return buf.String() -} - -func PrintResultTreeEvaluator(it Nexter) { - fmt.Print(StringResultTreeEvaluator(it)) -} diff --git a/graph/result_tree_evaluator_test.go b/graph/result_tree_evaluator_test.go deleted file mode 100644 index ee733f9..0000000 --- a/graph/result_tree_evaluator_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Cayley Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package graph_test - -import ( - "testing" - - . "github.com/google/cayley/graph" - "github.com/google/cayley/graph/iterator" -) - -func TestSingleIterator(t *testing.T) { - all := iterator.NewInt64(1, 3) - result := StringResultTreeEvaluator(all) - expected := "(1)\n(2)\n(3)\n" - if expected != result { - t.Errorf("Expected %q got %q", expected, result) - } -} - -func TestAndIterator(t *testing.T) { - all1 := iterator.NewInt64(1, 3) - all2 := iterator.NewInt64(3, 5) - and := iterator.NewAnd(nil) - and.AddSubIterator(all1) - and.AddSubIterator(all2) - - result := StringResultTreeEvaluator(and) - expected := "(3 (3) (3))\n" - if expected != result { - t.Errorf("Expected %q got %q", expected, result) - } -}